def add_unit_to_group(self, group: unitgroup.VehicleGroup, unit_type: Type[VehicleType], name: str, position: Point, heading: int) -> Vehicle: unit = Vehicle(self.game.next_unit_id(), f"{group.name}|{name}", unit_type.id) unit.position = position unit.heading = heading group.add_unit(unit) return unit
def add_unit_to_group( self, group: VehicleGroup, unit_type: Type[VehicleType], name: str, position: Point, heading: int, ) -> Vehicle: unit = Vehicle(self.game.next_unit_id(), f"{group.name}|{name}", unit_type.id) unit.position = position unit.heading = heading group.add_unit(unit) # get price of unit to calculate the real price of the whole group try: ground_unit_type = next(GroundUnitType.for_dcs_type(unit_type)) self.price += ground_unit_type.price except StopIteration: logging.error(f"Cannot get price for unit {unit_type.name}") return unit