コード例 #1
0
    def testShieldDefenceArcherFire(self):
        self.disableRandomChoice(True)
        shooter = self.createUnit(weaponType=self.TYPE_WEAPON_BOW,
                                  damage=100,
                                  agility=60)
        target = self.createUnit(armorType=self.TYPE_ARMOR_LEATHER,
                                 shieldType=self.TYPE_SHIELD_WOOD,
                                 shieldDurability=1000,
                                 shieldBlocking=50,
                                 agility=30,
                                 health=500)

        Actions.archerFire(shooter, target, 1)

        self.assertEqual(target.shieldDurability, 900)
コード例 #2
0
ファイル: group.py プロジェクト: Zerstoren/honor-of-nation
    def archersFire(self, targetFront, bonus):
        """
        :type targetFront: battle.structure.front.Front
        :return:
        """
        log.group('`%s` %i archers fire for enemy `%s`' %
                  (self.it, len(self.range), targetFront.it))

        for archer in self.range:
            if not archer.steps >= 10:
                continue

            shoots = int(archer.steps / 10)
            archer.steps %= 10

            log.unit('`%s` create archery shoots %i' % (archer.it, shoots))
            for i in range(shoots):
                group = targetFront.getRandomGroup()
                if group.getCount() == 0:
                    break

                target = group.getRandomUnit()

                log.unit('`%s` shoot to enemy `%s`' % (archer.it, target.it))
                if Actions.archerFire(archer, target,
                                      bonus) and target.health <= 0:
                    log.unit('`%s` archer killed enemy `%s`' %
                             (archer.it, target.it))
                    group.removeUnit(target)
コード例 #3
0
    def testArcherFire(self):
        self.disableRandomChoice(True)
        shooter = self.createUnit(weaponType=self.TYPE_WEAPON_BOW,
                                  damage=100,
                                  agility=60)
        target = self.createUnit(armorType=self.TYPE_ARMOR_LEATHER,
                                 agility=30,
                                 health=500)

        self.assertTrue(Actions.archerFire(shooter, target, 1))
        self.assertEqual(target.health, 395)