hit and freeze 这关怎么破,求助。
codecombat吧
全部回复
仅看楼主
level 2
kilan790 楼主
特别是那
if the result stored in canattack is true.
那个代码怎么破。
2016年12月22日 06点12分 1
level 1
# 你掉进陷阱里了!别动!你会受伤的!
# 这个函数检查敌人是否再攻击范围。
def inAttackRange(enemy):
distance = hero.distanceTo(enemy)
# Almost all swords have attack range of 3.
if distance <= 3:
return True
else:
return False
# Attack ogres only when they're within reach.
while True:
# 找到最近的敌人,并将其储存在一个变量中。
enemy = hero.findNearestEnemy()
# 调用 inAttackRange(enemy),将 enemy 作为参数
# 把结果保存于 “canAttack” 变量中
canAttack = inAttackRange(enemy)
# If the result stored in canAttack is True, 然后下手!
if canAttack:
hero.attack(enemy)
pass
2017年01月10日 14点01分 2
1