From debffec9b0f9302107e370cb1aa6effbe0d0cfd9 Mon Sep 17 00:00:00 2001 From: Sakimori Date: Thu, 31 Dec 2020 13:41:32 -0500 Subject: [PATCH] first attempt at adding league or user info to the game display --- main_controller.py | 6 ++++-- static/game.html | 1 + static/games_page.css | 14 ++++++++++++++ static/loader.js | 2 ++ templates/index.html | 4 ++-- the-prestige.pyproj | 1 + the_prestige.py | 11 +++++++++-- 7 files changed, 33 insertions(+), 6 deletions(-) diff --git a/main_controller.py b/main_controller.py index 095d7be..51612e2 100644 --- a/main_controller.py +++ b/main_controller.py @@ -30,9 +30,10 @@ def update_loop(): states_to_send = {} game_times = iter(master_games_dic.copy().keys()) for game_time in game_times: - this_game, state = master_games_dic[game_time] + this_game, state, discrim_string = master_games_dic[game_time] test_string = this_game.gamestate_display_full() - + print(discrim_string) + state["leagueoruser"] = discrim_string state["display_inning"] = this_game.inning #games need to be initialized with the following keys in state: state["outs"] = this_game.outs #away_name state["pitcher"] = this_game.get_pitcher().name #home_name @@ -123,5 +124,6 @@ def update_loop(): global last_update last_update = states_to_send + socketio.emit("states_update", states_to_send) time.sleep(6) diff --git a/static/game.html b/static/game.html index 1e1dc91..633fa17 100644 --- a/static/game.html +++ b/static/game.html @@ -46,4 +46,5 @@ \ No newline at end of file diff --git a/static/games_page.css b/static/games_page.css index c13017f..88a9030 100644 --- a/static/games_page.css +++ b/static/games_page.css @@ -190,6 +190,18 @@ h2 { padding: 5px; } +.leagueoruser { + font-size: 10pt; + text-align: right; + height: max-content; + padding: 5px; +} + +.footer { + display: flex; + justify-content: space-between; +} + .outs { display: flex; justify-content: space-between; @@ -250,6 +262,8 @@ h2 { margin-top: 10px; } + + .update_emoji, .update_text { display: inline } diff --git a/static/loader.js b/static/loader.js index 2d7f93b..7ca2d83 100644 --- a/static/loader.js +++ b/static/loader.js @@ -103,6 +103,8 @@ $(document).ready(function (){ $('#updateTarget .update_text').html(gamestate.update_text); $('#updateTarget .batting').html((gamestate.display_top_of_inning ? gamestate.away_name : gamestate.home_name) + " batting."); + console.log(gamestate.leagueoruser) + $('#updateTarget .leagueoruser').html(gamestate.leagueoruser); gamediv.id = ""; }; diff --git a/templates/index.html b/templates/index.html index 117828e..6cfbb63 100644 --- a/templates/index.html +++ b/templates/index.html @@ -7,8 +7,8 @@ ⚾ The Simmadome - - + + diff --git a/the-prestige.pyproj b/the-prestige.pyproj index 2b928ed..9567763 100644 --- a/the-prestige.pyproj +++ b/the-prestige.pyproj @@ -58,6 +58,7 @@ + diff --git a/the_prestige.py b/the_prestige.py index 9bd3302..819bcbf 100644 --- a/the_prestige.py +++ b/the_prestige.py @@ -549,7 +549,7 @@ Creator, type `{newgame.name} done` to finalize lineups.""") game_task = asyncio.create_task(watch_game(channel, newgame)) await game_task -async def watch_game(channel, newgame, user = None): +async def watch_game(channel, newgame, user = None, league = None): blank_emoji = discord.utils.get(client.emojis, id = 790899850295509053) empty_base = discord.utils.get(client.emojis, id = 790899850395779074) occupied_base = discord.utils.get(client.emojis, id = 790899850320543745) @@ -574,10 +574,17 @@ async def watch_game(channel, newgame, user = None): "end_delay" : 3 } + if league is not None: + discrim_string = league + elif user is not None: + discrim_string = f"Started by {user.name}" + else: + discrim_string = "Unclaimed game." + await channel.send(f"{newgame.teams['away'].name} vs. {newgame.teams['home'].name}, starting at {config()['simmadome_url']}") gamesarray.append((newgame, channel, user)) - main_controller.master_games_dic[str(time.time() * 1000.0)] = (newgame, state_init) + main_controller.master_games_dic[str(time.time() * 1000.0)] = (newgame, state_init, discrim_string) async def play_from_queue(channel, game, user_mention): await channel.send(f"{user_mention}, your game's ready.")