-
Notifications
You must be signed in to change notification settings - Fork 0
/
stat-mod.ts
46 lines (39 loc) · 1.17 KB
/
stat-mod.ts
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
37
38
39
40
41
42
43
44
45
46
import { Serializable } from '../interfaces/entity.interfaces';
import { staticImplements } from '../utility/class-decorators';
@staticImplements<Serializable<MUDStatMod, MUDStatModSerialized>>()
export class MUDStatMod {
public value: number;
public type: MUDStatModType;
public phase: MUDStatModPhase;
constructor(value: number, type: MUDStatModType, phase: MUDStatModPhase = MUDStatModPhase.normal) {
this.value = value;
this.type = type;
this.phase = phase;
}
public static Serialize(object: MUDStatMod): MUDStatModSerialized {
return {
phase: object.phase,
type: object.type,
value: object.value
};
}
public static Deserialize(value: MUDStatModSerialized): MUDStatMod {
return new MUDStatMod(value.value, value.type, value.phase);
}
}
export interface MUDStatModSerialized {
phase: MUDStatModPhase;
type: MUDStatModType;
value: number;
}
export enum MUDStatModType {
add = 'add',
subtract = 'sub',
multiply = 'multiply',
divide = 'divide'
}
export enum MUDStatModPhase {
early = 'early',
normal = 'normal',
late = 'late'
}