random games (also bugfix for same)

This commit is contained in:
Sakimori 2022-09-18 11:27:36 -04:00
parent dcbc934f86
commit d6011a69d7
2 changed files with 20 additions and 15 deletions

View file

@ -235,7 +235,7 @@ class game(object):
self.over = False self.over = False
self.random_weather_flag = False self.random_weather_flag = False
self.teams = {"away" : team1, "home" : team2} self.teams = {"away" : team1, "home" : team2}
self.archetypes = {team1.name : team1.archetypes, team2.name : team2.archetypes}
self.offense_archetypes = {} self.offense_archetypes = {}
self.defense_archetypes = {} self.defense_archetypes = {}
self.inning = 1 self.inning = 1
@ -254,10 +254,14 @@ class game(object):
self.voice = None self.voice = None
self.current_batter = None self.current_batter = None
for this_team in [team1, team2]: try:
for this_player in this_team.lineup + this_team.rotation: self.archetypes = {team1.name : team1.archetypes, team2.name : team2.archetypes}
if this_player.name in this_team.archetypes.keys(): for this_team in [team1, team2]:
this_team.archetypes[this_player.name].modify_player_stats(this_player) for this_player in this_team.lineup + this_team.rotation:
if this_player.name in this_team.archetypes.keys():
this_team.archetypes[this_player.name].modify_player_stats(this_player)
except:
pass
def occupied_bases(self): def occupied_bases(self):
occ_dic = {} occ_dic = {}

View file

@ -178,21 +178,22 @@ async def startgame(interaction, away: str, home: str, innings: Optional[int]=9,
class StartRandomGameCommand(Command): class StartRandomGameCommand(Command):
name = "randomgame" name = "randomgame"
template = "m;randomgame" template = "randomgame"
description = "Starts a 9-inning game between 2 entirely random teams. Embrace chaos!" description = "Starts a 9-inning game between 2 entirely random teams. Embrace chaos!"
async def execute(self, msg, command, flags): @client.tree.command()
if config()["game_freeze"]: async def randomgame(interaction):
raise CommandError("Patch incoming. We're not allowing new games right now.") if config()["game_freeze"]:
raise CommandError("Patch incoming. We're not allowing new games right now.")
channel = msg.channel channel = interaction.channel
await channel.send("Rolling the bones... This might take a while.") await interaction.response.send_message("Rolling the bones... This might take a while.")
teamslist = games.get_all_teams() teamslist = games.get_all_teams()
game = games.game(random.choice(teamslist).finalize(), random.choice(teamslist).finalize()) game = games.game(random.choice(teamslist).finalize(), random.choice(teamslist).finalize())
game_task = asyncio.create_task(watch_game(channel, game, user="the winds of chaos")) game_task = asyncio.create_task(watch_game(channel, game, user="the winds of chaos"))
await game_task await game_task
class SetupGameCommand(Command): class SetupGameCommand(Command):
name = "setupgame" name = "setupgame"