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

Chain of Command #169

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

# Only your pet can wake the wizard up.

def onHear(event):
    # "hear" events set the event.speaker property.
    # Check if the pet has heard the hero:
    if event.speaker == hero:
        pet.say("WOOF")

# Assign the event handler for "hear" event.
pet.on("hear", onHear)

while True:
    enemy = hero.findNearestEnemy()
    # If there is an enemy:
    if enemy:
        # Use hero.say() to alert your pet
        hero.say("Allert my pet")
        # Move to the X in the camp.
        hero.moveXY(30,33)
        # Then return to the X outside the camp.
        hero.moveXY(30,15)