File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -192,7 +192,7 @@ def __init__(
192192 self .ante = ante
193193 self .bb_ante = bb_ante
194194
195- self .players = []
195+ self .players : list [ Player ] = []
196196
197197 if stacks is not None :
198198 self .set_stacks (stacks )
@@ -214,6 +214,10 @@ def set_stacks(self, stacks: List[Decimal]):
214214 Player (position = pos , stack = Decimal (stack ), hand_history = self )
215215 )
216216
217+ @property
218+ def is_hu (self ) -> bool :
219+ return len (self .players ) == 2
220+
217221 def post_blinds_and_antes (self ):
218222 self .current_player = self .players [0 ]
219223 if self .ante :
@@ -279,7 +283,7 @@ def _next_player(self):
279283
280284 def _next_street (self ):
281285 # HU special case
282- if len ( self .players ) == 2 and self .current_street == Street .PRE_FLOP :
286+ if self .is_hu and self .current_street == Street .PRE_FLOP :
283287 self .players = self .players [::- 1 ]
284288 self .current_street = self .current_street .next ()
285289 if self .current_street == Street .SHOWDOWN :
@@ -518,6 +522,8 @@ def from_dict(cls, obj):
518522 if action_type in BLINDS + [ActionType .ANTE ]:
519523 continue
520524 hh .add_action (action_type , action ["amount" ])
525+ if hh .is_hu and hh .players [0 ].position == Position .BB :
526+ hh .players = hh .players [::- 1 ]
521527 return hh
522528
523529 def to_json (self ):
You can’t perform that action at this time.
0 commit comments