This describes how client and server interact, in order to for example allow player to pick up item, equip item and so on. This also involves changing the html on the cient side according to the event received from server
This is sub-layout for documentation pages
All of the following tasks (or actions) are executed by client always, when relevant packet with data arrives, regardless the situation (since server is master). Client can fulfill (not only) the following tasks:
The situation is illustrated by following activity diagram:
The situation is illustrated by following activity diagram:
When client clicks on an NPC or another player, command to the server is sent, that player
should attack another charactter.
The mechanics is illustrated by following activity diagram:
For any of these settings, if user clicks on some button, message is sent to server with that info.
Server then validates, if that setup is possible, and if so, overwrites the setup in Player's combat class instance.
That info is later used whenever player attacks (for example).
Below is a use case diagram, showing the combat settings use cases:
Buff or debuff in any effect put on target character(s). Such an effect modifies the character (health, of stats....)
for some (usually finite) amount of time, or until removed.
Buff or debuff is represented by AuraAbility
When you add effect to character (maybe lower the stats, or damage over time), you need the AuraAbility.
The AuraAbility structure is added as effect to the character.
This gives flexibility, where whatever buff you want to create, you just add a new ability (which can be
unavailable to players to be used as ability) to game.
The usage in game is illustrated by following activity diagram:
Note: in green are displayed sub-activities
When command from server is received, client adds a new player to the map,
and will be displaying the player, until removed.
Along with the command from server, complete info for player must be sent
aswell (for example: object ID, player name, player level, position, current
health, max health, skull ... )
However, once this is done, server can address such a player using ID, and send only updates.
The interaction is displayed by following activity diagram:
Player is dead \(\iff\) his health reaches \(0\) or is below \(0\)
As this is complicated operation, it is atomized to easier operations, which are already implemeted.
Suppose, that player dies (which is evaluated on server side). Then:
When player clicks on door (or cave entrance), it would take him to different map.
That is called the map transition (=change current map).
This describes, how it is implemented
The idea is to assebmle this operation from operations described above. Here is what generally what happens (understanding, that comunication is done through network and packets, so diagram is simplified alot):
On server side, this is easy, we just remove player from current map, and add him to the other map (GameMap instance).
When client receives information about map transition, he will also retrieve the dynamic data for the map.
There is no way to optimize this (apart from difference data sending, which would be extremelly complex),
as dynamic data in map can change at any time...
The map transition event can be triggered by, for example, using door.
However, implementation is not that trivial, and it shows that it is actually very tricky to get this done correctly...
Here is example solution, which might seem like correct one after first look, but is in fact incorrect,
and can result in undefined behavior, which would be tormendously difficult to resolve (=to find why is game crashing...)
Imagine, that upon receiving request from client, action is added to the action queue of player:
Then, as the server update loop will run, the following would happen:
Note: The class names / interations might NOT exactly reflect the server itself,
as the code is changing alot, but the diagram is more about the idea of what could have happened...
In the packet creation phase, before we add data to the packet, we check, whether player has transitioned between maps (this update). If so, then we will not add some data to packets / add different, relevant data