Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
jsWarrior.turn = function(warrior) {
if(warrior.check() == "enemy") {
warrior.attack();
}
else {
warrior.lastHealth = warrior.getHealth();
while(warrior.lastHealth < 20) {
warrior.rest();
if(warrior.getHealth() < warrior.lastHealth + 2) {
break;
}
warrior.lastHealth = warrior.lastHealth + 2;
}
warrior.walk();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.