Please find both attached and on the branch table-picker-bug-13772 @ r5959 a fix for bug #13772. The patch depends on the previous patch for bug #13787 being applied.
I plan to merge it into trunk tonight. Merge into table-picker-bug-13772 into trunk. See table-picker-bug-13772 commit logs from r5956 to r5959 for detailed implementation notes. A summary of the work follows: Closes bug#13772: PacketPokerTablePicker() has option, auto_blind_ante Client can include a packet field, auto_blind_ante in PacketPokerTablePicker() to have it act as if a PacketPokerAutoBlindAnte() had been sent. Documentation is improved to explain this, and while we're at it, documentation is for PacketPokerAutoBlindAnte() and PacketPokerNoautoBlindAnte() was improved. This patch is copyrighted by me and licensed AGPLv3-or-later.
diff --git a/poker-network/ChangeLog b/poker-network/ChangeLog index be32339..4418770 100644 --- a/poker-network/ChangeLog +++ b/poker-network/ChangeLog @@ -1,5 +1,22 @@ 2009-06-27 Bradley M. Kuhn <[email protected]> + * pokernetwork/pokeravatar.py + (PokerAvatar.performPacketPokerTablePicker): added support for + auto_blind_ante setting in packet. + + * tests/test-pokeravatar.py.in + (PokerAvatarTablePickerTestCase.tablePickerSucceeds): Added + autoBlindAnte argument. + (PokerAvatarTablePickerTestCase.test03_tablePicker_onlyOnePossible): + Set autoBlindAnte to True for this test. + + * pokernetwork/pokerpackets.py (PacketPokerTablePicker): + Documented and added new auto_blind_ante boolean in packet. + (PacketPokerAutoBlindAnte): Correctly documented what server sends + back. + (PacketPokerNoautoBlindAnte): Correctly documented what server + sends back. + * tests/test-pokeravatar.py.in (PokerAvatarTestCase.requestsWithWrongSerial): Changed err_type expected for table_picker to PACKET_POKER_ERROR. diff --git a/poker-network/pokernetwork/pokeravatar.py b/poker-network/pokernetwork/pokeravatar.py index 8d4a280..ff0fd7f 100644 --- a/poker-network/pokernetwork/pokeravatar.py +++ b/poker-network/pokernetwork/pokeravatar.py @@ -918,6 +918,8 @@ class PokerAvatar: if self.performPacketPokerBuyIn( PacketPokerBuyIn(serial = mySerial, amount = buyIn, game_id = table.game.id), table, table.game): + if packet.auto_blind_ante: + table.autoBlindAnte(self, packet.serial, True) self.performPacketPokerSit( PacketPokerSit(serial = mySerial, game_id = table.game.id), table) diff --git a/poker-network/pokernetwork/pokerpackets.py b/poker-network/pokernetwork/pokerpackets.py index 88d8f87..ed51255 100644 --- a/poker-network/pokernetwork/pokerpackets.py +++ b/poker-network/pokernetwork/pokerpackets.py @@ -2377,14 +2377,17 @@ PacketNames[PACKET_POKER_AUTO_BLIND_ANTE] = "POKER_AUTO_BLIND_ANTE" class PacketPokerAutoBlindAnte(PacketPokerId): """\ -Semantics: the player "serial" asks the server to automatically -post the blinds or/and antes for game "game_id". + +Semantics: the player "serial" asks the server to automatically post the + blinds or/and antes for game "game_id". In response to this + packet, the server sends PacketPokerAutoBlindAnte() if + AutoBlindAnte has been successfully turned on, otherwise, it + sends PacketPokerNoautoBlindAnte(). Direction: server <= client -Context: by default the server will not automatically post -the blinds or/and antes. The server will not send any packet -back. +Context: by default the server will not automatically post the blinds +or/and antes. serial: integer uniquely identifying a player. game_id: integer uniquely identifying a game. @@ -2401,9 +2404,14 @@ PacketNames[PACKET_POKER_NOAUTO_BLIND_ANTE] = "POKER_NOAUTO_BLIND_ANTE" class PacketPokerNoautoBlindAnte(PacketPokerId): """\ -Semantics: the player "serial" asks the server to send -a PACKET_POKER_BLIND_REQUEST or/and PACKET_POKER_ANTE_REQUEST -when a blind or/and ante for game "game_id" must be paid. +Semantics: the player "serial" asks the server to send a + PACKET_POKER_BLIND_REQUEST or/and PACKET_POKER_ANTE_REQUEST + when a blind or/and ante for game "game_id" must be paid. + + In response ot this packet, the server sends + PacketPokerNoautoBlindAnte() if AutoBlindAnte has been + successfully turned off, otherwise, it sends + PacketPokerAautoBlindAnte(). Direction: server <= client @@ -4442,6 +4450,8 @@ Semantics: The player "serial" wishes to join a table that matches the Send: PacketPokerTableJoin() Send: PacketPokerSeat() + if auto_blind_ante: # in original packet + Send: PacketPokerAutoBlindAnte() Receive: PacketPokerBuyInLimits() [ returning "best", "min" ] if player.money_available < best: Send: PacketPokerBuyIn(amount = min) @@ -4466,6 +4476,8 @@ Semantics: The player "serial" wishes to join a table that matches the PacketPokerBuyInLimits() # still sent despite mention in pseudo-code above PacketPokerPlayerArrive() # for client.serial PacketPokerPlayerChips() # for client.serial + if auto_blind_ante: + PacketPokerAutoBlindAnte() PacketPokerSit() # for client.serial PacketPokerSeats() @@ -4488,12 +4500,16 @@ serial: integer uniquely identifying a player. currency_serial: int currency id (criteria for search) variant: base name of the variant sought. betting_structure: base name of the betting structure. +autoblind_ante: boolean, if True server will act as if + PacketPokerAutoBlindAnte() were also sent by client. + Defaults to False. """ info = PacketPokerId.info + ( ('currency_serial', 0, 'I'), ('min_players', 0, 'I'), ('variant', '', 's'), ('betting_structure', '', 's'), + ('auto_blind_ante', False, 'bool'), ) Packet.infoDeclare(globals(), PacketPokerTablePicker, Packet, "POKER_TABLE_PICKER", 165) # 165 # 0xa5 # %SEQ% diff --git a/poker-network/tests/test-pokeravatar.py.in b/poker-network/tests/test-pokeravatar.py.in index 2bb9dc9..f2f12ab 100644 --- a/poker-network/tests/test-pokeravatar.py.in +++ b/poker-network/tests/test-pokeravatar.py.in @@ -4080,7 +4080,7 @@ class PokerAvatarTablePickerTestCase(PokerAvatarTestCaseBaseClass): return (client, packet) # ------------------------------------------------------------------------- def tablePickerSucceeds(self, (client, packet), id, numPlayers, currencySerial, - variant, structure, gameId, gameName): + variant, structure, gameId, gameName, autoBlindAnte = False): table = self.service.getTable(gameId) # Save the amount of money the player has, because, later, we may @@ -4091,12 +4091,15 @@ class PokerAvatarTablePickerTestCase(PokerAvatarTestCaseBaseClass): avatar = self.service.avatars[id] avatar.queuePackets() - avatar.handlePacketLogic(PacketPokerTablePicker(serial = client.getSerial(), - currency_serial = currencySerial, - min_players = numPlayers, - variant = variant, - betting_structure = structure)) + avatar.handlePacketLogic( + PacketPokerTablePicker(serial = client.getSerial(), + currency_serial = currencySerial, + min_players = numPlayers, + variant = variant, + betting_structure = structure, + auto_blind_ante = autoBlindAnte)) total = 7 + if autoBlindAnte: total += 1 found = 0 seatNumber = None # next three vars for implementing tests about buyIn amounts. See @@ -4172,6 +4175,13 @@ class PokerAvatarTablePickerTestCase(PokerAvatarTestCaseBaseClass): self.assertEquals(packet.game_id, gameId) if packet.serial == client.getSerial(): found += 1 + elif packet.type == PACKET_POKER_AUTO_BLIND_ANTE: + self.assertEquals(packet.serial, client.getSerial()) + self.assertEquals(packet.game_id, gameId) + found += 1 + self.failUnless(autoBlindAnte, + "should not see an autoBlindAnte since it was not asked for") + self.assertEquals(found, total, "only found %d packet (if that's just 1, then likely the table pick failed rather than succeeded" % found) @@ -4285,7 +4295,8 @@ class PokerAvatarTablePickerTestCase(PokerAvatarTestCaseBaseClass): pickerDeferred = self.preparePlayerForTablePickerSend(3) pickerDeferred.addCallback(self.setMoneyForPlayer, 3, 2, "over_min_under_best", 5) pickerDeferred.addCallback(self.tablePickerSucceeds, 3, 3, 0, - "7stud", "2-4-limit", 5, "Stud 8-max 2/4") + "7stud", "2-4-limit", 5, "Stud 8-max 2/4", + autoBlindAnte = True) playersDeferreds.append(pickerDeferred) return defer.DeferredList(playersDeferreds) # ------------------------------------------------------------------------
-- -- bkuhn
_______________________________________________ Pokersource-users mailing list [email protected] https://mail.gna.org/listinfo/pokersource-users
