Esempio n. 1
0
 def can_move_piece(self,
                    player: Player,
                    piece: Piece,
                    destination: Location,
                    requires_rule: bool = False) -> bool:
     # We'll never look for rule in move that isn't from one clearing to another clearing
     if requires_rule and isinstance(destination, Clearing):
         if not player.does_rule_clearing(
                 self) and not player.does_rule_clearing(destination):
             return False
     return super().can_move_piece(player, piece, destination,
                                   requires_rule)
Esempio n. 2
0
def sort_clearings_by_ruled_by_self(clearings: list[Clearing],
                                    acting_player: Player,
                                    descending: bool = True) -> list[Clearing]:
    return sorted(clearings,
                  key=lambda c: acting_player.does_rule_clearing(c),
                  reverse=descending)