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

Alchemic Power #179

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

# Wait for alchemist's commands to fetch potions.

# The event handler for the pet's event "hear".
def onHear(event):
def waitingDelivery(event):
    potion = pet.findNearestByType("potion")
    if event.message == 'Fetch':
        pet.fetch(potion)
    else:
        pet.moveXY(55, 35)

pet.on("hear", waitingDelivery)
while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        hero.attack(enemy)
    else:
        hero.moveXY(40, 35)