AlexeySapsay / Python_solution_CodeCombat_2018

In that repository I will post my sollution for codecombat.com games for study Python
1 stars 0 forks source link

Sand Mushrooms #120

Open AlexeySapsay opened 6 years ago

AlexeySapsay commented 6 years ago
# Follow me on youtube  channel Phy Tu
# Help with programming on Python, school math, physics
# https://www.youtube.com/channel/UCP5ycahCEZ24qmRRgNnko5Q

# Collect 9 mushrooms.

# This function makes the pet fetch potions for you.
def onSpawn(event):
    while True:
        # Pets can find the nearest item by its type.
        potion = pet.findNearestByType("potion")
        # Make the pet fetch the potion if it exists:
        pet.fetch(potion)

pet.on("spawn", onSpawn)

# Mushrooms are toxic, don't collect them too quickly.
while True:
    someItem = hero.findNearestItem()
    if someItem and hero.health > hero.maxHealth / 3:
        # Collect the someItem:
        hero.moveXY(someItem.pos.x,someItem.pos.y)
        pass