forked from nortti/tea_cah
Add !redeal
This commit is contained in:
parent
cf6e2fea93
commit
1ffb82ebc1
|
@ -296,6 +296,10 @@ def parse_command(message, nick, irc):
|
||||||
if args(0) is not None:
|
if args(0) is not None:
|
||||||
send_event((events.origins, nick))
|
send_event((events.origins, nick))
|
||||||
|
|
||||||
|
elif c == '!redeal':
|
||||||
|
if args(0) is not None:
|
||||||
|
send_event((events.redeal, nick))
|
||||||
|
|
||||||
elif c == '!help':
|
elif c == '!help':
|
||||||
arg = args([0, 1, 2])
|
arg = args([0, 1, 2])
|
||||||
if arg is not None:
|
if arg is not None:
|
||||||
|
@ -304,10 +308,10 @@ def parse_command(message, nick, irc):
|
||||||
arg[0] = arg[0][1:]
|
arg[0] = arg[0][1:]
|
||||||
|
|
||||||
if len(arg) == 0:
|
if len(arg) == 0:
|
||||||
send('!status !start !ready !unready !kill !join !leave !players !kick !deck !limit !card !cards !origins')
|
send('!status !start !ready !unready !kill !join !leave !players !kick !deck !limit !card !cards !origins !redeal')
|
||||||
|
|
||||||
elif len(arg) == 1:
|
elif len(arg) == 1:
|
||||||
if arg[0] in ('status', 'ready', 'unready', 'kill', 'join', 'leave', 'players', 'cards', 'origins'):
|
if arg[0] in ('status', 'ready', 'unready', 'kill', 'join', 'leave', 'players', 'cards', 'origins', 'redeal'):
|
||||||
send('Usage: !%s' % (arg[0]))
|
send('Usage: !%s' % (arg[0]))
|
||||||
elif arg[0] == 'start':
|
elif arg[0] == 'start':
|
||||||
send('Usage: !start [<preset>]')
|
send('Usage: !start [<preset>]')
|
||||||
|
|
51
gameloop.py
51
gameloop.py
|
@ -2,8 +2,6 @@ import enum
|
||||||
import random
|
import random
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
# TODO: !redeal
|
|
||||||
|
|
||||||
import cardcast_api
|
import cardcast_api
|
||||||
|
|
||||||
class events(enum.Enum):
|
class events(enum.Enum):
|
||||||
|
@ -13,7 +11,7 @@ class events(enum.Enum):
|
||||||
deck_add, deck_add_random, deck_remove, deck_list,
|
deck_add, deck_add_random, deck_remove, deck_list,
|
||||||
bot_add_rando, bot_remove,
|
bot_add_rando, bot_remove,
|
||||||
limit,
|
limit,
|
||||||
card, cards, origins) = range(21)
|
card, cards, origins, redeal) = range(22)
|
||||||
|
|
||||||
class limit_types(enum.Enum):
|
class limit_types(enum.Enum):
|
||||||
points, rounds = range(2)
|
points, rounds = range(2)
|
||||||
|
@ -351,8 +349,8 @@ def game(send, notice, voice, devoice, get_event):
|
||||||
if origins != '':
|
if origins != '':
|
||||||
notice(nick, origins)
|
notice(nick, origins)
|
||||||
|
|
||||||
elif event == events.card or event == events.cards:
|
elif event == events.card or event == events.cards or event == events.redeal:
|
||||||
# Ignore selecting and listing cards if it's not available
|
# Ignore card commands if no cards are available yet
|
||||||
pass
|
pass
|
||||||
|
|
||||||
elif event == events.ready or event == events.unready:
|
elif event == events.ready or event == events.unready:
|
||||||
|
@ -783,6 +781,26 @@ def game(send, notice, voice, devoice, get_event):
|
||||||
else:
|
else:
|
||||||
notice(nick, 'call: %s, %s' % (round_call_card.deck.code, get_hand_origins(players[nick])))
|
notice(nick, 'call: %s, %s' % (round_call_card.deck.code, get_hand_origins(players[nick])))
|
||||||
|
|
||||||
|
elif event == events.redeal:
|
||||||
|
nick, = args
|
||||||
|
|
||||||
|
if nick not in players:
|
||||||
|
# Ignore those not in the game
|
||||||
|
continue
|
||||||
|
|
||||||
|
player = players[nick]
|
||||||
|
|
||||||
|
for index in range(len(player.hand)):
|
||||||
|
player.hand[index] = None
|
||||||
|
|
||||||
|
if player in choosers or player in card_choices:
|
||||||
|
send('Dealing out a new hand to %s, restarting round' % nick)
|
||||||
|
|
||||||
|
return setup_round
|
||||||
|
|
||||||
|
else:
|
||||||
|
notice(nick, 'New hand will be dealt next round')
|
||||||
|
|
||||||
elif event == events.deck_remove:
|
elif event == events.deck_remove:
|
||||||
common_handler(event, args)
|
common_handler(event, args)
|
||||||
|
|
||||||
|
@ -906,6 +924,26 @@ def game(send, notice, voice, devoice, get_event):
|
||||||
|
|
||||||
notice(nick, 'call: %s; %s' % (round_call_card.deck.code, '; '.join(answers_origins)))
|
notice(nick, 'call: %s; %s' % (round_call_card.deck.code, '; '.join(answers_origins)))
|
||||||
|
|
||||||
|
elif event == events.redeal:
|
||||||
|
nick, = args
|
||||||
|
|
||||||
|
if nick not in players:
|
||||||
|
# Ignore those not in the game
|
||||||
|
continue
|
||||||
|
|
||||||
|
player = players[nick]
|
||||||
|
|
||||||
|
for index in range(len(player.hand)):
|
||||||
|
player.hand[index] = None
|
||||||
|
|
||||||
|
if player in card_choices:
|
||||||
|
send('Lost a card played this round, restarting round')
|
||||||
|
|
||||||
|
return setup_round
|
||||||
|
|
||||||
|
else:
|
||||||
|
notice(nick, 'New hand will be dealt next round')
|
||||||
|
|
||||||
elif event == events.deck_remove:
|
elif event == events.deck_remove:
|
||||||
common_handler(event, args)
|
common_handler(event, args)
|
||||||
|
|
||||||
|
@ -1079,6 +1117,9 @@ if __name__ == '__main__':
|
||||||
elif t == 'origins':
|
elif t == 'origins':
|
||||||
nick = input('nick> ')
|
nick = input('nick> ')
|
||||||
return (events.origins, nick)
|
return (events.origins, nick)
|
||||||
|
elif t == 'redeal':
|
||||||
|
nick = input('nick> ')
|
||||||
|
return (events.redeal, nick)
|
||||||
else:
|
else:
|
||||||
print('?')
|
print('?')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue