Esempio n. 1
0
 def get_clearings_to_revolt_in(self) -> list[Clearing]:
     valid_revolt_clearings = []
     for base in self.piece_stock.get_bases():
         # Skip bases that don't match the order card
         if not Suit.are_suits_equal(base.location, self.order_card.suit):
             continue
         # Skip bases that are on the map
         if not isinstance(base.location, Supply):
             continue
         # Skip bases without matching sympathetic clearings
         for token in self.piece_stock.get_sympathy():
             # We don't check if clearing.can_place_piece here, because any piece that prevents the base from being
             # placed is removed by the revolt
             if isinstance(token.location, Clearing) and token.location.suit == base.suit:
                 valid_revolt_clearings.append(token.location)
     return valid_revolt_clearings
Esempio n. 2
0
 def get_clearings_of_suit(self, suit: Suit) -> list[Clearing]:
     clearings_of_suit = []
     for clearing in self.clearings:
         if Suit.are_suits_equal(clearing.suit, suit):
             clearings_of_suit.append(clearing)
     return clearings_of_suit
Esempio n. 3
0
    def test_are_suits_equal__true(self):
        suit1 = Suit.FOX
        suit2 = Suit.FOX

        self.assertTrue(Suit.are_suits_equal(suit1, suit2))
Esempio n. 4
0
    def test_are_suits_equal_bird__false(self):
        suit1 = Suit.BIRD
        suit2 = Suit.FOX

        self.assertFalse(Suit.are_suits_equal(suit1, suit2))
Esempio n. 5
0
    def test_are_suits_equal__false(self):
        suit1 = Suit.FOX
        suit2 = Suit.RABBIT

        self.assertFalse(Suit.are_suits_equal(suit1, suit2))
Esempio n. 6
0
def sort_clearings_by_matching_suit(clearings: list[Clearing],
                                    suit: Suit,
                                    descending: bool = True) -> list[Clearing]:
    return sorted(clearings,
                  key=lambda c: Suit.are_suits_equal(c.suit, suit),
                  reverse=descending)