mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
more spooky stuff
This commit is contained in:
parent
c76b110402
commit
38ed4c292d
6 changed files with 128 additions and 193 deletions
222
db.py
222
db.py
|
@ -1,6 +1,8 @@
|
|||
import datetime
|
||||
import logging
|
||||
import os
|
||||
import typing
|
||||
|
||||
import coloredlogs
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.orm import sessionmaker, relationship, joinedload
|
||||
|
@ -902,172 +904,76 @@ class Halloween(Base):
|
|||
|
||||
boss_battle = Column(DateTime)
|
||||
|
||||
def __getitem__(self, item):
|
||||
if not isinstance(item, int):
|
||||
raise TypeError("The index should be an int")
|
||||
if item == 1:
|
||||
return self.puzzle_piece_a
|
||||
elif item == 2:
|
||||
return self.puzzle_piece_b
|
||||
elif item == 3:
|
||||
return self.puzzle_piece_c
|
||||
elif item == 4:
|
||||
return self.puzzle_piece_d
|
||||
elif item == 5:
|
||||
return self.puzzle_piece_e
|
||||
elif item == 6:
|
||||
return self.puzzle_piece_f
|
||||
elif item == 7:
|
||||
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:
|
||||
raise ValueError("No such puzzle piece")
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
if not isinstance(key, int):
|
||||
raise TypeError("The index should be an int")
|
||||
if key == 1:
|
||||
self.puzzle_piece_a = value
|
||||
elif key == 2:
|
||||
self.puzzle_piece_b = value
|
||||
elif key == 3:
|
||||
self.puzzle_piece_c = value
|
||||
elif key == 4:
|
||||
self.puzzle_piece_d = value
|
||||
elif key == 5:
|
||||
self.puzzle_piece_e = value
|
||||
elif key == 6:
|
||||
self.puzzle_piece_f = value
|
||||
elif key == 7:
|
||||
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:
|
||||
raise ValueError("No such puzzle piece")
|
||||
|
||||
def pieces_completed(self) -> int:
|
||||
count = 0
|
||||
if self.puzzle_piece_a is not None:
|
||||
count += 1
|
||||
if self.puzzle_piece_b is not None:
|
||||
count += 1
|
||||
if self.puzzle_piece_c is not None:
|
||||
count += 1
|
||||
if self.puzzle_piece_d is not None:
|
||||
count += 1
|
||||
if self.puzzle_piece_e is not None:
|
||||
count += 1
|
||||
if self.puzzle_piece_f is not None:
|
||||
count += 1
|
||||
if self.puzzle_piece_g is not None:
|
||||
count += 1
|
||||
if self.puzzle_piece_h is not None:
|
||||
count += 1
|
||||
if self.puzzle_piece_i is not None:
|
||||
count += 1
|
||||
if self.puzzle_piece_j is not None:
|
||||
count += 1
|
||||
for i in range(1, 11):
|
||||
if self[i]:
|
||||
count += 1
|
||||
return count
|
||||
|
||||
@staticmethod
|
||||
def puzzle_is_complete() -> bool:
|
||||
def puzzle_status() -> typing.List[bool]:
|
||||
session = Session()
|
||||
halloweens = session.query(Halloween).all()
|
||||
session.close()
|
||||
completed_a = False
|
||||
completed_b = False
|
||||
completed_c = False
|
||||
completed_d = False
|
||||
completed_e = False
|
||||
completed_f = False
|
||||
completed_g = False
|
||||
completed_h = False
|
||||
completed_i = False
|
||||
completed_j = False
|
||||
for halloween in halloweens:
|
||||
if halloween.puzzle_piece_a is not None:
|
||||
completed_a = True
|
||||
if halloween.puzzle_piece_b is not None:
|
||||
completed_b = True
|
||||
if halloween.puzzle_piece_c is not None:
|
||||
completed_c = True
|
||||
if halloween.puzzle_piece_d is not None:
|
||||
completed_d = True
|
||||
if halloween.puzzle_piece_d is not None:
|
||||
completed_d = True
|
||||
if halloween.puzzle_piece_e is not None:
|
||||
completed_e = True
|
||||
if halloween.puzzle_piece_f is not None:
|
||||
completed_f = True
|
||||
if halloween.puzzle_piece_g is not None:
|
||||
completed_g = True
|
||||
if halloween.puzzle_piece_h is not None:
|
||||
completed_h = True
|
||||
if halloween.puzzle_piece_i is not None:
|
||||
completed_i = True
|
||||
if halloween.puzzle_piece_j is not None:
|
||||
completed_j = True
|
||||
return (completed_a and completed_b and completed_c and completed_d and completed_e
|
||||
and completed_f and completed_g and completed_h and completed_i and completed_j)
|
||||
|
||||
@staticmethod
|
||||
def puzzle_piece_a_complete() -> bool:
|
||||
session = Session()
|
||||
halloweens = session.query(Halloween).all()
|
||||
session.close()
|
||||
for halloween in halloweens:
|
||||
if halloween.puzzle_piece_a is not None:
|
||||
return True
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def puzzle_piece_b_complete() -> bool:
|
||||
session = Session()
|
||||
halloweens = session.query(Halloween).all()
|
||||
session.close()
|
||||
for halloween in halloweens:
|
||||
if halloween.puzzle_piece_b is not None:
|
||||
return True
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def puzzle_piece_c_complete() -> bool:
|
||||
session = Session()
|
||||
halloweens = session.query(Halloween).all()
|
||||
session.close()
|
||||
for halloween in halloweens:
|
||||
if halloween.puzzle_piece_c is not None:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
@staticmethod
|
||||
def puzzle_piece_d_complete() -> bool:
|
||||
session = Session()
|
||||
halloweens = session.query(Halloween).all()
|
||||
session.close()
|
||||
for halloween in halloweens:
|
||||
if halloween.puzzle_piece_d is not None:
|
||||
return True
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def puzzle_piece_e_complete() -> bool:
|
||||
session = Session()
|
||||
halloweens = session.query(Halloween).all()
|
||||
session.close()
|
||||
for halloween in halloweens:
|
||||
if halloween.puzzle_piece_e is not None:
|
||||
return True
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def puzzle_piece_f_complete() -> bool:
|
||||
session = Session()
|
||||
halloweens = session.query(Halloween).all()
|
||||
session.close()
|
||||
for halloween in halloweens:
|
||||
if halloween.puzzle_piece_f is not None:
|
||||
return True
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def puzzle_piece_g_complete() -> bool:
|
||||
session = Session()
|
||||
halloweens = session.query(Halloween).all()
|
||||
session.close()
|
||||
for halloween in halloweens:
|
||||
if halloween.puzzle_piece_g is not None:
|
||||
return True
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def puzzle_piece_h_complete() -> bool:
|
||||
session = Session()
|
||||
halloweens = session.query(Halloween).all()
|
||||
session.close()
|
||||
for halloween in halloweens:
|
||||
if halloween.puzzle_piece_h is not None:
|
||||
return True
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def puzzle_piece_i_complete() -> bool:
|
||||
session = Session()
|
||||
halloweens = session.query(Halloween).all()
|
||||
session.close()
|
||||
for halloween in halloweens:
|
||||
if halloween.puzzle_piece_i is not None:
|
||||
return True
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def puzzle_piece_j_complete() -> bool:
|
||||
session = Session()
|
||||
halloweens = session.query(Halloween).all()
|
||||
session.close()
|
||||
for halloween in halloweens:
|
||||
if halloween.puzzle_piece_j is not None:
|
||||
return True
|
||||
return False
|
||||
|
||||
completed = [False for _ in range(10)]
|
||||
for h in halloweens:
|
||||
for i in range(10):
|
||||
if h[i+1]:
|
||||
completed[i] = True
|
||||
return completed
|
||||
|
||||
# If run as script, create all the tables in the db
|
||||
if __name__ == "__main__":
|
||||
|
|
BIN
static/lamorteaspettasolote.ogg
Normal file
BIN
static/lamorteaspettasolote.ogg
Normal file
Binary file not shown.
|
@ -755,12 +755,11 @@ table {
|
|||
padding: 18px;
|
||||
grid-template-columns: 100%;
|
||||
|
||||
.stars {
|
||||
grid-column: 1;
|
||||
.moons.game-score {
|
||||
font-size: 0;
|
||||
|
||||
i {
|
||||
color: yellow;
|
||||
font-size: 30px;
|
||||
font-size: 34px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -863,20 +862,12 @@ ntry {
|
|||
.lower-box {
|
||||
text-align: center;
|
||||
|
||||
.stars a {
|
||||
color: @text-color;
|
||||
.time-left {
|
||||
font-size: 64px;
|
||||
|
||||
&:hover {
|
||||
color: @highlight-color;
|
||||
}
|
||||
|
||||
.fas {
|
||||
color: yellow;
|
||||
}
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
.time-left {
|
||||
.moons {
|
||||
font-size: 64px;
|
||||
}
|
||||
}
|
||||
|
@ -930,6 +921,18 @@ ntry {
|
|||
}
|
||||
}
|
||||
|
||||
.moons a {
|
||||
color: @text-color;
|
||||
|
||||
&:hover {
|
||||
color: @highlight-color;
|
||||
}
|
||||
|
||||
.fas {
|
||||
color: yellow;
|
||||
}
|
||||
}
|
||||
|
||||
#debug-mode {
|
||||
color: red;
|
||||
font-weight: bold;
|
||||
|
|
|
@ -36,12 +36,12 @@
|
|||
</div>
|
||||
<div class="lower-box">
|
||||
Lune raccolte:
|
||||
<div class="stars">
|
||||
<div class="moons">
|
||||
{% for index, star in halloween %}
|
||||
{% if star %}
|
||||
<a href="/ritual/{{ index + 1 }}" title="Passo {{ index + 1 }} completato!"><i class="fas fa-moon"></i></a>
|
||||
<a href="/ritual/{{ index }}" title="Luna {{ index }} ottenuta!"><i class="fas fa-moon"></i></a>
|
||||
{% else %}
|
||||
<a href="/ritual/{{ index + 1 }}" title="Passo {{ index + 1 }}"><i class="far fa-moon"></i></a>
|
||||
<a href="/ritual/{{ index }}" title="Rituale {{ index }}"><i class="far fa-moon"></i></a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
@ -97,6 +97,9 @@
|
|||
<div class="lower-box">
|
||||
<ul>
|
||||
<li><a href="/game/ryg">Royal Games</a></li>
|
||||
{% if config["DEBUG"] %}
|
||||
<li><a href="/game/halloween">Rituale di Halloween</a></li>
|
||||
{% endif %}
|
||||
<li><a href="/game/tg">Telegram</a></li>
|
||||
<li><a href="/game/discord">Discord</a></li>
|
||||
<li><a href="/game/steam">Steam</a></li>
|
||||
|
@ -105,7 +108,6 @@
|
|||
<li><a href="/game/lol">League of Legends</a></li>
|
||||
<li><a href="/game/ow">Overwatch</a></li>
|
||||
<li><a href="/game/osu">osu!</a></li>
|
||||
<!--li><a href="/game/halloween">Rituale di Halloween</a></li-->
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -3,12 +3,16 @@
|
|||
<div class="player">
|
||||
<span class="player-name">Rituale di Halloween</span>
|
||||
</div>
|
||||
<div class="game-title stars">
|
||||
<div class="game-title moons">
|
||||
Lune ottenute
|
||||
</div>
|
||||
<div class="game-score stars">
|
||||
{% for index in range(record.pieces_completed()) %}
|
||||
<i class="fas fa-moon"></i>
|
||||
<div class="game-score moons">
|
||||
{% for index in range(10) %}
|
||||
{% if halloween[index] %}
|
||||
<a href="/ritual/{{ index + 1 }}" title="Luna {{ index + 1 }} ottenuta!"><i class="fas fa-moon"></i></a>
|
||||
{% else %}
|
||||
<a href="/ritual/{{ index + 1 }}" title="Rituale {{ index + 1 }}"><i class="far fa-moon"></i></a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
|
44
webserver.py
44
webserver.py
|
@ -66,18 +66,7 @@ def page_main():
|
|||
random_diario = db_session.query(db.Diario).order_by(db.func.random()).first()
|
||||
next_events = db_session.query(db.Event).filter(db.Event.time > datetime.datetime.now()).order_by(
|
||||
db.Event.time).all()
|
||||
halloween = [
|
||||
db.Halloween.puzzle_piece_a_complete(),
|
||||
db.Halloween.puzzle_piece_b_complete(),
|
||||
db.Halloween.puzzle_piece_c_complete(),
|
||||
db.Halloween.puzzle_piece_d_complete(),
|
||||
db.Halloween.puzzle_piece_e_complete(),
|
||||
db.Halloween.puzzle_piece_f_complete(),
|
||||
db.Halloween.puzzle_piece_g_complete(),
|
||||
db.Halloween.puzzle_piece_h_complete(),
|
||||
db.Halloween.puzzle_piece_i_complete(),
|
||||
db.Halloween.puzzle_piece_j_complete()
|
||||
]
|
||||
halloween = db.Halloween.puzzle_status()
|
||||
db_session.close()
|
||||
return render_template("main.html", royals=royals, wiki_pages=wiki_pages, entry=random_diario,
|
||||
next_events=next_events, rygconf=config, escape=escape, halloween=enumerate(halloween))
|
||||
|
@ -343,6 +332,37 @@ def page_diario():
|
|||
return render_template("diario.html", rygconf=config, entries=diario_entries)
|
||||
|
||||
|
||||
@app.route("/ritual/<int:n>", methods=["GET", "POST"])
|
||||
def page_ritual(n: int):
|
||||
user_id = fl_session.get("user_id")
|
||||
if not user_id:
|
||||
return redirect(url_for("page_login"))
|
||||
if request.method == "GET":
|
||||
return render_template("ritual.html", rygconf=config, n=n)
|
||||
elif request.method == "POST":
|
||||
if n == 1:
|
||||
pass
|
||||
elif n == 2:
|
||||
pass
|
||||
elif n == 3:
|
||||
pass
|
||||
elif n == 4:
|
||||
pass
|
||||
elif n == 5:
|
||||
pass
|
||||
elif n == 6:
|
||||
pass
|
||||
elif n == 7:
|
||||
pass
|
||||
elif n == 8:
|
||||
pass
|
||||
elif n == 9:
|
||||
pass
|
||||
elif n == 10:
|
||||
pass
|
||||
return redirect(url_for("page_ritual", n=n))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
app.run(host="0.0.0.0", port=1235, debug=__debug__)
|
||||
|
|
Loading…
Reference in a new issue