Created
October 15, 2015 13:34
-
-
Save ninjapanzer/fcc2140d6b933ab73d4b to your computer and use it in GitHub Desktop.
JSWarrior Stage 5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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