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

Marauder #148

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

# Destroy mechs and collect gold from them.
coinNumber=0
while True:
    coin = hero.findNearest(hero.findItems())
    # While a coin exists:
    while coin:

        # Move to the coin.
        hero.moveXY(coin.pos.x,coin.pos.y)
        coin = hero.findNearest(hero.findItems())
        # Reassign the coin variable to the nearest item.
        coinNumber+=1
    enemy = hero.findNearestEnemy()
    if enemy:
        # While enemy's health is greater than 0.
        while enemy.health>0:
            # Attack enemy.
            hero.attack(enemy)
        pass