How does this work?


Just want the code? Find it in our GitHub repo!
Or, you can check out the JS file directly.
Read the license for this game (MIT).

Basic idea

You are the fighter. They are the enemy. That's the objective.
Pick a name and beat as many enemies as you can (with some strategy, of course) before losing all your health.

What can you do?

During your encounters, you have four available options to choose from:

  1. Sword [1]
  2. Shield [2]
  3. Blaster [3]
  4. Heal [4]
The number in square brackets is the key you can press to activate each ability.

Detailed game mechanics and calculations

Ability information table
Action Energy cost Attack damage Special effects
Sword 10 20 N/A
Shield 0 0 Recovers 5 energy and quarters enemy damage.
Blaster 30 25 Decreases enemy accuracy and halves enemy damage.
Heal 10 0 Heals 5 health and blocks enemy attack.

Enemy stats per level
Enemy level Enemy health Enemy attack damage Enemy accuracy (rounded)
1 10 [3, 18] 91.67%
2 20 [6, 21] 83.33%
3 30 [9, 24] 75.00%
4 40 [12, 27] 66.67%
5 50 [15, 30] 58.33%
6 60 [18, 33] 50.00%
7 70 [21, 36] 41.67%
8 80 [24, 39] 33.33%
9 90 [27, 42] 25.00%
10 100 [30, 45] 16.67%

Player health

Player health is set at the beginning of the game to "100". It will decrease from enemies' attacks until it reaches zero, which is game over.
After each defeated foe, you regain 40 health (to a maximum of 100).

Player energy

Player energy, like health, is set to "100" at the beginning. It decreases with every ability the player uses (except shield, which recovers energy).
Without energy, the player cannot do any action except shield.
After each defeated foe, you regain 60 energy (to a maximum of 100).

Enemy level

The foe's level ("lvl.") is determined using a random number generator that creates an integer between 1 and 10.
Many other calculations rely on this determined number, which changes after each time you defeat the previous enemy.

Enemy attack damage

The enemy's attack damage is a range that changes based on the level of the enemy.
The other elements that affect this are the blaster and shield abilities.

Enemy accuracy

The enemy's accuracy is a function of their level, such that:
accuracy = -(lvl/12) + 1
Excepting, of course, the blaster ability, which alters it to:
accuracy = -(lvl/24) + 0.6

Score

Your score is the sum of the levels of all the enemies you defeat.

Disclaimers and terms

This game is licensed under MIT.
In short, you can copy, edit, distribute, etc. the code for this game as you wish, assuming it is under the same license, with proper attribution to Jacob Alfahad and with no liability to Jacob Alfahad for damages or other inconveniences.
For commercial purposes, please contact Jacob Alfahad.
All data saved on this site (your score and username, only when you permit) are non-identifiable and are not shared with any third-party.