allow new game if not enough chips

This commit is contained in:
Gordon Shumway 2019-12-06 05:48:36 -05:00 committed by GitHub
parent 967aac1960
commit 4264f4d6e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -222,14 +222,16 @@ class BlackJack(callbacks.Plugin):
game_name = "game_%s" % player
# Checks if player has any chips.
chips = self._playerChips(player)
chipsClass = Chips()
# If this is True player is already playing blackjack and only one game is allowed per player.
if self._isScheduled(game_name):
irc.reply("You can play only one instance of the game in same time.")
# If player does not have chips he can't play, logical.
if chips == "NoChipsFile" or chips == False or chips == None:
chipsClass = Chips()
chipsClass._addChips(player, stake)
chips = stake
elif stake > chips:
chipsClass._addChips(player, stake - chips)
if stake >= self.minStake and stake <= self.maxStake and stake <= chips:
# Now is good time to add new player and actually start a game.
self._addNewPlayer(player, stake)