コード例 #1
0
    def fightHordes(self, hordeA, hordeB):
        if near(hordeA,
                hordeB) < 2 * GB.APPROACH_DISTANCE and not hordeA is hordeB:
            print(hordeA)
            print(hordeB)
            while (not hordeA.allDead() and not hordeB.allDead()):
                hA_members = hordeA.getMembers()
                hB_members = hordeB.getMembers()
                fights_list = []
                longer = hA_members if len(hB_members) < len(
                    hA_members) else hB_members
                smaller = hB_members if len(hB_members) < len(
                    hA_members) else hA_members
                i = 0
                for i in range(0, len(longer)):
                    fight = [[smaller[i % len(smaller)]], [longer[i]]]
                    if len(fights_list) < len(smaller):
                        fights_list.append(fight)
                    else:
                        fights_list[i % len(smaller)][1].append(longer[i])

                for f in fights_list:
                    oppA = f[0]
                    oppB = f[1]
                    if len(oppA) < len(oppB):
                        oppA[0].receiveHit(oppA[0].getLife())
                    else:
                        self.fight(oppA[0], oppB[0], forceFight=True)

                hordeA.cleanDead()
                hordeB.cleanDead()
コード例 #2
0
    def fight(self, creatureA, creatureB, forceFight=False):
        if near(creatureA, creatureB) < GB.APPROACH_DISTANCE or forceFight:
            while (creatureA.getLife() > 0 and creatureB.getLife() > 0):

                cAh = creatureA.getHitForce()
                cBh = creatureB.getHitForce()
                creatureA.receiveHit(cBh)
                creatureB.receiveHit(cAh)
コード例 #3
0
 def doHorde(self, creatureA, creatureB, horde_list, this_day_horde_list):
     if near(creatureA, creatureB) < 2*GB.APPROACH_DISTANCE \
         and  \
         not creatureA in this_day_horde_list \
         and \
         not creatureB in this_day_horde_list \
         and not creatureA is creatureB :
         horde_list.append(Horde([creatureA, creatureB]))
         this_day_horde_list.append(creatureA)
         this_day_horde_list.append(creatureB)
コード例 #4
0
    def canTakeItem(self, creature, item):

        if (not item.isTaken()):
            distance = near(creature, item)
            if distance < GB.APPROACH_DISTANCE:
                item.take()
                if type(item) is Weapon:
                    if type(creature) is Orc:
                        creature.setStrength(creature.getStrength() +
                                             GB.WEAPON_EXTRA_STRENGTH_ORCS)
                    if type(creature) is Elf:
                        creature.setStrength(creature.getStrength() +
                                             GB.WEAPON_EXTRA_STRENGTH_ELVES)
                if type(item) is Amulet:
                    if type(creature) is Elf:
                        creature.setMagic(creature.getMagic() +
                                          GB.AMULET_EXTRA_MAGIC_ELVES)
                    if type(creature) is Orc:
                        creature.setMagic(creature.getMagic() +
                                          GB.AMULET_EXTRA_MAGIC_ORCS)
                if type(item) is Healer:
                    creature.heal()
コード例 #5
0
 def fightTroll(self, horde, troll):
     if near(horde, troll) < 2 * GB.APPROACH_DISTANCE:
         horde.setAllDead()
コード例 #6
0
 def mergeHordes(self, hordeA, hordeB):
     if near(hordeA,
             hordeB) < 2 * GB.APPROACH_DISTANCE and not hordeA is hordeB:
         hordeA.mergeWithHorde(hordeB)
コード例 #7
0
 def nearHorde(self, creature, distance):
     for c in self.__members:
         if near(c, creature) < distance:
             return True
     return False
コード例 #8
0
 def joinHorde(self, creature, distance):
     for c in self.__members:
         if near(c, creature) < distance:
             self.addMember(creature)
             return True
     return False