Пример #1
0
    def achieve_mission_loot(self):
        target = self.get_target()
        opponents = target.inhabitants
        if target.position_id <> self.group.position_id:
            self.group.log_report(
                type=1,
                subject="Votre attaque n’a pas abouti",
                body="La cible n'était pas à l'endroit prévu",
            )
            return
        combat = Combat(self.group, opponents)
        success = combat.is_attacker_winner()

        self.group.log_report(
                type=1,
                subject='Votre attaque a bien eu lieu',
                body=combat.report,
                )
        target.log_report(
                type=1,
                subject='Votre attaque a échoué lamentablement',
                body=combat.report,
                )

        #FIXME optimize sql requests
        for unittype in combat.attack_deads:
            stack = self.group.unitstack_set.get(unit_type=unittype)
            stack.kill_guys(combat.attack_deads[unittype])
        for unittype in combat.defense_deads:
            stack = opponents.unitstack_set.get(unit_type=unittype)
            stack.kill_guys(combat.defense_deads[unittype])

        if success:
            self.group.steal(target)
            opponents.flee()
 #           if target.units_number() == 0:
 #               target.delete()
 #           else:
 #               target.flee()
 #           self.come_back()
            return
        elif success is None:
            if opponents.units_number() == 0:
                opponents.delete()
            if self.group.units_number() == 0:
                self.group.delete()
            else:
                self.come_back()
            return
        else:
            target.steal(self.group)
            if self.group.units_number() == 0:
                self.group.delete()
            else:
                self.group.flee()
            return
Пример #2
0
    def achieve_mission_attack(self):
        target = self.get_target()
        if target.position_id <> self.group.position_id:
            self.group.log_report(
                type=1,
                subject="Votre attaque n’a pas abouti",
                body="La cible n'était pas à l'endroit prévu",
            )
            return
        combat = Combat(self.group, target)
        success = combat.is_attacker_winner()

        self.group.log_report(
                type=1,
                subject='Votre attaque a été menée à bien',
                body=combat.report,
                )
        target.log_report(
                type=1,
                subject='Votre groupe a été attaqué',
                body=combat.report,
                )

        #FIXME optimize sql requests
        for unittype in combat.attack_deads:
            stack = self.group.unitstack_set.get(unit_type=unittype)
            stack.kill_guys(combat.attack_deads[unittype])
        for unittype in combat.defense_deads:
            stack = target.unitstack_set.get(unit_type=unittype)
            stack.kill_guys(combat.defense_deads[unittype])

        if success:
            self.group.steal(target)
            if target.units_number() == 0:
                target.delete()
            else:
                target.flee()
            self.come_back()
            return
        elif success is None:
            if target.units_number() == 0:
                target.delete()
            if self.group.units_number() == 0:
                self.group.delete()
            else:
                self.come_back()
            return
        else:
            target.steal(self.group)
            if self.group.units_number() == 0:
                self.group.delete()
            else:
                self.group.flee()
            return