really fixed #191.
closes #190, -w or --weather flag on startgame can set weather
This commit is contained in:
parent
bc7f178462
commit
28e4e68c5a
|
@ -145,6 +145,12 @@ class StartGameCommand(Command):
|
||||||
await msg.channel.send("Make sure you put an integer after the -d flag.")
|
await msg.channel.send("Make sure you put an integer after the -d flag.")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
weather_name = None
|
||||||
|
if "-w " in command.split("\n")[0]:
|
||||||
|
weather_name = command.split("\n")[0].split("-w ")[1].split("-")[0].strip()
|
||||||
|
elif "--weather " in command.split("\n")[0]:
|
||||||
|
weather_name = command.split("\n")[0].split("--weather ")[1].split("-")[0].strip()
|
||||||
|
|
||||||
innings = None
|
innings = None
|
||||||
try:
|
try:
|
||||||
team_name1 = command.split("\n")[1].strip()
|
team_name1 = command.split("\n")[1].strip()
|
||||||
|
@ -183,6 +189,10 @@ class StartGameCommand(Command):
|
||||||
game.teams['home'].set_pitcher(rotation_slot = day)
|
game.teams['home'].set_pitcher(rotation_slot = day)
|
||||||
channel = msg.channel
|
channel = msg.channel
|
||||||
|
|
||||||
|
if weather_name is not None and weather_name in games.all_weathers().keys():
|
||||||
|
game.weather = games.all_weathers()[weather_name]
|
||||||
|
|
||||||
|
|
||||||
game_task = asyncio.create_task(watch_game(channel, game, user=msg.author, league=league))
|
game_task = asyncio.create_task(watch_game(channel, game, user=msg.author, league=league))
|
||||||
await game_task
|
await game_task
|
||||||
else:
|
else:
|
||||||
|
@ -1158,13 +1168,14 @@ commands = [
|
||||||
DraftPlayerCommand()
|
DraftPlayerCommand()
|
||||||
]
|
]
|
||||||
|
|
||||||
|
watching = False
|
||||||
client = discord.Client()
|
client = discord.Client()
|
||||||
gamesarray = []
|
gamesarray = []
|
||||||
active_tournaments = []
|
active_tournaments = []
|
||||||
active_leagues = []
|
active_leagues = []
|
||||||
active_standings = {}
|
active_standings = {}
|
||||||
setupmessages = {}
|
setupmessages = {}
|
||||||
watching = False
|
|
||||||
|
|
||||||
thread1 = threading.Thread(target=main_controller.update_loop)
|
thread1 = threading.Thread(target=main_controller.update_loop)
|
||||||
thread1.start()
|
thread1.start()
|
||||||
|
@ -1194,6 +1205,7 @@ def config():
|
||||||
|
|
||||||
@client.event
|
@client.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
|
global watching
|
||||||
db.initialcheck()
|
db.initialcheck()
|
||||||
print(f"logged in as {client.user} with token {config()['token']} to {len(client.guilds)} servers")
|
print(f"logged in as {client.user} with token {config()['token']} to {len(client.guilds)} servers")
|
||||||
if not watching:
|
if not watching:
|
||||||
|
@ -1396,7 +1408,7 @@ async def watch_game(channel, newgame, user = None, league = None):
|
||||||
main_controller.master_games_dic[id] = (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 and newgame.weather.name == "Sunny": #if no weather name supplied and the game's weather is default, pick random weather
|
||||||
weathers = games.all_weathers()
|
weathers = games.all_weathers()
|
||||||
newgame.weather = weathers[random.choice(list(weathers.keys()))]
|
newgame.weather = weathers[random.choice(list(weathers.keys()))]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue