# Use your new skill to choose what to do: hero.time
while True:
enemy = hero.findNearestEnemy()
# If it's the first 10 seconds, attack.
if hero.time < 10:
cleaver = hero.isReady("cleave")
if enemy and cleaver:
hero.cleave(enemy)
else:
hero.attack(enemy)
pass
# Else, if it's the first 35 seconds, collect coins.
elif hero.time < 35:
coin = hero.findNearestItem()
if coin:
hero.moveXY(coin.pos.x, coin.pos.y)
pass
elif hero.health < hero.maxHealth / 4:
PosX = hero.pos.x - 20
PosY = hero.pos.y
hero.moveXY(PosX, PosY)
# After 35 seconds, attack again!
else:
Palisades = hero.findEnemies()
enemy = hero.findNearestEnemy()
for "palisade" in Palisades:
if enemy.type != "palisade":
hero.attack(enemy)
pass```
What is wrong with my code? I get this error, "cannot read 'property' of start undefined
I figured it out myself. Had to:
if hero.time < 10:
Palisades = hero.findEnemies()
hero.findNearest(Palisades)
cleaver = hero.isReady("cleave")
if enemy and cleaver:
hero.cleave(enemy)
elif enemy and enemy.type != "palisade":
hero.attack(enemy)
pass