Skip to content

Instantly share code, notes, and snippets.

@grantroot
Created March 18, 2014 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grantroot/9623717 to your computer and use it in GitHub Desktop.
Save grantroot/9623717 to your computer and use it in GitHub Desktop.
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