Beispiel #1
0
    def scramble_count(self, multiplier: float, task: Task = None) -> int:
        if task:
            count = sum([
                v for k, v in self.aircraft.items() if db.unit_task(k) == task
            ])
        else:
            count = self.total_planes

        count = int(math.ceil(count * PLANES_SCRAMBLE_FACTOR * self.strength))
        return min(
            min(max(count, PLANES_SCRAMBLE_MIN_BASE),
                int(PLANES_SCRAMBLE_MAX_BASE * multiplier)), count)
Beispiel #2
0
    def commision_units(self, units: typing.Dict[typing.Any, int]):
        for value in units.values():
            assert value > 0
            assert value == math.floor(value)

        for unit_type, unit_count in units.items():
            for_task = db.unit_task(unit_type)

            target_dict = None
            if for_task == CAS or for_task == CAP or for_task == Embarking:
                target_dict = self.aircraft
            elif for_task == PinpointStrike:
                target_dict = self.armor
            elif for_task == AirDefence:
                target_dict = self.aa

            assert target_dict is not None
            target_dict[unit_type] = target_dict.get(unit_type, 0) + unit_count
Beispiel #3
0
    def commision_units(self, units: typing.Dict[typing.Any, int]):

        for unit_type, unit_count in units.items():
            if unit_count <= 0:
                continue

            for_task = db.unit_task(unit_type)

            target_dict = None
            if for_task == CAS or for_task == CAP or for_task == Embarking:
                target_dict = self.aircraft
            elif for_task == PinpointStrike:
                target_dict = self.armor
            elif for_task == AirDefence:
                target_dict = self.aa

            if target_dict is not None:
                target_dict[unit_type] = target_dict.get(unit_type, 0) + unit_count
            else:
                logging.error("Unable to determine target dict for " + str(unit_type))