From 2c467ba2b7e079d24a757c1e97b1b95cf8b13624 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 3 Oct 2018 00:18:41 +0200 Subject: [PATCH] sssh --- db.py | 42 ++++++++++++------------ discordbot.py | 3 +- static/spoopy.less | 74 +++++++++++++++++++++++++++++------------- templates/game.html | 1 + templates/main.html | 50 ++++++++++++++++++++++------ templates/profile.html | 6 ++++ webserver.py | 21 ++++++++++-- 7 files changed, 141 insertions(+), 56 deletions(-) diff --git a/db.py b/db.py index dc74a650..bccbd204 100644 --- a/db.py +++ b/db.py @@ -904,31 +904,31 @@ class Halloween(Base): def pieces_completed(self) -> int: count = 0 - if puzzle_piece_a is not None: + if self.puzzle_piece_a is not None: count += 1 - if puzzle_piece_b is not None: + if self.puzzle_piece_b is not None: count += 1 - if puzzle_piece_c is not None: + if self.puzzle_piece_c is not None: count += 1 - if puzzle_piece_d is not None: + if self.puzzle_piece_d is not None: count += 1 - if puzzle_piece_e is not None: + if self.puzzle_piece_e is not None: count += 1 - if puzzle_piece_f is not None: + if self.puzzle_piece_f is not None: count += 1 - if puzzle_piece_g is not None: + if self.puzzle_piece_g is not None: count += 1 - if puzzle_piece_h is not None: + if self.puzzle_piece_h is not None: count += 1 - if puzzle_piece_i is not None: + if self.puzzle_piece_i is not None: count += 1 - if puzzle_piece_j is not None: + if self.puzzle_piece_j is not None: count += 1 return count @staticmethod def puzzle_is_complete() -> bool: - session = db.Session() + session = Session() halloweens = session.query(Halloween).all() session.close() completed_a = False @@ -969,7 +969,7 @@ class Halloween(Base): @staticmethod def puzzle_piece_a_complete() -> bool: - session = db.Session() + session = Session() halloweens = session.query(Halloween).all() session.close() for halloween in halloweens: @@ -979,7 +979,7 @@ class Halloween(Base): @staticmethod def puzzle_piece_b_complete() -> bool: - session = db.Session() + session = Session() halloweens = session.query(Halloween).all() session.close() for halloween in halloweens: @@ -989,7 +989,7 @@ class Halloween(Base): @staticmethod def puzzle_piece_c_complete() -> bool: - session = db.Session() + session = Session() halloweens = session.query(Halloween).all() session.close() for halloween in halloweens: @@ -1000,7 +1000,7 @@ class Halloween(Base): @staticmethod def puzzle_piece_d_complete() -> bool: - session = db.Session() + session = Session() halloweens = session.query(Halloween).all() session.close() for halloween in halloweens: @@ -1010,7 +1010,7 @@ class Halloween(Base): @staticmethod def puzzle_piece_e_complete() -> bool: - session = db.Session() + session = Session() halloweens = session.query(Halloween).all() session.close() for halloween in halloweens: @@ -1020,7 +1020,7 @@ class Halloween(Base): @staticmethod def puzzle_piece_f_complete() -> bool: - session = db.Session() + session = Session() halloweens = session.query(Halloween).all() session.close() for halloween in halloweens: @@ -1030,7 +1030,7 @@ class Halloween(Base): @staticmethod def puzzle_piece_g_complete() -> bool: - session = db.Session() + session = Session() halloweens = session.query(Halloween).all() session.close() for halloween in halloweens: @@ -1040,7 +1040,7 @@ class Halloween(Base): @staticmethod def puzzle_piece_h_complete() -> bool: - session = db.Session() + session = Session() halloweens = session.query(Halloween).all() session.close() for halloween in halloweens: @@ -1050,7 +1050,7 @@ class Halloween(Base): @staticmethod def puzzle_piece_i_complete() -> bool: - session = db.Session() + session = Session() halloweens = session.query(Halloween).all() session.close() for halloween in halloweens: @@ -1060,7 +1060,7 @@ class Halloween(Base): @staticmethod def puzzle_piece_j_complete() -> bool: - session = db.Session() + session = Session() halloweens = session.query(Halloween).all() session.close() for halloween in halloweens: diff --git a/discordbot.py b/discordbot.py index bac1460f..b87dc9a7 100644 --- a/discordbot.py +++ b/discordbot.py @@ -265,6 +265,7 @@ class RoyalDiscordBot(discord.Client): "!skip": self.cmd_skip, "!s": self.cmd_skip, "!remove": self.cmd_remove, + "!r": self.cmd_remove, "!cancel": self.cmd_remove, "!queue": self.cmd_queue, "!q": self.cmd_queue, @@ -494,7 +495,7 @@ class RoyalDiscordBot(discord.Client): while True: # Fun things will happen with multiple 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 if len(self.video_queue) == 0: self.now_playing = None diff --git a/static/spoopy.less b/static/spoopy.less index f8a3bd7c..655a271b 100644 --- a/static/spoopy.less +++ b/static/spoopy.less @@ -749,6 +749,21 @@ table { grid-column: 3; } } + + .halloweenmini { + background-color: #311515; + padding: 18px; + grid-template-columns: 100%; + + .stars { + grid-column: 1; + + i { + color: yellow; + font-size: 30px; + } + } + } } .wiki { @@ -814,6 +829,11 @@ ntry { .right { grid-column: 2; } + + .halloween { + grid-column-start: 1; + grid-column-end: 3; + } } @media (max-width:600px) { @@ -828,6 +848,38 @@ ntry { .right { 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 { color: red; font-weight: bold; diff --git a/templates/game.html b/templates/game.html index ce64767f..35aeb415 100644 --- a/templates/game.html +++ b/templates/game.html @@ -2,6 +2,7 @@ {% block prehead %} + {% endblock %} {% block pagetitle %} diff --git a/templates/main.html b/templates/main.html index e49829b6..49a053f3 100644 --- a/templates/main.html +++ b/templates/main.html @@ -4,19 +4,22 @@ Pagina principale {% endblock %} +{% block prehead %} + +{% endblock %} + {% block posthead %} {% endblock %} @@ -25,6 +28,32 @@ Royal Games
+ {% if config["DEBUG"] %} +
+
+
+ Rituale di Halloween! +
+
+ Lune raccolte: +
+ {% for index, star in halloween %} + {% if star %} + + {% else %} + + {% endif %} + {% endfor %} +
+
+ Tempo rimanente: +
+ Loading... +
+
+
+
+ {% endif %}
@@ -76,6 +105,7 @@
  • League of Legends
  • Overwatch
  • osu!
  • +
    diff --git a/templates/profile.html b/templates/profile.html index 89a926ac..ffd65c20 100644 --- a/templates/profile.html +++ b/templates/profile.html @@ -2,6 +2,7 @@ {% block prehead %} + {% endblock %} {% block pagetitle %} @@ -37,6 +38,11 @@ {% with record = ryg %} {% include "minis/ryg.html" %} {% endwith %} + {% if halloween %} + {% with record = halloween %} + {% include "minis/halloween.html" %} + {% endwith %} + {% endif %} {% if tg %} {% with record = tg %} {% include "minis/tg.html" %} diff --git a/webserver.py b/webserver.py index 61cc1fdc..2aa9274c 100644 --- a/webserver.py +++ b/webserver.py @@ -66,9 +66,21 @@ 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() + ] 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) + next_events=next_events, rygconf=config, escape=escape, halloween=enumerate(halloween)) @app.route("/profile/") @@ -89,6 +101,7 @@ def page_profile(name: str): 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() 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() if css is not None: converted_bio = Markup(markdown2.markdown(css.bio.replace("<", "<"), @@ -96,7 +109,8 @@ def page_profile(name: str): else: converted_bio = "" 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") @@ -231,6 +245,9 @@ def page_game(name: str): elif name == "discord": game_name = "Discord" 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: abort(404) return