-
Notifications
You must be signed in to change notification settings - Fork 37
UserSystem
PassiveSystem
that manages the CRUD of the playable characters.
We can find the following methods:
-
checkStorageDirectory()
is a static method that checks that the folderCharfile.DIR_CHARFILES
is created on the system and creates it in case not -
login()
First checks if the user exist withuserExists()
, if False, the system will call the serverSystem and send to the clientUserLoginResponse.failed()
. Case the user is found (if True), the system will load the users characters callingloadUser()
. Once the system has the Entities loaded, on success returnsUserLoginResponse.ok()
to the client. Lastly the system send theEntities
toworldEntitiesSystem.login()
. On errors returns theUserLoginResponse.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, returnsUserCreateResponse.failed()
to the client. In case the name is valid, the Entity of the new character is created throughentityFactorySystem.create()
andsaved()
. 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 clientUserCreateResponse.ok()
and callsworldEntitiesSystem.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 onCharfile.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 callscomponentSystem.getComponents
with aComponentSystem.Visibility.SERVER
, this returns all theEntities
related to the character that then will be saved (if they are not empty), into the characters directoryCharfile.DIR_CHARFILES
. Finally, the system will execute the code sent as paramenterGdx.app.postRunnable()
-
loadUser()
returns a Future object containing a thread with the task of loading the user data (located inside the directoryCharfile.DIR_CHARFILES
). The Future object contains all the Entities related to the user account, that are also registered into the world by theentityFactorySystem.create(components)
.
- IntelliJ
- Windows JDK
- Linux JDK
- Run client and server localhost
- Host a public server
- Import project to IntelliJ