Launching the game: https://liaksej.github.io/ajs-diplom/
A two-dimensional fantasy game where the player has to pit their characters vs. characters of the undead. Each round restores the lives of the surviving characters. of the player's surviving characters and level up. The maximum level is 4.
The game can be saved and restored from a save.
Key Entities:
- GamePlay - class responsible for interaction with HTML-page
- GameController - class responsible for the application logic
- Character - base class from which characters are inherited
- GameState - object that stores the current state of the game (can recreate itself from another object)
- GameStateService - object that interacts with the current state (saves data to localStorage for later loading)
- PositionedCharacter - Character bound to a coordinate on the field
- Team - a class for a team (a set of characters) representing the computer and the player
- generators - module containing auxiliary functions for generating team and characters
There are 4 levels in the game:
- Level 1: prairie
- Level 2: desert
- Level 3: arctic
- Level 4: mountain
- Bowman
- Swordsman
- Magician
- Vampire
- Undead
- Daemon
Class | attack | defence |
---|---|---|
Bowman | 25 | 25 |
Swordsman | 40 | 10 |
Magician | 10 | 40 |
Vampire | 25 | 25 |
Undead | 40 | 10 |
Daemon | 10 | 10 |
When you move the cursor over a character, information about that character appears.
-
If we are going to select another character, the field is not highlighted and the cursor takes the shape of
pointer
: -
If we are going to move to another cell (within the allowed transitions), the field is highlighted green, the cursor takes the form of
pointer
: -
If we are going to attack the enemy (within the allowed attack radius), the field is highlighted in red, the cursor takes the shape of
crosshair
: -
If we are about to perform an invalid action, the cursor takes the form of
notallowed
(in this case an error message is also displayed when clicking):
The direction of movement is similar to the queen in chess. Characters of different types can walk different distances (in the basic version you can jump over other characters, i.e. like a horse in chess, the only rule is that you have to go in straight lines and diagonally):
- Swordsmans/Undeads - 4 squares in any direction
- Лучники/Vampires - 2 клетки в любом направлении
- Magicians/Демоны - 1 клетка в любом направлении
Дальность атаки тоже ограничена:
- Мечники/Скелеты - can only attack a neighboring cell
- Bowmans/Вампиры - for the next two squares
- Маги/Daemons - for the next four squares
Cells are counted "by radius", let's say for a swordsman the attack zone will look like this:
For the archer (marked in red):
-
When moving to a new level, the health indicator is brought to the value: current level + 80 (but not more than 100).
That is, if character 1 had a life level of 10 after the end of the round, and character 2 had a life level of 80, after level up:
- character 1 - life becomes 90
- character 2 - life will become 100
-
Attack/defense increases are tied to remaining life by a formula:
attackAfter = Math.max(attackBefore, attackBefore * (80 + life) / 100)
, i.e. if a character has 50% life left after the end of a round, his stats will improve by 30%. If the character has 1% life left, his stats will not increase in any way.
After the game is over (player loses) or all 4 levels are completed, the playing field is blocked (i.e. does not react to events occurring on it).
When you click on the New Game
button, a new game starts.
The game score is displayed above the buttons and reflects the points earned by the player and the computer during the game.
You can save the game by clicking on the Save Game
button. The game will be saved at the level and state at which the save was invoked.
You can load a saved game by pressing the Load Game
button. The game will open at the level and state at which it was saved.
The state is stored in a byte type in localstorage
and restored from it on boot.