summaryrefslogtreecommitdiff
path: root/src/routers/vault/types
diff options
context:
space:
mode:
Diffstat (limited to 'src/routers/vault/types')
-rw-r--r--src/routers/vault/types/Char.js34
-rw-r--r--src/routers/vault/types/EvolAccount.js21
-rw-r--r--src/routers/vault/types/EvolChar.js21
-rw-r--r--src/routers/vault/types/GameAccount.js38
-rw-r--r--src/routers/vault/types/LegacyAccount.js21
-rw-r--r--src/routers/vault/types/LegacyChar.js21
-rw-r--r--src/routers/vault/types/Session.js44
7 files changed, 189 insertions, 11 deletions
diff --git a/src/routers/vault/types/Char.js b/src/routers/vault/types/Char.js
new file mode 100644
index 0000000..a90b950
--- /dev/null
+++ b/src/routers/vault/types/Char.js
@@ -0,0 +1,34 @@
+/**
+ * represents a generic game character
+ */
+module.exports = class Char {
+ /** reference to the parent GameAccount */
+ account = null;
+ /** the ID of this char */
+ charId = 0;
+ /** the public name */
+ name = "";
+ /** the level of the char */
+ baseLevel = 1;
+ /** gender of the char */
+ gender = "N";
+
+ constructor (acc, id, name) {
+ this.account = acc;
+ this.charId = id;
+ this.name = name;
+ }
+
+ /**
+ * serialize for sending over the network
+ * @param {*} key
+ */
+ toJSON (key) {
+ return {
+ charId: this.charId,
+ name: this.name,
+ level: this.baseLevel,
+ sex: this.gender,
+ };
+ }
+}
diff --git a/src/routers/vault/types/EvolAccount.js b/src/routers/vault/types/EvolAccount.js
new file mode 100644
index 0000000..6db03bf
--- /dev/null
+++ b/src/routers/vault/types/EvolAccount.js
@@ -0,0 +1,21 @@
+const GameAccount = require("./GameAccount.js");
+
+/**
+ * represents an Evol game account
+ */
+module.exports = class EvolAccount extends GameAccount {
+ /** account id of the source legacy account (ported) */
+ legacyId = null;
+ /** reference to the LegacyAccount */
+ legacyAccount = null;
+
+ /**
+ * serialize for sending over the network
+ * @param {*} key
+ */
+ toJSON (key) {
+ return Object.assign({
+ legacyId: this.legacyId,
+ }, super.toJSON());
+ }
+}
diff --git a/src/routers/vault/types/EvolChar.js b/src/routers/vault/types/EvolChar.js
new file mode 100644
index 0000000..1107d62
--- /dev/null
+++ b/src/routers/vault/types/EvolChar.js
@@ -0,0 +1,21 @@
+const Char = require("./Char.js");
+
+/**
+ * represents an Evol game char
+ */
+module.exports = class EvolChar extends Char {
+ /** char id of the source legacy char (ported) */
+ legacyId = null;
+ /** reference to the LegacyChar */
+ legacyChar = null;
+
+ /**
+ * serialize for sending over the network
+ * @param {*} key
+ */
+ toJSON (key) {
+ return Object.assign({
+ legacyId: this.legacyId,
+ }, super.toJSON());
+ }
+}
diff --git a/src/routers/vault/types/GameAccount.js b/src/routers/vault/types/GameAccount.js
new file mode 100644
index 0000000..fa94808
--- /dev/null
+++ b/src/routers/vault/types/GameAccount.js
@@ -0,0 +1,38 @@
+/**
+ * represents a generic game account
+ */
+module.exports = class GameAccount {
+ /** the GID of the account */
+ accountId = 0;
+ /** the login username */
+ userid = "";
+ /** the email address associated with the account */
+ email = null;
+ /** Char[] */
+ chars = [];
+ /** the last time the account logged in */
+ lastLogin = null;
+ /** the last IP that was used to log in */
+ lastIP = null;
+ /** the total number of times the account logged in */
+ loginCount = 0;
+ /** whether the account is banned */
+ banned = false;
+
+ constructor (id, name) {
+ this.accountId = id;
+ this.userid = name;
+ }
+
+ /**
+ * serialize for sending over the network
+ * @param {*} key
+ */
+ toJSON (key) {
+ return {
+ accountId: this.accountId,
+ name: this.userid,
+ chars: this.chars,
+ };
+ }
+}
diff --git a/src/routers/vault/types/LegacyAccount.js b/src/routers/vault/types/LegacyAccount.js
new file mode 100644
index 0000000..747e6df
--- /dev/null
+++ b/src/routers/vault/types/LegacyAccount.js
@@ -0,0 +1,21 @@
+const GameAccount = require("./GameAccount.js");
+
+/**
+ * represents a Legacy game account
+ */
+module.exports = class LegacyAccount extends GameAccount {
+ /** account id of the target evol account (ported) */
+ revoltId = null;
+ /** reference to the EvolAccount of the target evol account */
+ revoltAccount = null;
+
+ /**
+ * serialize for sending over the network
+ * @param {*} key
+ */
+ toJSON (key) {
+ return Object.assign({
+ revoltId: this.revoltId,
+ }, super.toJSON());
+ }
+}
diff --git a/src/routers/vault/types/LegacyChar.js b/src/routers/vault/types/LegacyChar.js
new file mode 100644
index 0000000..b893c3f
--- /dev/null
+++ b/src/routers/vault/types/LegacyChar.js
@@ -0,0 +1,21 @@
+const Char = require("./Char.js");
+
+/**
+ * represents a Legacy game char
+ */
+module.exports = class LegacyChar extends Char {
+ /** char id of the target evol char (ported) */
+ revoltId = null;
+ /** reference to the EvolChar */
+ revoltChar = null;
+
+ /**
+ * serialize for sending over the network
+ * @param {*} key
+ */
+ toJSON (key) {
+ return Object.assign({
+ revoltId: this.revoltId,
+ }, super.toJSON());
+ }
+}
diff --git a/src/routers/vault/types/Session.js b/src/routers/vault/types/Session.js
index 34bd250..1809cac 100644
--- a/src/routers/vault/types/Session.js
+++ b/src/routers/vault/types/Session.js
@@ -2,20 +2,42 @@
* holds a cache of all the user data fetched from SQL
*/
module.exports = class Session {
- expires = new Date(); // expiry Date
- vault = null; // Vault account id
- authenticated = false; // whether the user logged in
- identity = null; // the identity that was used to log in
- email; // the email address of the identity that was used to log in
- identities = []; // cache holding all identities
- primaryIdentity = null; // the main identity of the account
- allowNonPrimary = true; // whether to allow logging in with a non-primary ident
- legacyAccounts = []; // cache holding all legacy game accounts
- gameAccounts = []; // cache holding all evol game accounts
- ip; // ip that was used to init the session
+ /** expiry Date */
+ expires = new Date();
+ /** Vault account id */
+ vault = null;
+ /** whether the user logged in */
+ authenticated = false;
+ /** the identity that was used to log in */
+ identity = null;
+ /** the email address of the identity that was used to log in */
+ email;
+ /** cache holding all identities */
+ identities = [];
+ /** the main identity of the account */
+ primaryIdentity = null;
+ /** whether to allow logging in with a non-primary ident */
+ allowNonPrimary = true;
+ /** LegacyAccount[] cache holding all legacy game accounts */
+ legacyAccounts = [];
+ /** EvolAccount[] cache holding all evol game accounts */
+ gameAccounts = [];
+ /** ip that was used to init the session */
+ ip;
constructor (ip, email) {
this.ip = ip;
this.email = email;
}
+
+ /**
+ * serialize for sending over the network
+ * @param {*} key
+ */
+ toJSON (key) {
+ return {
+ expires: this.expires,
+ identity: this.identity,
+ }
+ }
}