1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 13:34:28 +00:00
This commit is contained in:
Steffo 2018-10-03 00:18:41 +02:00
parent d2449f6cf7
commit 2c467ba2b7
7 changed files with 141 additions and 56 deletions

42
db.py
View file

@ -904,31 +904,31 @@ class Halloween(Base):
def pieces_completed(self) -> int: def pieces_completed(self) -> int:
count = 0 count = 0
if puzzle_piece_a is not None: if self.puzzle_piece_a is not None:
count += 1 count += 1
if puzzle_piece_b is not None: if self.puzzle_piece_b is not None:
count += 1 count += 1
if puzzle_piece_c is not None: if self.puzzle_piece_c is not None:
count += 1 count += 1
if puzzle_piece_d is not None: if self.puzzle_piece_d is not None:
count += 1 count += 1
if puzzle_piece_e is not None: if self.puzzle_piece_e is not None:
count += 1 count += 1
if puzzle_piece_f is not None: if self.puzzle_piece_f is not None:
count += 1 count += 1
if puzzle_piece_g is not None: if self.puzzle_piece_g is not None:
count += 1 count += 1
if puzzle_piece_h is not None: if self.puzzle_piece_h is not None:
count += 1 count += 1
if puzzle_piece_i is not None: if self.puzzle_piece_i is not None:
count += 1 count += 1
if puzzle_piece_j is not None: if self.puzzle_piece_j is not None:
count += 1 count += 1
return count return count
@staticmethod @staticmethod
def puzzle_is_complete() -> bool: def puzzle_is_complete() -> bool:
session = db.Session() session = Session()
halloweens = session.query(Halloween).all() halloweens = session.query(Halloween).all()
session.close() session.close()
completed_a = False completed_a = False
@ -969,7 +969,7 @@ class Halloween(Base):
@staticmethod @staticmethod
def puzzle_piece_a_complete() -> bool: def puzzle_piece_a_complete() -> bool:
session = db.Session() session = Session()
halloweens = session.query(Halloween).all() halloweens = session.query(Halloween).all()
session.close() session.close()
for halloween in halloweens: for halloween in halloweens:
@ -979,7 +979,7 @@ class Halloween(Base):
@staticmethod @staticmethod
def puzzle_piece_b_complete() -> bool: def puzzle_piece_b_complete() -> bool:
session = db.Session() session = Session()
halloweens = session.query(Halloween).all() halloweens = session.query(Halloween).all()
session.close() session.close()
for halloween in halloweens: for halloween in halloweens:
@ -989,7 +989,7 @@ class Halloween(Base):
@staticmethod @staticmethod
def puzzle_piece_c_complete() -> bool: def puzzle_piece_c_complete() -> bool:
session = db.Session() session = Session()
halloweens = session.query(Halloween).all() halloweens = session.query(Halloween).all()
session.close() session.close()
for halloween in halloweens: for halloween in halloweens:
@ -1000,7 +1000,7 @@ class Halloween(Base):
@staticmethod @staticmethod
def puzzle_piece_d_complete() -> bool: def puzzle_piece_d_complete() -> bool:
session = db.Session() session = Session()
halloweens = session.query(Halloween).all() halloweens = session.query(Halloween).all()
session.close() session.close()
for halloween in halloweens: for halloween in halloweens:
@ -1010,7 +1010,7 @@ class Halloween(Base):
@staticmethod @staticmethod
def puzzle_piece_e_complete() -> bool: def puzzle_piece_e_complete() -> bool:
session = db.Session() session = Session()
halloweens = session.query(Halloween).all() halloweens = session.query(Halloween).all()
session.close() session.close()
for halloween in halloweens: for halloween in halloweens:
@ -1020,7 +1020,7 @@ class Halloween(Base):
@staticmethod @staticmethod
def puzzle_piece_f_complete() -> bool: def puzzle_piece_f_complete() -> bool:
session = db.Session() session = Session()
halloweens = session.query(Halloween).all() halloweens = session.query(Halloween).all()
session.close() session.close()
for halloween in halloweens: for halloween in halloweens:
@ -1030,7 +1030,7 @@ class Halloween(Base):
@staticmethod @staticmethod
def puzzle_piece_g_complete() -> bool: def puzzle_piece_g_complete() -> bool:
session = db.Session() session = Session()
halloweens = session.query(Halloween).all() halloweens = session.query(Halloween).all()
session.close() session.close()
for halloween in halloweens: for halloween in halloweens:
@ -1040,7 +1040,7 @@ class Halloween(Base):
@staticmethod @staticmethod
def puzzle_piece_h_complete() -> bool: def puzzle_piece_h_complete() -> bool:
session = db.Session() session = Session()
halloweens = session.query(Halloween).all() halloweens = session.query(Halloween).all()
session.close() session.close()
for halloween in halloweens: for halloween in halloweens:
@ -1050,7 +1050,7 @@ class Halloween(Base):
@staticmethod @staticmethod
def puzzle_piece_i_complete() -> bool: def puzzle_piece_i_complete() -> bool:
session = db.Session() session = Session()
halloweens = session.query(Halloween).all() halloweens = session.query(Halloween).all()
session.close() session.close()
for halloween in halloweens: for halloween in halloweens:
@ -1060,7 +1060,7 @@ class Halloween(Base):
@staticmethod @staticmethod
def puzzle_piece_j_complete() -> bool: def puzzle_piece_j_complete() -> bool:
session = db.Session() session = Session()
halloweens = session.query(Halloween).all() halloweens = session.query(Halloween).all()
session.close() session.close()
for halloween in halloweens: for halloween in halloweens:

View file

@ -265,6 +265,7 @@ class RoyalDiscordBot(discord.Client):
"!skip": self.cmd_skip, "!skip": self.cmd_skip,
"!s": self.cmd_skip, "!s": self.cmd_skip,
"!remove": self.cmd_remove, "!remove": self.cmd_remove,
"!r": self.cmd_remove,
"!cancel": self.cmd_remove, "!cancel": self.cmd_remove,
"!queue": self.cmd_queue, "!queue": self.cmd_queue,
"!q": self.cmd_queue, "!q": self.cmd_queue,
@ -494,7 +495,7 @@ class RoyalDiscordBot(discord.Client):
while True: while True:
# Fun things will happen with multiple voice clients! # Fun things will happen with multiple voice clients!
for voice_client in self.voice_clients: for voice_client in self.voice_clients:
if not voice_client.is_connected() or voice_client.is_playing(): if not voice_client.is_connected() or voice_client.is_playing() or voice_client.is_paused():
continue continue
if len(self.video_queue) == 0: if len(self.video_queue) == 0:
self.now_playing = None self.now_playing = None

View file

@ -749,6 +749,21 @@ table {
grid-column: 3; grid-column: 3;
} }
} }
.halloweenmini {
background-color: #311515;
padding: 18px;
grid-template-columns: 100%;
.stars {
grid-column: 1;
i {
color: yellow;
font-size: 30px;
}
}
}
} }
.wiki { .wiki {
@ -814,6 +829,11 @@ ntry {
.right { .right {
grid-column: 2; grid-column: 2;
} }
.halloween {
grid-column-start: 1;
grid-column-end: 3;
}
} }
@media (max-width:600px) { @media (max-width:600px) {
@ -828,6 +848,38 @@ ntry {
.right { .right {
grid-row: 2; grid-row: 2;
} }
.halloween {
grid-row-start: 1;
grid-row-end: 3;
}
}
.halloween {
.upper-box {
font-size: xx-large;
}
.lower-box {
text-align: center;
.stars a {
color: @link-color;
font-size: 64px;
&:hover {
color: @highlight-color;
}
.fas {
color: yellow;
}
}
.time-left {
font-size: 64px;
}
}
} }
} }
@ -878,28 +930,6 @@ ntry {
} }
} }
@keyframes shake {
0%, 100% {
transform: translate(2px, 2px);
}
20%, 80% {
transform: translate(-2px, -2px);
}
40% {
transform: translate(2px, -2px);
}
60% {
transform: translate(-2px, 2px);
}
10%, 30%, 50%, 70%, 90% {
transform: translate(0px, 0px);
}
}
#debug-mode { #debug-mode {
color: red; color: red;
font-weight: bold; font-weight: bold;

View file

@ -2,6 +2,7 @@
{% block prehead %} {% block prehead %}
<meta name="description" content="La Royal Games su {{ game_name }}"> <meta name="description" content="La Royal Games su {{ game_name }}">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
{% endblock %} {% endblock %}
{% block pagetitle %} {% block pagetitle %}

View file

@ -4,19 +4,22 @@
Pagina principale Pagina principale
{% endblock %} {% endblock %}
{% block prehead %}
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
{% endblock %}
{% block posthead %} {% block posthead %}
<script> <script>
var audio = new Audio("{{ url_for('static', filename='ee.ogg') }}"); function timer() {
var now = new Date().getTime();
var to = new Date("Oct 31, 2018 15:30:00").getTime();
var result = to - now;
document.getElementById("time-left").innerHTML = Math.floor(String((result / 3600000))) + "h "
+ Math.floor(String((result / 60000) % 60)) + "m "
+ Math.floor(String((result / 1000) % 60)) + "s";
}
function ee() { setInterval(timer, 100);
fetch("/ee/r", {
method: "POST",
mode: "same-origin",
credentials: "same-origin"
});
document.getElementById("main-title").innerHTML = '<span class="eetip" title="When there is something strange, in the neighbourhood, who you gonna call?">R</span>oyal Games';
audio.play();
}
</script> </script>
{% endblock %} {% endblock %}
@ -25,6 +28,32 @@
Royal Games Royal Games
</h1> </h1>
<div class="main-page"> <div class="main-page">
{% if config["DEBUG"] %}
<div class="halloween">
<div class="box">
<div class="upper-box">
Rituale di Halloween!
</div>
<div class="lower-box">
Lune raccolte:
<div class="stars">
{% for index, star in halloween %}
{% if star %}
<a href="/ritual/{{ index + 1 }}" title="Passo {{ index + 1 }} completato!"><i class="fas fa-moon"></i></a>
{% else %}
<a href="/ritual/{{ index + 1 }}" title="Passo {{ index + 1 }}"><i class="far fa-moon"></i></a>
{% endif %}
{% endfor %}
</div>
<br>
Tempo rimanente:
<div id="time-left" class="time-left">
Loading...
</div>
</div>
</div>
</div>
{% endif %}
<div class="left"> <div class="left">
<div class="box"> <div class="box">
<div class="upper-box"> <div class="upper-box">
@ -76,6 +105,7 @@
<li><a href="/game/lol">League of Legends</a></li> <li><a href="/game/lol">League of Legends</a></li>
<li><a href="/game/ow">Overwatch</a></li> <li><a href="/game/ow">Overwatch</a></li>
<li><a href="/game/osu">osu!</a></li> <li><a href="/game/osu">osu!</a></li>
<!--li><a href="/game/halloween">Rituale di Halloween</a></li-->
</ul> </ul>
</div> </div>
</div> </div>

View file

@ -2,6 +2,7 @@
{% block prehead %} {% block prehead %}
<meta name="description" content="Profilo Royalnet di {{ ryg.username }}"> <meta name="description" content="Profilo Royalnet di {{ ryg.username }}">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
{% endblock %} {% endblock %}
{% block pagetitle %} {% block pagetitle %}
@ -37,6 +38,11 @@
{% with record = ryg %} {% with record = ryg %}
{% include "minis/ryg.html" %} {% include "minis/ryg.html" %}
{% endwith %} {% endwith %}
{% if halloween %}
{% with record = halloween %}
{% include "minis/halloween.html" %}
{% endwith %}
{% endif %}
{% if tg %} {% if tg %}
{% with record = tg %} {% with record = tg %}
{% include "minis/tg.html" %} {% include "minis/tg.html" %}

View file

@ -66,9 +66,21 @@ def page_main():
random_diario = db_session.query(db.Diario).order_by(db.func.random()).first() 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( next_events = db_session.query(db.Event).filter(db.Event.time > datetime.datetime.now()).order_by(
db.Event.time).all() 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()
]
db_session.close() db_session.close()
return render_template("main.html", royals=royals, wiki_pages=wiki_pages, entry=random_diario, return render_template("main.html", royals=royals, wiki_pages=wiki_pages, entry=random_diario,
next_events=next_events, rygconf=config, escape=escape) next_events=next_events, rygconf=config, escape=escape, halloween=enumerate(halloween))
@app.route("/profile/<name>") @app.route("/profile/<name>")
@ -89,6 +101,7 @@ def page_profile(name: str):
tg = db_session.query(db.Telegram).filter_by(royal=user).one_or_none() tg = db_session.query(db.Telegram).filter_by(royal=user).one_or_none()
discord = db_session.execute(query_discord_music.one_query, {"royal": user.id}).fetchone() discord = db_session.execute(query_discord_music.one_query, {"royal": user.id}).fetchone()
gamelog = db_session.query(db.GameLog).filter_by(royal=user).one_or_none() gamelog = db_session.query(db.GameLog).filter_by(royal=user).one_or_none()
halloween = db_session.query(db.Halloween).filter_by(royal=user).one_or_none()
db_session.close() db_session.close()
if css is not None: if css is not None:
converted_bio = Markup(markdown2.markdown(css.bio.replace("<", "&lt;"), converted_bio = Markup(markdown2.markdown(css.bio.replace("<", "&lt;"),
@ -96,7 +109,8 @@ def page_profile(name: str):
else: else:
converted_bio = "" converted_bio = ""
return render_template("profile.html", ryg=user, css=css, osu=osu, dota=dota, lol=lol, steam=steam, ow=ow, return render_template("profile.html", ryg=user, css=css, osu=osu, dota=dota, lol=lol, steam=steam, ow=ow,
tg=tg, discord=discord, rygconf=config, bio=converted_bio, gamelog=gamelog) tg=tg, discord=discord, rygconf=config, bio=converted_bio, gamelog=gamelog,
halloween=halloween)
@app.route("/login") @app.route("/login")
@ -231,6 +245,9 @@ def page_game(name: str):
elif name == "discord": elif name == "discord":
game_name = "Discord" game_name = "Discord"
query = [dict(row) for row in db_session.execute(query_discord_music.all_query)] query = [dict(row) for row in db_session.execute(query_discord_music.all_query)]
elif name == "halloween":
game_name = "Rituale di Halloween"
query = db_session.query(db.Halloween).all()
else: else:
abort(404) abort(404)
return return