# You are trapped. Don't move, it'll be painful.
# This function checks if the enemy is in your attack range.
distance = hero.distanceTo(enemy)
# Almost all swords have attack range of 3.
if distance <= 3:
# Attack ogres only when they're within reach.
# 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 hero == inAttackRange(enemy):
# If the result stored in canAttack is True, then attack!
if inAttackRange == true:
that’s my code and I just don’t understand the level that much
could someone help me understand it beter
Did you even start rlly -_0
capitalize true everywhere, remove pass, use <= 2 so its a guaranteed hit, as munchkins can move. If you have the longsword, you can increase the distance
also you have not made the variable canAttack so change your code to
canAttack = inAttackRange(enemy)
try listening to the blue comments. if you are still stuck, use hints, they are there for free and unlimited. finally ask the forums
read the link too please as you are a new user
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!
This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.