Example #1
0
 def testRankGreaterThan(self):
     rank1 = 1
     rank2 = 3
     rank3 = 5
     self.assertTrue(Poker.rank_greater_than(rank1, rank2))
     self.assertFalse(Poker.rank_greater_than(rank2, rank3))
     self.assertTrue(Poker.rank_greater_than(rank1, rank3))
Example #2
0
    def compare_set(self, set1, current):
        """
        returns True if set1 is larger than set2;
        false if less or equal or inapplicable.
        Pre-condition: current set is checked to be
        valid.
        """

        # if current is None, then player has the right to
        # pull out cards first. If set1 is consistent then
        # it should be Okay.
        if current is None:
            return NormalGame.get_main_rank(set1) is not None
        if len(set1) != len(current):
            return False
        # when one of the sets are empty then raise an exception
        if len(set1) == 0:
            raise InvalidPokerException()

        has_small_joker = False
        for card in current:
            if card.suite == 0:
                # If current set has big joker,
                # then it is impossible for another
                # set to be greater, False should be returned.
                if card.rank == 1:
                    return False
                else:
                    has_small_joker = True

        if has_small_joker:
            # check to see if set1 has big joker, since
            # current set already has small joker
            choice_okay = False
            for card in set1:
                if card.suite == 0 and card.rank == 1:
                    choice_okay = True
            if not choice_okay:
                return False

        rank_set1 = NormalGame.get_main_rank(set1)
        rank_current = NormalGame.get_main_rank(current)
        if rank_set1 is None:
            return False
        # Since the game is normal game, big2 should be true.
        return rank_set1 == 0 or Poker.rank_greater_than(rank_set1, rank_current, big2=True)