Exemplo n.º 1
0
 def test2(self):
     for (serial, seat) in ((1, 0), (2, 1), (3, 2), (4, 3)):
         self.make_new_player(serial, seat)
     self.game.beginTurn(1)
     for event in self.game.historyGet():
         if event[0] == "round":
             (type, name, board, pockets) = event
             for (player_serial, pocket) in pockets.iteritems():
                 pocket.loseNotVisible()
                 self.assertEqual(pocket, PokerCards([PokerCards.NOCARD] * pocket.len()))
Exemplo n.º 2
0
def private2public(packet, serial):
    #
    # cards private to each player are shown only to the player
    if packet.type == PACKET_POKER_PLAYER_CARDS and packet.serial != serial:
        return PacketPokerPlayerCards(game_id=packet.game_id,
                                      serial=packet.serial,
                                      cards=PokerCards(
                                          packet.cards).tolist(False))
    else:
        return packet
Exemplo n.º 3
0
 def make_cards(self, visible, *args):
     cards = PokerCards(poker_eval.string2card(args))
     if visible:
         cards.allVisible()
     else:
         cards.allHidden()
     return cards
 class TestPacket(packets.Packet):
     info = packets.Packet.info + (
         ('f1', [1, 10], 'c'),
         ('f2',
          [PokerChips([1], [3]),
           PokerCards([255, 255]), ["a", 1]], 'j'),
     )
     fields = (
         "\x0a",  # type
         "\0\0",  # length
         "\0\0\0\x0a",  # f1
         '\x00-[["Chips", 3], ["Cards", 255, 255], ["a", 1]]',  # f2
     )
     binary = fields[0] + pack('!H', len("".join(fields))) + "".join(
         fields[2:])
Exemplo n.º 5
0
 def decode_objects(something):
     if type(something) is types.ListType:
         if something[0] in ('Cards', 'Chips'):
             if something[0] == 'Cards':
                 return PokerCards(something[1:])
             elif something[0] == 'Chips':
                 return PokerChips([1], [something[1]])
         else:
             return map(PokerClientPacketJSON.decode_objects, something)
     elif type(something) is types.DictType:
         return dict(
             map(
                 lambda
                 (k, v): [k, PokerClientPacketJSON.decode_objects(v)],
                 something.iteritems()))
     else:
         return something
Exemplo n.º 6
0
 def make_cards(self, *args):
     return PokerCards(poker_eval.string2card(args))
Exemplo n.º 7
0
def createCache():
    return {"board": PokerCards(), "pockets": {}}