code-combat Python 参考答案
mountain 安息之云山峰
borrowed-sword 借刀
https://codecombat.com/play/level/borrowed-sword?
- Solution a
while True:
friends = hero.findFriends()
for i in range(len(friends)):
friend = friends[i]
target = None
maxHealth = 0
enemyIndex = 0
enemies = hero.findEnemies()
while enemyIndex < len(enemies):
enemy = enemies[enemyIndex]
if enemy.health > maxHealth:
maxHealth = enemy.health
target = enemy
enemyIndex += 1
if target:
hero.command(friend, "attack", target)
- Solution b
while True:
enemies = hero.findEnemies()
highestHp = None
bestHealth= 0
for enemy in enemies:
if enemy.health