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

Preferential Treatment #150

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

# First, loop through all enemies...

enemies = hero.findEnemies()
enemyIndex = 0
# ... but only attack "thrower" type enemies.
while enemyIndex < len(enemies):
    enemy = enemies[enemyIndex]
    if enemy and enemy.type == "thrower":
        hero.attack(enemy)
    enemyIndex += 1
# Then loop through all the enemies again...
enemies = hero.findEnemies()
enemyIndex = 0
# ... and defeat everyone who's still standing.
while enemyIndex<len(enemies):
    enemy=enemies[enemyIndex]
    if enemy:
        hero.attack(enemy)
    enemyIndex+=1