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

Mad Maxer Strikes Back #183

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

# The smaller ogres here do more damage!
# Attack the ogres with the least health first.
while True:
    weakest = None
    leastHealth = 99999
    enemyIndex = 0
    enemies = hero.findEnemies()

    # Loop through all enemies.
    for enemy in enemies:
        # If an enemy's health is less than leastHealth,
        if enemy.health<leastHealth:
            # make it the weakest and set leastHealth to its health.
            weakest=leastHealth
        #  Don't forget to increase enemyIndex by 1.
        enemyIndex+=1
    if weakest:
        # Attack the weakest ogre.
        hero.attack(enemies[enemyIndex-1])
        pass