def process(self, powerPopulation, buildingPopulation, terrain): Creature.process(self, powerPopulation, buildingPopulation, terrain) self.lastAttack += TIME_QUANTUM if(self.lastAttack > self.attackSpeed): for i in range(3): for j in range(3): thing = terrain.getThingOcupying(self.x+i-1,self.y+j-1) if(isinstance(thing, Creature) or isinstance(thing, Building)): if(thing.getTeam() != self.team and thing.isAlive()): thing.damage(random.randint(0, self.attack)) self.lastAttack = 0 return if(self.moving == False): self.moveEvil(terrain)
def process(self, powerPopulation, buildingPopulation, terrain): Creature.process(self, powerPopulation, buildingPopulation, terrain) self.buildTime += TIME_QUANTUM if(self.repair(terrain) == False): if(self.buildTime > PEASANT_BUILD_INTERVAL): self.buildTime = 0 if(random.randint(0,100) < PEASANT_BUILD_CHANCE): self.buildRandomBuilding(buildingPopulation, terrain) else: if(self.moving == False): self.moveEvil(terrain) #self.movePurposefully(terrain, buildingPopulation) else: if(self.moving == False): self.moveEvil(terrain)
def process(self, powerPopulation, buildingPopulation, terrain): Creature.process(self, powerPopulation, buildingPopulation, terrain) self.lastAttack += TIME_QUANTUM if(self.lastAttack > self.attackSpeed): for i in range(7): for j in range(7): thing = terrain.getThingOcupying(self.x+i-3,self.y+j-3) '''If there is a creature near by that's an enemy''' if(isinstance(thing, Creature)): if(thing.getTeam() != self.team and thing.isAlive()): '''move towards it''' powerPopulation.addPower(Lightning(self.x, self.y, random.randint(0, self.attack), thing)) self.lastAttack = 0 return if(self.moving == False): self.moveEvil(terrain)