Skip to content

Instantly share code, notes, and snippets.

@ninjapanzer
Created October 15, 2015 13:34
Show Gist options
  • Select an option

  • Save ninjapanzer/fcc2140d6b933ab73d4b to your computer and use it in GitHub Desktop.

Select an option

Save ninjapanzer/fcc2140d6b933ab73d4b to your computer and use it in GitHub Desktop.
JSWarrior Stage 5
jsWarrior.turn = function(warrior) {
if(!warrior.healing && warrior.getHealth() < 8){
warrior.walk("backward")
warrior.healing = true;
} else if(warrior.check() == "enemy") {
warrior.attack();
} else if(warrior.check() == "diamond"){
warrior.collect();
} else if(warrior.getHealth() < 20 && warrior.healing ){
warrior.rest();
} else {
warrior.healing = false;
warrior.walk()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment