Hello everybody!
As I understand this level, just fulfilling the functions as in the previous level it should win. I tried but a lot of ogres appear and my soldiers can not beat them. I tried to add a function attacking the enemies if they are more than 10 but even like that too many appear. Does it mean that I need to improve my equipment? or am I doing something wrong?
Here my code:
def summonSoldiers():
if self.gold >= self.costOf("soldier"):
self.summon("soldier")
# Define the function: commandSoldiers
def commandSoldiers():
peasant = self.findByType("peasant")[0]
friends=self.findFriends()
for friend in friends:
if friend.type != 'peasant':
enemies= peasant.findEnemies()
if enemies:
for enemy in enemies:
self.command(friend, "attack", enemy)
# Define the function: pickUpNearestCoin
def pickUpNearestCoin():
coin=self.findNearest(self.findItems())
self.moveXY(coin.pos.x, coin.pos.y)
peasant = self.findByType("peasant")[0]
def attackmalos():
malos=self.findEnemies()
if len(malos)>10:
for malo in malos:
if self.isReady("bash"):
self.bash(malo)
else if self.canElectrocute(malo):
self.electrocute(malo)
else:
self.attack(malo)
loop:
summonSoldiers()
commandSoldiers()
pickUpNearestCoin()
attackmalos()
Thanks in advance