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

Mushroom Noise #122

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

# Defeat the skeleton and open the chest.

def onSpawn (event):
    # Pet should find the health potion (type is "potion"): 
    potion=pet.findNearestByType("potion")
    # and fetch it:
    if potion.type=="potion":
        pet.fetch(potion)
    # Pet should find the gold key (type is "gold-key"):
    goldKey=pet.findNearestByType("gold-key")
    if goldKey.type=="gold-key":
    # and fetch it:
        pet.fetch(goldKey)
        pass

# Pet can find more than just items:
skeleton = pet.findNearestByType("skeleton")
pet.on("spawn", onSpawn)

while True:
    if skeleton.health > 0:
        hero.attack(skeleton)
    else:
        hero.moveXY(31, 38)