added weather selection box
This commit is contained in:
parent
393094a63c
commit
4685f4aea8
|
@ -109,10 +109,11 @@ class StartGameCommand(Command):
|
|||
- this command has fuzzy search so you don't need to type the full name of the team as long as you give enough to identify the team you're looking for."""
|
||||
|
||||
@client.tree.command()
|
||||
async def startgame(interaction, away: str, home: str, innings: Optional[int]=9, flags: Optional[str] = ""):
|
||||
@app_commands.rename(wthr="weather")
|
||||
@app_commands.choices(wthr=weather.weather_choices())
|
||||
async def startgame(interaction, away: str, home: str, innings: Optional[int]=9, wthr: Optional[app_commands.Choice[str]] = None, flags: Optional[str] = ""):
|
||||
league = None
|
||||
day = None
|
||||
weather_name = None
|
||||
innings = None
|
||||
voice = None
|
||||
|
||||
|
@ -128,10 +129,6 @@ async def startgame(interaction, away: str, home: str, innings: Optional[int]=9,
|
|||
day = int(flag[1])
|
||||
except:
|
||||
raise CommandError("Make sure you put an integer after the -d flag.")
|
||||
elif flag[0] == "w":
|
||||
weather_name = flag[1]
|
||||
if weather_name not in weather.all_weathers():
|
||||
raise CommandError("We can't find that weather, chief. Try again.")
|
||||
elif flag[0] == "v" or flag[0] == "a":
|
||||
if flag[1] in gametext.all_voices():
|
||||
voice = gametext.all_voices()[flag[1]]
|
||||
|
@ -168,8 +165,8 @@ async def startgame(interaction, away: str, home: str, innings: Optional[int]=9,
|
|||
game.voice = voice()
|
||||
channel = interaction.channel
|
||||
|
||||
if weather_name is not None:
|
||||
game.weather = weather.all_weathers()[weather_name](game)
|
||||
if wthr is not None:
|
||||
game.weather = weather.all_weathers()[wthr.value](game)
|
||||
|
||||
game_task = asyncio.create_task(watch_game(channel, game, user=interaction.user, league=league, interaction=interaction))
|
||||
await game_task
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import random, math, roman
|
||||
from gametext import appearance_outcomes, game_strings_base, base_string
|
||||
from discord.app_commands import Choice
|
||||
|
||||
class Weather:
|
||||
name = "Sunny"
|
||||
|
@ -636,6 +637,12 @@ def all_weathers():
|
|||
}
|
||||
return weathers_dic
|
||||
|
||||
def weather_choices():
|
||||
lst = []
|
||||
for key, value in list(all_weathers().items()):
|
||||
lst.append(Choice(name=key, value=key))
|
||||
return lst
|
||||
|
||||
def safe_weathers():
|
||||
"""weathers safe to swap in mid-game"""
|
||||
weathers_dic = {
|
||||
|
|
Loading…
Reference in a new issue