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 Adjutant #181

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 can help you survive until you can escape.

def onHear(event):
    # event.message contains the text that was heard.
    # If somebody said "Fire"
    if event.message == "Fire":
        # Move to the bottom X mark with pet.moveXY()
        pet.moveXY(64,16)
        # Say something with pet.say()
        pet.say("Take it")
        pass
    # If somebody said "Heal"
    elif event.message == "Heal":
        # Move to the top X mark with pet.moveXY()
        pet.moveXY(63,53)

        # Say something with pet.say()
        pet.say(" You will be alive")
        pass

pet.on("hear", onHear)

# You don't have to change the code below.
while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        # If an enemy is too strong.
        if enemy.type == "brawler":
            hero.say("Fire")
        else:
            hero.attack(enemy)
    else:
        # If your hero needs healing.
        if hero.health < hero.maxHealth / 2:
            hero.say("Heal")