Beispiel #1
0
def test_should_return_false_when_a_ship_took_less_hits_than_its_length(
        hits_taken: int):
    ship = Ship("destroyer", 3)

    ship.hits_taken = hits_taken

    assert not is_ship_destroyed(ship)
Beispiel #2
0
def has_all_ships_destroyed(board: Board2D) -> bool:
    return all(is_ship_destroyed(ship) for ship in board.ships)
Beispiel #3
0
 def remaining_ships(self) -> List[str]:
     return [
         ship.kind for ship in self.board.ships
         if not is_ship_destroyed(ship)
     ]
Beispiel #4
0
def has_destroyed_ship_on_position(board: Board2D, position: Position) -> bool:
    affected_ship = board.ship_at(position)
    increase_ship_hits_taken(affected_ship)
    return is_ship_destroyed(affected_ship)