Final tweaks
This commit is contained in:
parent
c65d81a5e6
commit
c15f500058
10
the_draft.py
10
the_draft.py
|
@ -96,7 +96,7 @@ class Draft:
|
||||||
if not player:
|
if not player:
|
||||||
# might be some whitespace shenanigans
|
# might be some whitespace shenanigans
|
||||||
for name, stats in self._players.items():
|
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
|
player = stats
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
@ -124,7 +124,7 @@ class Draft:
|
||||||
teams.append((self._active_participant.handle, self._active_participant.team))
|
teams.append((self._active_participant.handle, self._active_participant.team))
|
||||||
for participant in self._participants:
|
for participant in self._participants:
|
||||||
if participant != BOOKMARK:
|
if participant != BOOKMARK:
|
||||||
teams.append((self._active_participant.handle, self._active_participant.team))
|
teams.append((participant.handle, participant.team))
|
||||||
return teams
|
return teams
|
||||||
|
|
||||||
def finish_draft(self):
|
def finish_draft(self):
|
||||||
|
@ -136,7 +136,7 @@ class Draft:
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# extremely robust testing OC do not steal
|
# extremely robust testing OC do not steal
|
||||||
DRAFT_ROUNDS = 3
|
DRAFT_ROUNDS = 2
|
||||||
draft = Draft.make_draft()
|
draft = Draft.make_draft()
|
||||||
draft.add_participant('@bluh', 'Bluhstein Bluhs', 'bluh bluh bluh')
|
draft.add_participant('@bluh', 'Bluhstein Bluhs', 'bluh bluh bluh')
|
||||||
draft.add_participant('@what', 'Barcelona IDK', 'huh')
|
draft.add_participant('@what', 'Barcelona IDK', 'huh')
|
||||||
|
@ -151,7 +151,3 @@ if __name__ == '__main__':
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
print(e)
|
print(e)
|
||||||
print(draft.get_teams())
|
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)
|
|
||||||
|
|
|
@ -634,31 +634,56 @@ class StartDraftCommand(Command):
|
||||||
return
|
return
|
||||||
|
|
||||||
draft.start_draft()
|
draft.start_draft()
|
||||||
|
footer = f"The draft class of {random.randint(2007, 2075)}"
|
||||||
while draft.round <= DRAFT_ROUNDS:
|
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(
|
await msg.channel.send(
|
||||||
f'Round {draft.round}/{DRAFT_ROUNDS}: {draft.active_drafter}, choose a {choosing} for {draft.active_drafting_team}.',
|
message,
|
||||||
embed=build_draft_embed(draft.get_draftees(), footer=f"{choosing[0]}You must choose"),
|
embed=build_draft_embed(draft.get_draftees(), footer=footer),
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
draft_message = await self.wait_draft(msg.channel, draft)
|
draft_message = await self.wait_draft(msg.channel, draft)
|
||||||
draft.draft_player(f'<@!{draft_message.author.id}>', draft_message.content.split(' ', 1)[1])
|
draft.draft_player(f'<@!{draft_message.author.id}>', draft_message.content.split(' ', 1)[1])
|
||||||
except SlowDraftError:
|
except SlowDraftError:
|
||||||
player = random.choice(draft.get_draftees())
|
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)
|
draft.draft_player(draft.active_drafter, player)
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
await msg.channel.send(str(e))
|
await msg.channel.send(str(e))
|
||||||
|
except IndexError:
|
||||||
|
await msg.channel.send("Quit the funny business.")
|
||||||
|
|
||||||
for handle, team in draft.get_teams():
|
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:
|
try:
|
||||||
draft.finish_draft()
|
draft.finish_draft()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
await msg.channel.send(str(e))
|
await msg.channel.send(str(e))
|
||||||
|
|
||||||
async def wait_start(self, channel, mentions):
|
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("👍")
|
||||||
await start_msg.add_reaction("👎")
|
await start_msg.add_reaction("👎")
|
||||||
|
|
||||||
|
@ -669,7 +694,7 @@ class StartDraftCommand(Command):
|
||||||
try:
|
try:
|
||||||
react, _ = await client.wait_for('reaction_add', timeout=60.0, check=react_check)
|
react, _ = await client.wait_for('reaction_add', timeout=60.0, check=react_check)
|
||||||
if react.emoji == "👎":
|
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
|
return False
|
||||||
if react.emoji == "👍":
|
if react.emoji == "👍":
|
||||||
reactors = set()
|
reactors = set()
|
||||||
|
@ -687,10 +712,10 @@ class StartDraftCommand(Command):
|
||||||
def check(m):
|
def check(m):
|
||||||
if m.channel != channel:
|
if m.channel != channel:
|
||||||
return False
|
return False
|
||||||
if m.content.startswith('d') or m.content.startswith('draft'):
|
if m.content.startswith('d ') or m.content.startswith('draft '):
|
||||||
return True
|
return True
|
||||||
for prefix in config()['prefix']:
|
for prefix in config()['prefix']:
|
||||||
if m.content.startswith(prefix + 'draft'):
|
if m.content.startswith(prefix + 'draft '):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user