| 277 | return True |
| 278 | |
| 279 | def _is_same_kind(self) -> int: |
| 280 | # Kind Values for internal use: |
| 281 | # 7: Four of a kind |
| 282 | # 6: Full house |
| 283 | # 3: Three of a kind |
| 284 | # 2: Two pairs |
| 285 | # 1: One pair |
| 286 | # 0: False |
| 287 | kind = val1 = val2 = 0 |
| 288 | for i in range(4): |
| 289 | # Compare two cards at a time, if they are same increase 'kind', |
| 290 | # add the value of the card to val1, if it is repeating again we |
| 291 | # will add 2 to 'kind' as there are now 3 cards with same value. |
| 292 | # If we get card of different value than val1, we will do the same |
| 293 | # thing with val2 |
| 294 | if self._card_values[i] == self._card_values[i + 1]: |
| 295 | if not val1: |
| 296 | val1 = self._card_values[i] |
| 297 | kind += 1 |
| 298 | elif val1 == self._card_values[i]: |
| 299 | kind += 2 |
| 300 | elif not val2: |
| 301 | val2 = self._card_values[i] |
| 302 | kind += 1 |
| 303 | elif val2 == self._card_values[i]: |
| 304 | kind += 2 |
| 305 | # For consistency in hand type (look at note in _get_hand_type function) |
| 306 | kind = kind + 2 if kind in [4, 5] else kind |
| 307 | # first meaning first pair to compare in 'compare_with' |
| 308 | first = max(val1, val2) |
| 309 | second = min(val1, val2) |
| 310 | # If it's full house (three count pair + two count pair), make sure |
| 311 | # first pair is three count and if not then switch them both. |
| 312 | if kind == 6 and self._card_values.count(first) != 3: |
| 313 | first, second = second, first |
| 314 | self._first_pair = first |
| 315 | self._second_pair = second |
| 316 | return kind |
| 317 | |
| 318 | def _internal_state(self) -> tuple[list[int], set[str]]: |
| 319 | # Internal representation of hand as a list of card values and |