summaryrefslogtreecommitdiff
path: root/src/routers/vault/types/Char.js
blob: 98a0f46dc4ae9f9235cb16b5e70b1992b7c78ad2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
 * 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";
    /** when the char was created */
    creationTime = 0;

    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,
        };
    }
}