Skip to content

MartinStankov/GameServerSimulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Game Server Simulator project using Java

The main idea of this project is to recreate a simple server simulator. You can create a player and a npc on the board. They can attack each other, perform regular moves, defend themselves, use healing like shown in the main file and so on. If either the Npc or the Player health drops bellow 0 they are being removed from the field.

How it works

You initialize the project by creating the game board. It requires width and height which happens like that:

GameBoard board = new GameBoard(10, 10);

After that you initialize a Player and Npc. They require a name, max health, start position x and start position y are initialized in a similar way:

Player player = new Player("player1", 100, 0, 0)
NPC npc = new NPC("npc1", 70, 5, 5);

After that you should add them to the board like this:

board.addEntity(player);
board.addEntity(npc);

After that the game server should be initialized and started.

GameServer gameServer = new GameServer(board);
gameServer.start();

After that PlayerThread and NPCThread must be created and started:

PlayerThread playerThread = new PlayerThread(player, board, gameServer);
Thread thread = new Thread(playerThread, "PlayerThread");
thread.start();

Abilities and actions

Currently, there's only a heal ability which can be initialized and used (it can be used on either the caster, or for example the caster can use it on someone else). It works like that:

HealAbility heal = new HealAbility(25);
gameServer.addAction(new AbilityAction(player, heal, player));

There are normal actions as well like attack action, move action and defend action. They can be initialized in a simpler way.

Here's an example with AttackAction:

gameServer.addAction(new AttackAction(npc, board, player.getPositionX(), player.getPositionY(), 30));

If a player/npc health drops bellow 0 they are removed from the game. If you want to check what's left on the board you can use:

board.displayBoard();

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages