# Follow me on youtube channel Phy Tu
# Help with programming on Python, school math, physics
# https://www.youtube.com/channel/UCP5ycahCEZ24qmRRgNnko5Q
# You only have 20 seconds until the ogre horde arrives!
# Grab as much gold as you can, then retreat to your base and wall it off!
while (hero.time < 20) or (hero.gold<60):
# Collect coins
hero.say("I should pick up a coin")
items = hero.findItems()
for item in items:
if item.value==3 or item.value==2:
hero.moveXY(item.pos.x,item.pos.y)
# Build a fence to keep the ogres out.
while hero.time>22:
hero.moveXY(15,37)
hero.buildXY("fence",21,38)