Im normally not the one to ask for help but this has been at my plate and I need to get on track because I’ve been on this for 2 weeks and I will have a 0 as my major in the grade book so this is urgent it due in 5 days and basically what is happening is I try to get a lot of coins but as I get coins the enemies come out and its like my character only knows how to fight as it sees an emeny and for some reason start to kill the enemies and doesn’t grab coins in the process and dies trying to fight. I’m stuck and there is absolutely no errors in my code. Here is my code and this is a photo of what happens right before I die and this is my hero inventory
# http://codecombat.com/play/level/vital-powers
def pickUpNearestCoin():
items = hero.findItems()
nearestCoin = hero.findNearest(items)
if nearestCoin and hero.distanceTo(nearestCoin) < 30:
if hero.isReady("jump"):
hero.jumpTo(nearestCoin.pos)
else:
hero.move(nearestCoin.pos)
def summonSoldier():
if hero.gold > hero.costOf("soldier"):
hero.summon("soldier")
def commandSoldiers():
for soldier in hero.findFriends():
enemy = soldier.findNearestEnemy()
if enemy:
hero.command(soldier, "attack", enemy)
def attack(target):
if target:
if (hero.isReady("jump") and hero.distanceTo > 10):
hero.jumpTo(target.pos)
elif (hero.isReady("bash")):
hero.bash(target)
elif (hero.canCast('chain-lightning', target)):
hero.cast('chain-lightning', target)
else:
hero.attack(target)
def tacktick():
enemies = hero.findEnemies()
nearest = hero.findNearest(enemies)
friends = hero.findFriends()
if nearest and (hero.distanceTo(nearest) < 10 or hero.now() > 25):
attack(nearest)
elif nearest and len(friends) / 3 < len(enemies):
attack(nearest)
else:
pickUpNearestCoin()
while True:
(tacktick)
summonSoldier()
commandSoldiers()
while True: