File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -77,9 +77,9 @@ class Action:
7777
7878 @label.setter
7979 def label(self , value: str ) -> None:
80- if ( value == "" or value.encode("ascii") in
81- (action.deref().GetLabel()
82- for action in self.action.deref().GetInfoset().deref().GetActions()) ):
80+ if value == self.label:
81+ return
82+ if value == "" or value in (act.label for act in self.infoset. actions ):
8383 warnings.warn(" In a future version, actions must have unique labels "
8484 " within their information set" ,
8585 FutureWarning )
Original file line number Diff line number Diff line change @@ -192,9 +192,11 @@ class Player:
192192
193193 @label.setter
194194 def label(self , value: str ) -> None:
195- # check to see if the player's name has been used elsewhere
196- if value in [i.label for i in self.game.players]:
197- warnings.warn("Another player with an identical label exists")
195+ if value == self.label:
196+ return
197+ if value == "" or value in (player.label for player in self.game.players ):
198+ warnings.warn(" In a future version, players must have unique labels" ,
199+ FutureWarning )
198200 self .player.deref().SetLabel(value.encode(" ascii" ))
199201
200202 @property
Original file line number Diff line number Diff line change @@ -61,6 +61,18 @@ def test_player_label_invalid():
6161 _ = game .players ["Not a player" ]
6262
6363
64+ def test_set_empty_player_futurewarning ():
65+ game = games .create_stripped_down_poker_efg ()
66+ with pytest .warns (FutureWarning ):
67+ game .players [0 ].label = ""
68+
69+
70+ def test_set_duplicate_player_futurewarning ():
71+ game = games .create_stripped_down_poker_efg ()
72+ with pytest .warns (FutureWarning ):
73+ game .players [0 ].label = game .players [1 ].label
74+
75+
6476def test_strategic_game_add_player ():
6577 game = gbt .Game .new_table ([2 , 2 ])
6678 game .add_player ()
You can’t perform that action at this time.
0 commit comments