Skip to content

Commit

Permalink
Catch missing arguments to .play. Fixes #16.
Browse files Browse the repository at this point in the history
  • Loading branch information
dgw committed Jul 19, 2015
1 parent d9f5130 commit fd3dab1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion unobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@
"If you cannot play a card on your turn, you must %pdraw. If that card is not playable, you "
"must %ppass (forfeiting your turn).",
"Use %punotheme (dark|light) if you are having trouble reading your cards to give them a "
"dark/light background color, respectively. Use %punotheme default to reset it."]
"dark/light background color, respectively. Use %punotheme default to reset it."],
'PLAY_SYNTAX': "Command syntax error. You must use e.g. %pplay r 3 or %pplay w y.",
} # yapf: disable
COLORED_CARD_NUMS = ['1', '2', '3', '4', '5', '6', '7', '8', '9', 'R', 'S', 'D2']
CARD_COLORS = 'RGBY'
Expand Down Expand Up @@ -184,6 +185,9 @@ def play(self, bot, trigger):
if trigger.nick != self.playerOrder[self.currentPlayer]:
bot.say(STRINGS['ON_TURN'] % self.playerOrder[self.currentPlayer])
return
if not trigger.group(3) or not trigger.group(4):
bot.notice(STRINGS['PLAY_SYNTAX'].replace('%p', bot.config.core.help_prefix), trigger.nick)
return
color = trigger.group(3).upper()
if color in CARD_COLORS:
card = trigger.group(4).upper()
Expand Down

0 comments on commit fd3dab1

Please sign in to comment.