Remove error handling for impossible case.

This commit is contained in:
Dan Albert 2022-09-11 17:45:22 -07:00
parent c39a094d88
commit bbfe1657d6
2 changed files with 20 additions and 29 deletions

View File

@ -1,6 +1,5 @@
from __future__ import annotations from __future__ import annotations
import logging
import math import math
import random import random
from typing import List, Optional, TYPE_CHECKING, Tuple from typing import List, Optional, TYPE_CHECKING, Tuple
@ -203,9 +202,6 @@ class FlotGenerator:
forward_heading, forward_heading,
self.conflict.theater, self.conflict.theater,
) )
if not infantry_position:
logging.warning("Could not find infantry position")
return
faction = self.game.faction_for(is_player) faction = self.game.faction_for(is_player)
@ -691,7 +687,7 @@ class FlotGenerator:
def get_valid_position_for_group( def get_valid_position_for_group(
self, distance_from_frontline: int, spawn_heading: Heading self, distance_from_frontline: int, spawn_heading: Heading
) -> Point | None: ) -> Point:
assert self.conflict.heading is not None assert self.conflict.heading is not None
assert self.conflict.size is not None assert self.conflict.size is not None
shifted = self.conflict.position.point_from_heading( shifted = self.conflict.position.point_from_heading(
@ -733,30 +729,27 @@ class FlotGenerator:
distance_from_frontline, spawn_heading distance_from_frontline, spawn_heading
) )
if final_position is not None: g = self._generate_group(
g = self._generate_group( is_player,
self.mission.country(country),
group.unit_type,
group.size,
final_position,
heading=spawn_heading.opposite,
)
if is_player:
g.set_skill(Skill(self.game.settings.player_skill))
else:
g.set_skill(Skill(self.game.settings.enemy_vehicle_skill))
positioned_groups.append((g, group))
if group.role in [CombatGroupRole.APC, CombatGroupRole.IFV]:
self.gen_infantry_group_for_group(
g,
is_player, is_player,
self.mission.country(country), self.mission.country(country),
group.unit_type, spawn_heading.opposite,
group.size,
final_position,
heading=spawn_heading.opposite,
) )
if is_player:
g.set_skill(Skill(self.game.settings.player_skill))
else:
g.set_skill(Skill(self.game.settings.enemy_vehicle_skill))
positioned_groups.append((g, group))
if group.role in [CombatGroupRole.APC, CombatGroupRole.IFV]:
self.gen_infantry_group_for_group(
g,
is_player,
self.mission.country(country),
spawn_heading.opposite,
)
else:
logging.warning(f"Unable to get valid position for {group}")
return positioned_groups return positioned_groups

View File

@ -68,8 +68,6 @@ class FrontLineConflictDescription:
attack_heading.right, attack_heading.right,
theater, theater,
) )
if position is None:
raise RuntimeError("Could not find front line position")
return position, attack_heading.opposite return position, attack_heading.opposite
@classmethod @classmethod
@ -142,7 +140,7 @@ class FrontLineConflictDescription:
max_distance: int, max_distance: int,
heading: Heading, heading: Heading,
theater: ConflictTheater, theater: ConflictTheater,
) -> Optional[Point]: ) -> Point:
"""Finds a valid ground position for the front line center. """Finds a valid ground position for the front line center.
Checks for positions along the front line first. If none succeed, the nearest Checks for positions along the front line first. If none succeed, the nearest