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

Dangerous Key #182

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

# Listen to the paladin and fetch the right key.

def onHear(event):
    # The pet can find the paladin and keys.
    paladinUnit = pet.findNearestByType("paladin")
    goldKey = pet.findNearestByType("gold-key")
    silverKey = pet.findNearestByType("silver-key")
    bronzeKey = pet.findNearestByType("bronze-key")
    # If event.speaker is paladinUnit:
    if event.speaker==paladin:
        # If event.message is "Gold":
        if enent.message==Gold:
            # The pet should fetch the gold key.
            pet.fetch(goldKey)
        # If event.message is "Silver":
        if event.message==Silver:
            # The pet should fetch the silver key.
            pet.fetch(silverKey)
        # If event.message is "Bronze":
        if event.message==Bronze:
            # The pet should fetch the bronze key.
            pet.fetch(bronzeKey)

pet.on("hear", onHear)