From c15f500058c290211aca84c7a8a45bd8e5903a0a Mon Sep 17 00:00:00 2001 From: joe Date: Mon, 4 Jan 2021 23:38:53 -0800 Subject: [PATCH] Final tweaks --- the_draft.py | 10 +++------- the_prestige.py | 43 ++++++++++++++++++++++++++++++++++--------- 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/the_draft.py b/the_draft.py index 8795a1b..cfb4cbc 100644 --- a/the_draft.py +++ b/the_draft.py @@ -96,7 +96,7 @@ class Draft: if not player: # might be some whitespace shenanigans for name, stats in self._players.items(): - if name.replace('\xa0', ' ').strip() == player_name: + if name.replace('\xa0', ' ').strip().lower() == player_name.lower(): player = stats break else: @@ -124,7 +124,7 @@ class Draft: teams.append((self._active_participant.handle, self._active_participant.team)) for participant in self._participants: if participant != BOOKMARK: - teams.append((self._active_participant.handle, self._active_participant.team)) + teams.append((participant.handle, participant.team)) return teams def finish_draft(self): @@ -136,7 +136,7 @@ class Draft: if __name__ == '__main__': # extremely robust testing OC do not steal - DRAFT_ROUNDS = 3 + DRAFT_ROUNDS = 2 draft = Draft.make_draft() draft.add_participant('@bluh', 'Bluhstein Bluhs', 'bluh bluh bluh') draft.add_participant('@what', 'Barcelona IDK', 'huh') @@ -151,7 +151,3 @@ if __name__ == '__main__': except ValueError as e: print(e) print(draft.get_teams()) - print(draft.get_teams()['@bluh'].lineup) - print(draft.get_teams()['@bluh'].pitcher) - print(draft.get_teams()['@what'].lineup) - print(draft.get_teams()['@what'].pitcher) diff --git a/the_prestige.py b/the_prestige.py index 3a57660..c17c26a 100644 --- a/the_prestige.py +++ b/the_prestige.py @@ -634,31 +634,56 @@ class StartDraftCommand(Command): return draft.start_draft() + footer = f"The draft class of {random.randint(2007, 2075)}" while draft.round <= DRAFT_ROUNDS: - choosing = 'โšพ๏ธpitcherโšพ๏ธ' if draft.round == DRAFT_ROUNDS else '๐Ÿhitter๐Ÿ' + message_prefix = f'Round {draft.round}/{DRAFT_ROUNDS}:' + if draft.round == DRAFT_ROUNDS: + body = random.choice([ + f"Now just choose a pitcher and we can finish off this paperwork for you, {draft.active_drafter}", + f"Pick a pitcher, {draft.active_drafter}, and we can all go home happy. 'Cept your players. They'll have to play bllaseball.", + f"Almost done, {draft.active_drafter}. Pick your pitcher.", + ]) + message = f"โšพ๏ธ {message_prefix} {body}" + else: + body = random.choice([ + f"Choose a batter, {draft.active_drafter}", + f"{draft.active_drafter}, your turn. Pick one.", + f"Pick one to fill your next lineup slot, {draft.active_drafter}", + f"Alright, {draft.active_drafter}, choose a batter.", + ]) + message = f"๐Ÿ {message_prefix} {body}" await msg.channel.send( - f'Round {draft.round}/{DRAFT_ROUNDS}: {draft.active_drafter}, choose a {choosing} for {draft.active_drafting_team}.', - embed=build_draft_embed(draft.get_draftees(), footer=f"{choosing[0]}You must choose"), + message, + embed=build_draft_embed(draft.get_draftees(), footer=footer), ) try: draft_message = await self.wait_draft(msg.channel, draft) draft.draft_player(f'<@!{draft_message.author.id}>', draft_message.content.split(' ', 1)[1]) except SlowDraftError: player = random.choice(draft.get_draftees()) - await msg.channel.send(f"I'm not waiting forever. You get {player}. Next") + await msg.channel.send(f"I'm not waiting forever. You get {player}. Next.") draft.draft_player(draft.active_drafter, player) except ValueError as e: await msg.channel.send(str(e)) + except IndexError: + await msg.channel.send("Quit the funny business.") for handle, team in draft.get_teams(): - await msg.channel.send(f'{handle} behold your team', embed=build_team_embed(team)) + await msg.channel.send( + random.choice([ + f"Done and dusted, {handle}. Here's your squad.", + f"Behold the {team.name}, {handle}. Flawless, we think.", + f"Oh, huh. Interesting stat distribution. Good luck, {handle}.", + ]), + embed=build_team_embed(team), + ) try: draft.finish_draft() except Exception as e: await msg.channel.send(str(e)) async def wait_start(self, channel, mentions): - start_msg = await channel.send('Are we good to go? ' + ' '.join(mentions)) + start_msg = await channel.send("Sound off, folks. ๐Ÿ‘ if you're good to go " + " ".join(mentions)) await start_msg.add_reaction("๐Ÿ‘") await start_msg.add_reaction("๐Ÿ‘Ž") @@ -669,7 +694,7 @@ class StartDraftCommand(Command): try: react, _ = await client.wait_for('reaction_add', timeout=60.0, check=react_check) if react.emoji == "๐Ÿ‘Ž": - await channel.send("Got it, stopping the draft") + await channel.send("We dragged out the photocopier for this! Fine, putting it back.") return False if react.emoji == "๐Ÿ‘": reactors = set() @@ -687,10 +712,10 @@ class StartDraftCommand(Command): def check(m): if m.channel != channel: return False - if m.content.startswith('d') or m.content.startswith('draft'): + if m.content.startswith('d ') or m.content.startswith('draft '): return True for prefix in config()['prefix']: - if m.content.startswith(prefix + 'draft'): + if m.content.startswith(prefix + 'draft '): return True return False