You wake up in a strange corridor. There's a sign at the end of the hallway. Walk over to it.
JSWarrior is a turn based game. You make one action (moving, attacking, etc) each turn by making decisions with code you write in the jsWarrior.turn function.
Call warrior.walk() to walk forward in the jsWarrior.turn function.
Note: The code required to complete this level is already filled up, to give you an idea of how to use it. Just Click Run to see it in action!
The game is played in turns. At every turn, the jsWarrior.turn is executed to determine what action the warrior will take. It's your responsibility to define the behavior using this function.
An action is something that the warrior can do. You can perform one action per turn
| Function | Description |
|---|---|
|
Walks in the direction the warrior is currently facing. Use |
|
Attack one step in the direction that you're facing. An attack deals 5 points of damage. |
|
Rest for the turn and gain 2 points of health. |
|
Turn around and face the other direction. |
|
Collect a diamond if it's there one step in the direction that you're facing. |
You can check to see what lies in your immediate surroundings. Simply call warrior.check() to see what's in the next step, in the direction you're facing, and warrior.check('backward') to see what's behind you. The function returns a string, and the possible values are:
| String | Description |
|---|---|
|
Nothing in the next cell |
|
An enemy in the next cell |
|
A gem that you can collect. |
|
A wall of the room |
| Name | Description |
|---|---|
Crab |
A small animal with a meelee attack. |
Troll |
A much stronger enemy with a more powerful meelee attack |
JavaLiner |
A frustrated developer who hates jsWarrior. Throws JavaLins at you from a distance. Has a limited range. |