def begin_game(self): self.t = False self.can_join = False self.phenny.say("Welcome to the Casino! This round of " + str(self.num_cards) + " card poker has now begun!") if self.stakes != "free": # Remove users that didnt ante in for uid in p.in_game: if p.players[uid].ante == False: p.remove_from_game(uid) self.phenny.say("%s did not ante in and was removed from this game." % p.players[uid].name) if len(p.in_game) == 0: self.phenny.say("No players ante'd in.") self.game_over() return if len(p.in_game) > 1: self.phenny.say(str("There are %d players this round: %s" % (len(p.in_game), p.list_in_game()))) # Not enough players else: self.phenny.say("There are not enough players! For a game of poker there must be 2 players minimum.") for uid in p.in_game: p.players[uid].add_gold(p.players[uid].bet) p.players[uid].bet = 0 p.remove_from_game(uid) self.phenny.write(('NOTICE', p.players[uid].name + " The dealer returned your ante.")) self.game_over() return self.deal_cards()
def casino_part(phenny, input): if input.uid in p.players.keys(): if in_play and input.uid in p.in_game: p.remove_from_game(input.uid) if hasattr(game, 'started') and game.started: phenny.say("%s forfeit their bet and left the game early." % p.players[input.uid].name) else: phenny.say("%s left the game." % p.players[input.uid].name) if len(p.in_game) == 0: game.game_over() p.remove_player(input.uid)
def yes(phenny, input): if input.uid in leaving: if game.started and input.uid in p.in_game: p.remove_from_game(input.uid) phenny.say("%s forfeit their bet and left the game early." % p.players[input.uid].name) if len(p.in_game) == 0: game.game_over() elif input.uid in p.in_game: p.remove_from_game(input.uid) phenny.say("%s forfeit their bet and left the game early." % p.players[input.uid].name) if len(p.in_game) == 0: game.game_over()
def leave(phenny, input): global leaving if in_play and game.started and input.uid in p.in_game: if input.uid not in leaving: leaving.append(input.uid) Timer(30.0, cancel_leave, [input.uid]).start() phenny.say( "Are you sure you want to forfeit all bets and leave the game early? !Yes or !No?" ) else: phenny.say("To leave the game respond !Yes") elif in_play and not game.started and input.uid in p.in_game: p.remove_from_game(input.uid) phenny.say("%s left the game." % p.players[input.uid].name) if len(p.in_game) == 0: game.game_over()
def surrender(self, uid): if self.accept_surrender and self.turns and self.turns[0] == uid: del self.turns[0] if self.t and self.t.is_alive(): self.t.cancel() self.t = False bet = p.players[uid].bet casino.gold += (bet * 0.25) p.players[0].add_gold(bet / 2) p.players[uid].bet = 0 p.players[uid].add_gold(bet / 2) p.remove_from_game(uid) gold = p.players[uid].gold self.phenny.write( ('NOTICE', p.players[uid].name + " You surrendered losing half your bet of " + str(bet) + " to the dealer. You have " + str(gold) + " left.")) # NOTICE self.next_player()
def remove_from_game(self): player.remove_from_game(self.fake_id)