The link above is the level I’m getting trouble with.
points = [{'x':22, 'y':109}, {'x':129, 'y':109}, {'x':132, 'y':27}, {'x':23, 'y':22}]
index = 0
while True:
enemy = hero.findNearestEnemy()
if enemy:
hero.attack(enemy)
hero.move(points[index % len(points)]
if hero.pos.x == points[index % len(points)].x and hero.pos.y == points[index % len(points)].y:
index += 1
This is my code. I got error message at line 9, which says “Unexpected token: expected T_NAME but found T_COLON while parsing test”. My code worked fine on other levels tho. Why is this happening?
def inAttackRange(enemy):
distance = hero.distanceTo(enemy)
# Almost all swords have attack range of 3.
if distance <= 3:
return True
else:
return False
pass
def canAttack:
canAttack == inAttackRange(target)
if inAttackRange(target) = True:
return True
else:
return False
pass
Attack ogres only when they’re within reach.
while True:
# Find the nearest enemy and store it in a variable.
enemy = hero.findNearestEnemy()
# Call inAttackRange(enemy), with the enemy as the argument
# and save the result in the variable canAttack
# If the result stored in canAttack is True, then attack!
if canAttack == True:
hero.attack(enemy)
pass
This code has T_colon,can someone explain this pls
Hello and welcome to codecombat discourse! This is a cozy forum where you can share ideas, share fan art, get assistance for code, etc! Before you proceed, we hope that you review this topic, which shows all essentials of this board! Thanks!