How can I do without a Paladin in the Restless Dead Level?
Where do I go wrong in my code?
summonTypes = ['soldier']
def attack(enemy):
if enemy:
while (enemy.health > 0):
if (hero.distanceTo(enemy) > 10):
hero.move(enemy.pos)
elif hero.isReady("bash"):
hero.bash(enemy)
elif hero.canCast('chain-lightning', enemy):
hero.cast('chain-lightning', enemy)
elif hero.isReady("warcry"):
hero.warcry()
else:
hero.attack(enemy)
def summonTroops():
type = summonTypes[len(hero.built) % len(summonTypes)]
if hero.gold > hero.costOf(type):
hero.summon(type)
def commandTroops():
for i, friend in enumerate(hero.findFriends()):
if friend.type == 'soldier':
Command(friend)
def Command(friend):
enemy = friend.findNearestEnemy()
if friend.type == "soldier":
hero.command(friend, "attack", enemy)
def collectItems():
item = hero.findNearestItem()
while item:
hero.move(item.pos)
item = hero.findNearestItem()
hero.moveXY(55, 10)
hero.wait(2)
attack(hero.findNearestEnemy())
collectItems()
hero.moveXY(55, 33)
hero.moveXY(49, 37)
hero.moveXY(19, 40)
hero.moveXY(55, 48)
for i in range(1, 20):
summonTroops()
commandTroops()
while True:
attack(hero.findNearestEnemy())
commandTroops()
collectItems()