1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 13:34:28 +00:00

asdadsasdasda

This commit is contained in:
Steffo 2018-10-07 21:26:53 +02:00
parent cd44cb150d
commit 2036ec2515
5 changed files with 26 additions and 54 deletions

21
db.py
View file

@ -898,9 +898,6 @@ class Halloween(Base):
puzzle_piece_e = Column(DateTime) puzzle_piece_e = Column(DateTime)
puzzle_piece_f = Column(DateTime) puzzle_piece_f = Column(DateTime)
puzzle_piece_g = Column(DateTime) puzzle_piece_g = Column(DateTime)
puzzle_piece_h = Column(DateTime)
puzzle_piece_i = Column(DateTime)
puzzle_piece_j = Column(DateTime)
boss_battle = Column(DateTime) boss_battle = Column(DateTime)
@ -921,12 +918,6 @@ class Halloween(Base):
return self.puzzle_piece_f return self.puzzle_piece_f
elif item == 7: elif item == 7:
return self.puzzle_piece_g return self.puzzle_piece_g
elif item == 8:
return self.puzzle_piece_h
elif item == 9:
return self.puzzle_piece_i
elif item == 10:
return self.puzzle_piece_j
else: else:
raise ValueError("No such puzzle piece") raise ValueError("No such puzzle piece")
@ -947,18 +938,12 @@ class Halloween(Base):
self.puzzle_piece_f = value self.puzzle_piece_f = value
elif key == 7: elif key == 7:
self.puzzle_piece_g = value self.puzzle_piece_g = value
elif key == 8:
self.puzzle_piece_h = value
elif key == 9:
self.puzzle_piece_i = value
elif key == 10:
self.puzzle_piece_j = value
else: else:
raise ValueError("No such puzzle piece") raise ValueError("No such puzzle piece")
def pieces_completed(self) -> int: def pieces_completed(self) -> int:
count = 0 count = 0
for i in range(1, 11): for i in range(1, 8):
if self[i]: if self[i]:
count += 1 count += 1
return count return count
@ -969,9 +954,9 @@ class Halloween(Base):
halloweens = session.query(Halloween).all() halloweens = session.query(Halloween).all()
session.close() session.close()
started = bool(halloweens) started = bool(halloweens)
completed = [False for _ in range(10)] completed = [False for _ in range(7)]
for h in halloweens: for h in halloweens:
for i in range(10): for i in range(7):
if h[i+1]: if h[i+1]:
completed[i] = True completed[i] = True
return started, completed return started, completed

View file

@ -526,7 +526,7 @@ class RoyalDiscordBot(discord.Client):
if "ghostbusters" in now_playing.plain_text().lower(): if "ghostbusters" in now_playing.plain_text().lower():
halloween = await loop.run_in_executor(executor, session.query(db.Halloween) halloween = await loop.run_in_executor(executor, session.query(db.Halloween)
.filter_by(royal=enqueuer).one_or_none) .filter_by(royal=enqueuer).one_or_none)
halloween[4] = True halloween[5] = datetime.datetime.now()
# END # END
await loop.run_in_executor(executor, session.commit) await loop.run_in_executor(executor, session.commit)
await loop.run_in_executor(executor, session.close) await loop.run_in_executor(executor, session.close)

View file

@ -47,12 +47,15 @@ def page_voiceofevil():
if request.form.get("solution", "") != "1": if request.form.get("solution", "") != "1":
abort(400) abort(400)
return return
if "user_id" not in request.form:
abort(403)
return
db_session = db.Session() db_session = db.Session()
halloween = db_session.query(db.Halloween).filter_by(royal_id=fl_session["user_id"]).one_or_none() halloween = db_session.query(db.Halloween).filter_by(royal_id=request.form["user_id"]).one_or_none()
if halloween is None: if halloween is None:
abort(403) abort(403)
return return
halloween[3] = True halloween[4] = datetime.datetime.now()
db_session.commit() db_session.commit()
return redirect(url_for("page_owlcaptain")) return redirect(url_for("page_owlcaptain"))
@ -63,11 +66,11 @@ def page_mansion():
abort(400) abort(400)
return return
db_session = db.Session() db_session = db.Session()
halloween = db_session.query(db.Halloween).filter_by(royal_id=fl_session["user_id"]).one_or_none() halloween = db_session.query(db.Halloween).filter_by(royal_id=request.form["user_id"]).one_or_none()
if halloween is None: if halloween is None:
abort(403) abort(403)
return return
halloween[5] = True halloween[6] = datetime.datetime.now()
db_session.commit() db_session.commit()
return redirect(url_for("page_owlcaptain")) return redirect(url_for("page_owlcaptain"))

View file

@ -7,7 +7,7 @@
Lune ottenute Lune ottenute
</div> </div>
<div class="game-score mysterystatus"> <div class="game-score mysterystatus">
{% for index in range(10) %} {% for index in range(7) %}
{% if record[index + 1] %} {% if record[index + 1] %}
<i class="fas fa-moon done"></i> <i class="fas fa-moon done"></i>
{% else %} {% else %}

View file

@ -27,15 +27,18 @@
mode: "cors", mode: "cors",
credentials: "include" credentials: "include"
}).done((result) => { }).done((result) => {
data = result.json(); result.json().done((result) => {
if(data["user_id"] === null) { if(result["id"] === null) {
document.getElementById("main").innerHTML = "i don't know you. " + document.getElementById("main").innerHTML = "i don't know you. " +
"<a href='https://ryg.steffo.eu/login'>try logging in</a> first."; "<a href='https://ryg.steffo.eu/login'>try logging in</a> first.";
return; return;
user_id = data["user_id"]; }
username = data["username"]; user_id = result["id"];
} username = result["username"];
document.getElementsByName("user_id").forEach((item) => {
item.setAttribute("value", user_id);
})
});
}) })
} }
@ -114,6 +117,7 @@
</div> </div>
<form action="/voiceofevil" method="POST"> <form action="/voiceofevil" method="POST">
<input name="solution" type="text" placeholder="?"> <input name="solution" type="text" placeholder="?">
<input type="hidden" name="user_id">
<input type="submit" value="this is my answer!"> <input type="submit" value="this is my answer!">
</form> </form>
{% elif loop.index == 5 %} {% elif loop.index == 5 %}
@ -138,6 +142,7 @@
</div> </div>
<form action="/mansion" method="POST"> <form action="/mansion" method="POST">
<input name="solution" type="text" placeholder="?"> <input name="solution" type="text" placeholder="?">
<input type="hidden" name="user_id">
<input type="submit" value="this is my answer!"> <input type="submit" value="this is my answer!">
</form> </form>
{% elif loop.index == 7 %} {% elif loop.index == 7 %}
@ -146,27 +151,6 @@
</h2> </h2>
<div class="description"> <div class="description">
</div>
{% elif loop.index == 8 %}
<h2>
</h2>
<div class="description">
</div>
{% elif loop.index == 9 %}
<h2>
</h2>
<div class="description">
</div>
{% elif loop.index == 10 %}
<h2>
</h2>
<div class="description">
</div> </div>
{% endif %} {% endif %}
</div> </div>