From 929f54430d804b19b23a3c01c14f7acf2353c573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Mon, 6 May 2019 20:58:40 +0300 Subject: [PATCH] !card to for communism --- gameloop.py | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/gameloop.py b/gameloop.py index 5d466bc..b51df40 100644 --- a/gameloop.py +++ b/gameloop.py @@ -716,24 +716,39 @@ def game(send, notice, voice, devoice, get_event): notice(nick, 'Only the czar can choose now') continue - if len(choices) != 1: - notice(nick, 'Select one choice') - continue - choice = choices[0] + if len(choices) == 1: + choice = choices[0] - if 0 <= choice < len(choosers): - player = choosers[choice] - player.points += 1 + if 0 <= choice < len(choosers): + player = choosers[choice] + player.points += 1 - # Winner is Czar semantics - czar = player + # Winner is Czar semantics + czar = player - send('The winner is %s with: %s' % (player.nick, combine_cards(round_call_card.text, [player.hand[i].text for i in card_choices[player]]))) + send('The winner is %s with: %s' % (player.nick, combine_cards(round_call_card.text, [player.hand[i].text for i in card_choices[player]]))) + + break + + else: + notice(nick, '%i not in range' % choice) + + elif len(choices) == 0: + # Special case: award everyone a point + # and randomize czar + for player in card_choices: + player.points += 1 + + # If we set czar to None, setup_round() + # will handle ramdomizing it for us + czar = None + + send('Everyone is a winner!') break else: - notice(nick, '%i not in range' % choice) + notice(nick, 'Select one or zero choices') elif event == events.origins: nick, = args