# Follow me on youtube channel Phy Tu
# Help with programming on Python, school math, physics
# https://www.youtube.com/channel/UCP5ycahCEZ24qmRRgNnko5Q
# Accumulate 300 gold and escape from the dungeon.
def onSpawn(event):
# Send the pet to walk around the dungeon:
pet.moveXY(26, 55)
pet.moveXY(71, 57)
pet.moveXY(71, 11)
pet.moveXY(20, 11)
pet.moveXY(21, 36)
pet.moveXY(15, 36)
pet.moveXY(hero.pos.x-5, hero.pos.y)
# Don't forget to return it to the hero:
pass
pet.on("spawn", onSpawn)
while True:
# Guard peasants:
enemy=hero.findNearestEnemy()
if enemy:
if hero.isReady("cleave"):
hero.cleave(enemy)
if hero.isReady("chain-lightning"):
hero.cast("chain-lightning", enemy)
else:
hero.attack(enemy)
# When you have 300+ gold move to the red mark:
else:
hero.moveXY(23,34)
if hero.gold >=300:
break
hero.moveXY(50,34)