Exemplo n.º 1
0
    def __init__(self, factory, id=0, description=None):
        self.log = PokerTable.log.get_instance(self, refs=[
            ('Game', self, lambda table: table.game.id),
            ('Hand', self, lambda table: table.game.hand_serial if table.game.hand_serial > 1 else None)
        ])
        self.factory = factory
        settings = self.factory.settings
        self.game = PokerGameServer("poker.%s.xml", factory.dirs)
        self.game.prefix = "[Server]"
        self.history_index = 0
        predefined_decks = settings.headerGetList("/server/decks/deck")
        if predefined_decks:
            self.game.shuffler = PokerPredefinedDecks(map(
                lambda deck: self.game.eval.string2card(deck.split()),
                predefined_decks
            ))
        self.observers = []
        self.waiting = []
        self.game.id = id
        self.game.name = description["name"]
        self.game.setVariant(description["variant"])
        self.game.setBettingStructure(description["betting_structure"])
        self.game.setMaxPlayers(int(description["seats"]))
        self.game.forced_dealer_seat = int(description.get("forced_dealer_seat", -1))
        self.game.registerCallback(self._gameCallbackTourneyEndTurn)
        self.game.registerCallback(self._gameCallbackTourneyUpdateStats)
        self.skin = description.get("skin", "default")
        self.currency_serial = int(description.get("currency_serial", 0))
        self.playerTimeout = int(description.get("player_timeout", 60))
        self.muckTimeout = int(description.get("muck_timeout", 5))
        self.transient = 'transient' in description
        self.tourney = description.get("tourney", None)

        # max_missed_round can be configured on a per table basis, which
        # overrides the server-wide default
        self.max_missed_round = int(description.get("max_missed_round",factory.getMissedRoundMax()))

        self.delays = settings.headerGetProperties("/server/delays")[0]
        self.autodeal = settings.headerGet("/server/@autodeal") == "yes"
        self.autodeal_temporary = settings.headerGet("/server/users/@autodeal_temporary") == 'yes'
        self.cache = createCache()
        self.owner = 0
        self.avatar_collection = PokerAvatarCollection("Table%d" % id)
        self.timer_info = {
            "playerTimeout": None,
            "playerTimeoutSerial": 0,
            "playerTimeoutTime": None,
            "muckTimeout": None,
        }
        self.timeout_policy = "sitOut"
        self.previous_dealer = -1
        self.game_delay = {
            "start": 0,
            "delay": 0,
        }
        self.update_recursion = False

        # Lock Checker
        self._initLockCheck()
Exemplo n.º 2
0
 def handReplay(self, avatar, hand):
     history = self.factory.loadHand(hand)
     if not history:
         return
     event_type, level, hand_serial, hands_count, time, variant, betting_structure, player_list, dealer, serial2chips = history[0]  # @UnusedVariable
     for player in self.game.playersAll():
         avatar.sendPacketVerbose(PacketPokerPlayerLeave(
             game_id = self.game.id,
             serial = player.serial,
             seat = player.seat
         ))
     self.game.reset()
     self.game.name = "*REPLAY*"
     self.game.setVariant(variant)
     self.game.setBettingStructure(betting_structure)
     self.game.setTime(time)
     self.game.setHandsCount(hands_count)
     self.game.setLevel(level)
     self.game.hand_serial = hand
     for serial in player_list:
         self.game.addPlayer(serial)
         self.game.getPlayer(serial).money = serial2chips[serial]
         self.game.sit(serial)
     if self.isJoined(avatar):
         avatar.join(self, reason=PacketPokerTable.REASON_HAND_REPLAY)
     else:
         self.joinPlayer(avatar, avatar.getSerial(), reason = PacketPokerTable.REASON_HAND_REPLAY)
     serial = avatar.getSerial()
     cache = createCache()
     packets, previous_dealer, errors = history2packets(history, self.game.id, -1, cache) #@UnusedVariable
     for packet in packets:
         if packet.type == PACKET_POKER_PLAYER_CARDS and packet.serial == serial:
             packet.cards = cache["pockets"][serial].toRawList()
         if packet.type == PACKET_POKER_PLAYER_LEAVE:
             continue
         avatar.sendPacketVerbose(packet)
Exemplo n.º 3
0
 def historyReset(self):
     self.history_index = 0
     self.cache = createCache()