Prevent playing the same card twice with multiblanks
This commit is contained in:
parent
91bea13796
commit
8c09399ef7
1 changed files with 17 additions and 8 deletions
25
gameloop.py
25
gameloop.py
|
@ -4,6 +4,11 @@ from collections import namedtuple
|
||||||
|
|
||||||
import cardcast_api
|
import cardcast_api
|
||||||
|
|
||||||
|
# TODO: rando
|
||||||
|
# TODO: $0 support
|
||||||
|
# TODO: collapse several _ in a row into one
|
||||||
|
# TODO: keep track of where cards come from purge from hand when deck remove
|
||||||
|
|
||||||
class events(enum.Enum):
|
class events(enum.Enum):
|
||||||
quit, nick_change, status, start, ready, unready, kill, join, leave, players, deck_add, deck_add_random, deck_remove, deck_list, limit, card, cards = range(17)
|
quit, nick_change, status, start, ready, unready, kill, join, leave, players, deck_add, deck_add_random, deck_remove, deck_list, limit, card, cards = range(17)
|
||||||
|
|
||||||
|
@ -569,10 +574,21 @@ def game(send, notice, get_event):
|
||||||
notice(nick, 'You\'ll get to choose next round')
|
notice(nick, 'You\'ll get to choose next round')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Round call card has N parts. Between each of
|
||||||
|
# those parts goes one response card. Therefore
|
||||||
|
# there should be N - 1 response cards
|
||||||
|
if len(choices) != len(round_call_card) - 1:
|
||||||
|
notice(nick, 'Select %i card(s)' % (len(round_call_card) - 1))
|
||||||
|
continue
|
||||||
|
|
||||||
selected_cards = []
|
selected_cards = []
|
||||||
for choice in choices:
|
for choice in choices:
|
||||||
if 0 <= choice < len(player.hand):
|
if 0 <= choice < len(player.hand):
|
||||||
selected_cards.append(choice)
|
if choice not in selected_cards:
|
||||||
|
selected_cards.append(choice)
|
||||||
|
else:
|
||||||
|
notice(nick, 'Can\'t play the same card twice')
|
||||||
|
break
|
||||||
else:
|
else:
|
||||||
notice(nick, '%i not in your hand' % choice)
|
notice(nick, '%i not in your hand' % choice)
|
||||||
break
|
break
|
||||||
|
@ -581,13 +597,6 @@ def game(send, notice, get_event):
|
||||||
# Failed to use some choice
|
# Failed to use some choice
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Round call card has N parts. Between each of
|
|
||||||
# those parts goes one response card. Therefore
|
|
||||||
# there should be N - 1 response cards
|
|
||||||
if len(selected_cards) != len(round_call_card) - 1:
|
|
||||||
notice(nick, 'Select %i card(s)' % (len(round_call_card) - 1))
|
|
||||||
continue
|
|
||||||
|
|
||||||
card_choices[player] = selected_cards
|
card_choices[player] = selected_cards
|
||||||
if player in choosers:
|
if player in choosers:
|
||||||
choosers.remove(player)
|
choosers.remove(player)
|
||||||
|
|
Loading…
Reference in a new issue