Skip to content

Commit

Permalink
🚸 Use appropriate completions when ending combat
Browse files Browse the repository at this point in the history
Using the prompt session to prompt for how to dispose of leftover
monsters at the end of combat meant we were getting the primary command
completion which was inappropriate for the situation, so switched it to
use a situationally-appropriate WordCompleter instead.

Again sort of addresses #29.
  • Loading branch information
mpirnat committed Jun 29, 2019
1 parent 59294ca commit 8d1dd5f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion dndme/commands/end_combat.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import math
from prompt_toolkit.completion import WordCompleter
from dndme.commands import Command
from dndme.commands.remove_combatant import RemoveCombatant
from dndme.commands.show import Show
Expand Down Expand Up @@ -29,10 +30,12 @@ def do_command(self, *args):

# Allow some leftover monsters to remain in the combat group;
# perhaps some are friendly NPCs along for the ride?
choices = WordCompleter(['keep', 'remove', 'stash'])
for monster in list(combat.monsters.values()):
choice = self.session.prompt(
f"What should we do with {monster.name}? "
"[R]emove [S]tash [K]eep (default: Keep) "
"[R]emove [S]tash [K]eep (default: Keep) ",
completer=choices
).lower()
if choice in ('r', 'remove'):
RemoveCombatant.do_command(self, monster.name)
Expand Down

0 comments on commit 8d1dd5f

Please sign in to comment.