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

Sacred Grove #173

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

# Don’t let ogres step into the grove.

def onSpawn():
    while True:
        scout = pet.findNearestByType("scout")
        if scout and pet.isReady("charm"):
            pet.charm(scout)

# Assign the event handler to the pet's "spawn" event.
pet.on("spawn",onSpawn)
# Fight!
while True:
    enemy=hero.findNearestEnemy()
    if enemy:
        hero.attack(enemy)