def powerful_addition(self, combination_cards): """ :type combination_cards: list of Card :rtype: int """ addition_cards_number = 5 - len(combination_cards) return Card.diff(self.seven_cards, combination_cards)[:addition_cards_number]
def three_same_rank_two_same_rank(cls, seven_cards): """ :param seven_cards: list of Card :rtype: list of Card """ three = cls.three_same_rank(seven_cards) if not three: return None remaining_cards = Card.diff(seven_cards, three) second_pair = cls.two_same_rank(remaining_cards) if not second_pair: return None return three + second_pair
def two_same_rank_pairs(cls, seven_cards): """ :param seven_cards: list of Card :rtype: list of Card """ pair = cls.two_same_rank(seven_cards) if not pair: return None remaining_cards = Card.diff(seven_cards, pair) second_pair = cls.two_same_rank(remaining_cards) if not second_pair: return None return pair + second_pair
def evaluate(self, combination): """ :type combination: CombinationEnum :rtype: list """ combination_rule = self.evaluator[combination] pattern = combination_rule['pattern'] combination_cards = getattr(self, pattern)(self.seven_cards) if not combination_cards: return None powerful_addition_cards = self.powerful_addition(combination_cards) power_cards = combination_cards + powerful_addition_cards kicker_cards = Card.diff(powerful_addition_cards, self.table_cards) power = combination_rule['base_power'] + Card.power(power_cards) return [ combination, combination_cards, kicker_cards, power_cards, power ]