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

Pet Translator #178

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

# Your pet should translate commands.

def onHear(event):
    # The message the pet heard is in event.message
    message = event.message
    # If the message is "North":
    if message == "North":
        # The pet says "Htron".
        pet.say("Htron")
    # If the message is "South":
    if message == "South":
        # The pet says "Htuos".
        pet.say("Htuos")
        pass
    # If the message is "East":
    if message =="East":
        # The pet says "Tsae".
        pet.say("Tsae")

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

while True:
    enemy = hero.findNearestEnemy()
    # Don't attack Brawlers.
    if enemy and enemy.type != "brawler":
        hero.attack(enemy)