reduce waiting time for repeated skipping and remove after four successive skips

This commit is contained in:
Jannes Höke 2016-05-08 17:03:29 +02:00
parent 2b8c01002f
commit 1d10388d8e
2 changed files with 38 additions and 7 deletions

32
bot.py
View file

@ -356,12 +356,38 @@ def skip_player(bot, update):
update.message.message_id)
return
elif game.current_player.waiting_time > 0:
game.current_player.anti_cheat += 1
game.current_player.waiting_time -= 30
game.current_player.cards.append(game.deck.draw())
game.turn()
send_async(bot, chat_id,
text="Next player: %s"
text="Waiting time to skip this player has "
"been reduced to %d seconds.\n"
"Next player: %s"
% (game.current_player.waiting_time,
display_name(game.current_player.user)))
return
elif len(game.players) > 2:
send_async(bot, chat_id,
text="%s was skipped four times in a row "
"and has been removed from the game.\n"
"Next player: %s"
% (display_name(game.current_player.user),
display_name(
game.current_player.next.user)))
gm.leave_game(game.current_player.user, chat_id)
return
else:
send_async(bot, chat_id,
text="%s was skipped four times in a row "
"and has been removed from the game.\n"
"The game ended."
% display_name(game.current_player.user))
gm.end_game(chat_id, game.current_player.user)
return
@ -482,6 +508,10 @@ def process_result(bot, update):
def do_play_card(bot, chat_id, game, player, result_id, user):
if player.waiting_time < 90:
player.waiting_time = 90
send_async(bot, chat_id, text="Waiting time for %s has been reset to "
"90 seconds" % display_name(user))
card = c.from_str(result_id)
game.play_card(card)
player.cards.remove(card)

View file

@ -55,6 +55,7 @@ class Player(object):
self.drew = False
self.anti_cheat = 0
self.turn_started = datetime.now()
self.waiting_time = 90
def leave(self):
""" Leave the current game """