def __init__(self, phenny, uid, nick): self.game_type = "blackjack" self.started = False self.deck = False self.accept_bets = False self.accept_surrender = False self.accept_doubledown = False self.t = False # Used for the delay timer so that we can reset it from the !join command self.timer_start = 0 # Used for calculating whether or not we should reset the timer on !join self.starter_uid = False self.turns = False # The users who have turns, in order, current is at index 0 self.phenny = phenny p.add_player(0, 'Dealer') p.players[0].hand.hand_value = MethodType(hand_value, p.players[0].hand) p.players[0].add_gold(1000000) self.starter_uid = uid self.phenny.say( "A new game of blackjack has begun! Type !enter if you'd like to play. You have 30 seconds to join." ) self.phenny.say(p.add_to_game(self.phenny, uid)) p.players[uid].hand.hand_value = MethodType(hand_value, p.players[uid].hand) self.t = Timer(DELAY_TIME, self.begin_game) self.timer_start = time.time() self.t.start()
def join(self, uid): if len(p.in_game) < 6 and uid not in p.in_game: msg = p.add_to_game(self.phenny, uid) # Add the hand_value function p.players[uid].hand.hand_value = MethodType( hand_value, p.players[uid].hand) # Joining during betting if not self.accept_bets: # If we are at the max number of players, start the game if len(p.in_game) == 6: self.t.cancel() self.begin_game() # If half the countdown has already passed, restart the timer elif time.time( ) - self.timer_start > self.delay_time / 2 and self.t: self.t.cancel() self.t = Timer(self.delay_time, self.begin_game) self.t.start() return msg elif uid in p.in_game: return "You have already joined the game!" else: return "This game has reached the max amount (6) of players. Please try again later."
def join(self, uid): if not self.can_join: self.phenny.say("%s, this game has already started!" % p.players[uid].name) return if len(p.in_game) < 6 and uid not in p.in_game: msg = p.add_to_game(self.phenny, uid) p.players[uid].ante = False # If half the countdown has already passed, restart the timer if len(p.in_game) != 6 and time.time( ) - self.timer_start > DELAY_TIME / 2 and self.t: self.t.cancel() self.t = Timer(DELAY_TIME, self.begin_game) self.t.start() # If less than 5 seconds left, bump the timer to 5 seconds no matter what so the new player has time to ante elif time.time() - self.timer_start > DELAY_TIME - 5.0 and self.t: self.t.cancel() self.t = Timer(5.0, self.begin_game) self.t.start() return msg elif uid in p.in_game: return "You have already joined the game!" else: return "This game has reached the max amount (6) of players. Please try again later."
def __init__(self, phenny, uid, nick, cards, stakes): self.game_type = "poker" self.started = False self.deck = False self.deck2 = False self.can_join = False self.accept_bets = False self.accept_discard = False self.current_bet = 0 self.betting_rounds = 0 self.betting_stage = False self.betting_pot = 0 self.opening_player = False self.num_cards = cards self.accept_ante = True self.t = False # Used for the delay timer so that we can reset it from the !join command self.timer_start = 0 # Used for calculating whether or not we should reset the timer on !join self.starter_uid = uid self.turns = False self.phenny = phenny if stakes.isdigit(): self.stakes = int(stakes) elif stakes == "free": self.stakes = "free" elif stakes == "low": self.stakes = 100 elif stakes == "high": self.stakes = 5000 elif stakes == "extreme": self.stakes = 50000 else: self.stakes = 500 self.phenny.say( "A new game of " + str(self.num_cards) + " card poker has begun! Type !enter if you'd like to play. You have 30 seconds to join." ) if self.stakes == "free": self.phenny.say( "This is a no stakes game. There are no ante's and betting is not permitted." ) else: self.phenny.say( "The ante for this game is set at " + str(self.stakes) + " gold. After joining please type !ante to buy into the game.") self.phenny.say(p.add_to_game(self.phenny, uid)) p.players[uid].ante = False self.can_join = True self.t = Timer(DELAY_TIME, self.begin_game) self.timer_start = time.time() self.t.start()
def __init__(self, phenny, uid, nick, turbo=False): self.game_type = "blackjack" self.turbo = turbo self.delay_time = 30.0 self.started = False self.deck = False self.accept_bets = False self.accept_surrender = False self.accept_doubledown = False self.accept_split = False self.t = False # Used for the delay timer so that we can reset it from the !join command self.timer_start = 0 # Used for calculating whether or not we should reset the timer on !join self.starter_uid = False self.turns = False # The users who have turns, in order, current is at index 0 self.phenny = phenny p.add_player(phenny, 0, 'Dealer') p.players[0].hand.hand_value = MethodType(hand_value, p.players[0].hand) p.players[0].add_gold(1000000) self.starter_uid = uid if self.turbo: self.phenny.say( "A new game of turbo blackjack has begun! This is a sped up version of our normal blackjack. Make sure you are ready to go fast! Type !enter if you'd like to play. You have 10 seconds to join." ) self.delay_time = DELAY_SPEED_TIME else: self.phenny.say( "A new game of blackjack has begun! Type !enter if you'd like to play. You have 30 seconds to join." ) self.delay_time = DELAY_TIME self.phenny.say(p.add_to_game(self.phenny, uid)) p.players[uid].hand.hand_value = MethodType(hand_value, p.players[uid].hand) self.t = Timer(self.delay_time, self.begin_game) self.timer_start = time.time() self.t.start()