changed timestamp to uuid strings, adjusted variable names in the_prestige and main_controller
This commit is contained in:
parent
8d01a3cc79
commit
803f633a9e
|
@ -31,9 +31,9 @@ def handle_new_conn(data):
|
||||||
def update_loop():
|
def update_loop():
|
||||||
while True:
|
while True:
|
||||||
game_states = {}
|
game_states = {}
|
||||||
game_times = iter(master_games_dic.copy().keys())
|
game_ids = iter(master_games_dic.copy().keys())
|
||||||
for game_time in game_times:
|
for game_id in game_ids:
|
||||||
this_game, state, discrim_string = master_games_dic[game_time]
|
this_game, state, discrim_string = master_games_dic[game_id]
|
||||||
test_string = this_game.gamestate_display_full()
|
test_string = this_game.gamestate_display_full()
|
||||||
state["leagueoruser"] = discrim_string
|
state["leagueoruser"] = discrim_string
|
||||||
state["display_inning"] = this_game.inning #games need to be initialized with the following keys in state:
|
state["display_inning"] = this_game.inning #games need to be initialized with the following keys in state:
|
||||||
|
@ -125,16 +125,16 @@ def update_loop():
|
||||||
|
|
||||||
state["top_of_inning"] = this_game.top_of_inning
|
state["top_of_inning"] = this_game.top_of_inning
|
||||||
|
|
||||||
game_states[game_time] = state
|
game_states[game_id] = state
|
||||||
|
|
||||||
if state["update_pause"] <= 1 and state["start_delay"] < 0:
|
if state["update_pause"] <= 1 and state["start_delay"] < 0:
|
||||||
if this_game.over:
|
if this_game.over:
|
||||||
state["update_pause"] = 2
|
state["update_pause"] = 2
|
||||||
if state["end_delay"] < 0:
|
if state["end_delay"] < 0:
|
||||||
master_games_dic.pop(game_time)
|
master_games_dic.pop(game_id)
|
||||||
else:
|
else:
|
||||||
state["end_delay"] -= 1
|
state["end_delay"] -= 1
|
||||||
master_games_dic[game_time][1]["end_delay"] -= 1
|
master_games_dic[game_id][1]["end_delay"] -= 1
|
||||||
else:
|
else:
|
||||||
this_game.gamestate_update_full()
|
this_game.gamestate_update_full()
|
||||||
|
|
||||||
|
@ -144,12 +144,12 @@ def update_loop():
|
||||||
data_to_send = []
|
data_to_send = []
|
||||||
template = jinja2.Environment(loader=jinja2.FileSystemLoader('templates')).get_template('game_box.html')
|
template = jinja2.Environment(loader=jinja2.FileSystemLoader('templates')).get_template('game_box.html')
|
||||||
|
|
||||||
for timestamp in game_states:
|
for id in game_states:
|
||||||
data_to_send.append({
|
data_to_send.append({
|
||||||
'timestamp' : timestamp,
|
'timestamp' : id,
|
||||||
'league' : game_states[timestamp]['leagueoruser'] if game_states[timestamp]['is_league'] else '',
|
'league' : game_states[id]['leagueoruser'] if game_states[id]['is_league'] else '',
|
||||||
'state' : game_states[timestamp],
|
'state' : game_states[id],
|
||||||
'html' : template.render(state=game_states[timestamp], timestamp=timestamp)
|
'html' : template.render(state=game_states[id], timestamp=id)
|
||||||
})
|
})
|
||||||
|
|
||||||
socketio.emit("states_update", data_to_send)
|
socketio.emit("states_update", data_to_send)
|
||||||
|
|
|
@ -2,6 +2,7 @@ import discord, json, math, os, roman, games, asyncio, random, main_controller,
|
||||||
import database as db
|
import database as db
|
||||||
import onomancer as ono
|
import onomancer as ono
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
|
from uuid import uuid4
|
||||||
|
|
||||||
|
|
||||||
class Command:
|
class Command:
|
||||||
|
@ -779,15 +780,15 @@ async def watch_game(channel, newgame, user = None, league = None):
|
||||||
state_init["is_league"] = False
|
state_init["is_league"] = False
|
||||||
|
|
||||||
|
|
||||||
timestamp = str(time.time() * 1000.0)
|
id = str(uuid4())
|
||||||
ext = "?game="+timestamp
|
ext = "?game="+id
|
||||||
if league is not None:
|
if league is not None:
|
||||||
ext += "&league=" + urllib.parse.quote_plus(league)
|
ext += "&league=" + urllib.parse.quote_plus(league)
|
||||||
|
|
||||||
await channel.send(f"{newgame.teams['away'].name} vs. {newgame.teams['home'].name}, starting at {config()['simmadome_url']+ext}")
|
await channel.send(f"{newgame.teams['away'].name} vs. {newgame.teams['home'].name}, starting at {config()['simmadome_url']+ext}")
|
||||||
gamesarray.append((newgame, channel, user, timestamp))
|
gamesarray.append((newgame, channel, user, id))
|
||||||
|
|
||||||
main_controller.master_games_dic[timestamp] = (newgame, state_init, discrim_string)
|
main_controller.master_games_dic[id] = (newgame, state_init, discrim_string)
|
||||||
|
|
||||||
def prepare_game(newgame, league = None, weather_name = None):
|
def prepare_game(newgame, league = None, weather_name = None):
|
||||||
if weather_name is None:
|
if weather_name is None:
|
||||||
|
@ -834,9 +835,9 @@ async def start_tournament_round(channel, tourney, seeding = None):
|
||||||
state_init["title"] = f"0 - 0"
|
state_init["title"] = f"0 - 0"
|
||||||
discrim_string = tourney.name
|
discrim_string = tourney.name
|
||||||
|
|
||||||
timestamp = str(time.time() * 1000.0 + random.randint(0,3000))
|
id = str(uuid4())
|
||||||
current_games.append((this_game, timestamp))
|
current_games.append((this_game, id))
|
||||||
main_controller.master_games_dic[timestamp] = (this_game, state_init, discrim_string)
|
main_controller.master_games_dic[id] = (this_game, state_init, discrim_string)
|
||||||
|
|
||||||
ext = "?league=" + urllib.parse.quote_plus(tourney.name)
|
ext = "?league=" + urllib.parse.quote_plus(tourney.name)
|
||||||
|
|
||||||
|
@ -862,9 +863,9 @@ async def continue_tournament_series(tourney, queue, games_list, wins_in_series)
|
||||||
|
|
||||||
discrim_string = tourney.name
|
discrim_string = tourney.name
|
||||||
|
|
||||||
timestamp = str(time.time() * 1000.0 + random.randint(0,3000))
|
id = str(uuid4())
|
||||||
games_list.append((this_game, timestamp))
|
games_list.append((this_game, id))
|
||||||
main_controller.master_games_dic[timestamp] = (this_game, state_init, discrim_string)
|
main_controller.master_games_dic[id] = (this_game, state_init, discrim_string)
|
||||||
|
|
||||||
return games_list
|
return games_list
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user