Skip to content

UserSystem

jmpala edited this page Aug 14, 2020 · 3 revisions

PassiveSystem that manages the CRUD of the playable characters.

We can find the following methods:

  • checkStorageDirectory() is a static method that checks that the folder Charfile.DIR_CHARFILES is created on the system and creates it in case not

  • login() First checks if the user exist with userExists(), if False, the system will call the serverSystem and send to the client UserLoginResponse.failed(). Case the user is found (if True), the system will load the users characters calling loadUser(). Once the system has the Entities loaded, on success returns UserLoginResponse.ok() to the client. Lastly the system send the Entities to worldEntitiesSystem.login(). On errors returns the UserLoginResponse.failed() to the client

  • create() receives data from the account creation of the user. First validates the name and checks if the name already exist in our system. In case the name is not validated, returns UserCreateResponse.failed() to the client. In case the name is valid, the Entity of the new character is created through entityFactorySystem.create() and saved(). Then the system obtains the accounts character and validates if there is already a character created into the requested index. When there is, the system will delete the character file (Charfile.DIR_CHARFILES). Then the new character is linked into the user account, the system returns to the client UserCreateResponse.ok() and calls worldEntitiesSystem.login()

  • userExists() receives a String, that belongs to the name of an account. The system checks that the file belonging to the account is created inside de folder defined on Charfile.DIR_CHARFILES. Returns True if successful

  • saved() obtains the character Entity and validates that it has associated the components character and name. If True, the system calls componentSystem.getComponents with a ComponentSystem.Visibility.SERVER, this returns all the Entities related to the character that then will be saved (if they are not empty), into the characters directory Charfile.DIR_CHARFILES. Finally, the system will execute the code sent as paramenter Gdx.app.postRunnable()

  • loadUser() returns a Future object containing a thread with the task of loading the user data (located inside the directory Charfile.DIR_CHARFILES). The Future object contains all the Entities related to the user account, that are also registered into the world by the entityFactorySystem.create(components).

<< Back to Server Systems

Get Starting

Requirements

Source Code

Reference

run

Graphics

balance

external documentation

Clone this wiki locally