reduce waiting time for repeated skipping and remove after four successive skips
This commit is contained in:
parent
2b8c01002f
commit
1d10388d8e
2 changed files with 38 additions and 7 deletions
44
bot.py
44
bot.py
|
@ -356,13 +356,39 @@ def skip_player(bot, update):
|
||||||
update.message.message_id)
|
update.message.message_id)
|
||||||
return
|
return
|
||||||
|
|
||||||
game.current_player.anti_cheat += 1
|
elif game.current_player.waiting_time > 0:
|
||||||
game.current_player.cards.append(game.deck.draw())
|
game.current_player.anti_cheat += 1
|
||||||
game.turn()
|
game.current_player.waiting_time -= 30
|
||||||
send_async(bot, chat_id,
|
game.current_player.cards.append(game.deck.draw())
|
||||||
text="Next player: %s"
|
game.turn()
|
||||||
% display_name(game.current_player.user))
|
send_async(bot, chat_id,
|
||||||
return
|
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
|
||||||
|
|
||||||
|
|
||||||
def help(bot, update):
|
def help(bot, update):
|
||||||
|
@ -482,6 +508,10 @@ def process_result(bot, update):
|
||||||
|
|
||||||
|
|
||||||
def do_play_card(bot, chat_id, game, player, result_id, user):
|
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)
|
card = c.from_str(result_id)
|
||||||
game.play_card(card)
|
game.play_card(card)
|
||||||
player.cards.remove(card)
|
player.cards.remove(card)
|
||||||
|
|
|
@ -55,6 +55,7 @@ class Player(object):
|
||||||
self.drew = False
|
self.drew = False
|
||||||
self.anti_cheat = 0
|
self.anti_cheat = 0
|
||||||
self.turn_started = datetime.now()
|
self.turn_started = datetime.now()
|
||||||
|
self.waiting_time = 90
|
||||||
|
|
||||||
def leave(self):
|
def leave(self):
|
||||||
""" Leave the current game """
|
""" Leave the current game """
|
||||||
|
|
Loading…
Reference in a new issue