示例#1
0
    def _generate_fight_at(self, attackers: db.ArmorDict,
                           defenders: db.ArmorDict, position: Point):
        if attackers:
            attack_pos = position.point_from_heading(
                self.conflict.heading - 90, FIGHT_DISTANCE)
            attack_dest = position.point_from_heading(
                self.conflict.heading + 90, FIGHT_DISTANCE * 2)
            for type, count in attackers.items():
                self._generate_group(
                    side=self.conflict.attackers_side,
                    unit=type,
                    count=count,
                    at=attack_pos,
                    to=attack_dest,
                )

        if defenders:
            def_pos = position.point_from_heading(self.conflict.heading + 90,
                                                  FIGHT_DISTANCE)
            def_dest = position.point_from_heading(self.conflict.heading - 90,
                                                   FIGHT_DISTANCE * 2)
            for type, count in defenders.items():
                self._generate_group(
                    side=self.conflict.defenders_side,
                    unit=type,
                    count=count,
                    at=def_pos,
                    to=def_dest,
                )
示例#2
0
    def generate(self, attackers: db.ArmorDict, defenders: db.ArmorDict):
        for type, count in attackers.items():
            self._generate_group(side=self.conflict.attackers_side,
                                 unit=type,
                                 count=count,
                                 at=self.conflict.ground_attackers_location)

        for type, count in defenders.items():
            self._generate_group(side=self.conflict.defenders_side,
                                 unit=type,
                                 count=count,
                                 at=self.conflict.ground_defenders_location)
示例#3
0
 def generate_convoy(self, units: db.ArmorDict):
     for type, count in units.items():
         self._generate_group(side=self.conflict.defenders_side,
                              unit=type,
                              count=count,
                              at=self.conflict.ground_defenders_location,
                              to=self.conflict.position,
                              move_formation=PointAction.OnRoad)
示例#4
0
    def generate_vec(self, attackers: db.ArmorDict, defenders: db.ArmorDict):
        fights_count = randint(*FRONTLINE_CAS_FIGHTS_COUNT)
        single_fight_defenders_count = min(
            int(sum(defenders.values()) / fights_count),
            randint(*FRONTLINE_CAS_GROUP_MIN))
        defender_groups = list(
            db.unitdict_split(defenders, single_fight_defenders_count))

        single_fight_attackers_count = min(
            int(sum(attackers.values()) / len(defender_groups)),
            randint(*FRONTLINE_CAS_GROUP_MIN))
        attacker_groups = list(
            db.unitdict_split(attackers, single_fight_attackers_count))

        for attacker_group_dict, target_group_dict in zip_longest(
                attacker_groups, defender_groups):
            position = self.conflict.position.point_from_heading(
                self.conflict.heading, random.randint(0,
                                                      self.conflict.distance))
            self._generate_fight_at(attacker_group_dict, target_group_dict,
                                    position)