-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTechs.ts
177 lines (160 loc) · 4.52 KB
/
Techs.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import IUnits from "../interfaces/IUnits";
/**
* Represents a techs-row in the database
*/
export default class Techs implements IUnits {
/**
* The ID of the user
*/
public userID: number;
/**
* The current espionageTech level
*/
public espionageTech: number;
/**
* The current computerTech level
*/
public computerTech: number;
/**
* The current weaponTech level
*/
public weaponTech: number;
/**
* The current armourTech level
*/
public armourTech: number;
/**
* The current shieldingTech level
*/
public shieldingTech: number;
/**
* The current energyTech level
*/
public energyTech: number;
/**
* The current hyperspaceTech level
*/
public hyperspaceTech: number;
/**
* The current combustionDriveTech level
*/
public combustionDriveTech: number;
/**
* The current impulseDriveTech level
*/
public impulseDriveTech: number;
/**
* The current hyperspaceDriveTech level
*/
public hyperspaceDriveTech: number;
/**
* The current laserTech level
*/
public laserTech: number;
/**
* The current ionTech level
*/
public ionTech: number;
/**
* The current plasmaTech level
*/
public plasmaTech: number;
/**
* The current intergalacticResearchTech level
*/
public intergalacticResearchTech: number;
/**
* The current gravitonTech level
*/
public gravitonTech: number;
/**
* Returns, if the contains valid data or not
*/
public isValid(): boolean {
return (
0 < this.userID &&
0 <= this.espionageTech &&
0 <= this.computerTech &&
0 <= this.weaponTech &&
0 <= this.armourTech &&
0 <= this.shieldingTech &&
0 <= this.energyTech &&
0 <= this.hyperspaceTech &&
0 <= this.combustionDriveTech &&
0 <= this.impulseDriveTech &&
0 <= this.hyperspaceDriveTech &&
0 <= this.laserTech &&
0 <= this.ionTech &&
0 <= this.plasmaTech &&
0 <= this.intergalacticResearchTech &&
0 <= this.gravitonTech
);
}
// public save(): Promise<{}> {
// return new Promise((resolve, reject) => {
// const query = squel
// .update()
// .table("techs")
// .set("espionageTech", this.espionageTech)
// .set("computerTech", this.computerTech)
// .set("weaponTech", this.weaponTech)
// .set("armourTech", this.armourTech)
// .set("shieldingTech", this.shieldingTech)
// .set("energyTech", this.energyTech)
// .set("hyperspaceTech", this.hyperspaceTech)
// .set("combustionDriveTech", this.combustionDriveTech)
// .set("impulseDriveTech", this.impulseDriveTech)
// .set("hyperspaceDriveTech", this.hyperspaceDriveTech)
// .set("laserTech", this.laserTech)
// .set("ionTech", this.ionTech)
// .set("plasmaTech", this.plasmaTech)
// .set("intergalacticResearchTech", this.intergalacticResearchTech)
// .set("gravitonTech", this.gravitonTech)
// .where("userID = ?", this.userID)
// .toString();
//
// Database.query(query)
// .then(() => {
// return resolve(this);
// })
// .catch(error => {
// Logger.error(error);
// return reject(error);
// });
// });
// }
//
// public create(): Promise<{}> {
// return new Promise((resolve, reject) => {
// const query = squel
// .insert()
// .into("techs")
// .set("userID", this.userID)
// .set("espionageTech", this.espionageTech)
// .set("computerTech", this.computerTech)
// .set("weaponTech", this.weaponTech)
// .set("armourTech", this.armourTech)
// .set("shieldingTech", this.shieldingTech)
// .set("energyTech", this.energyTech)
// .set("hyperspaceTech", this.hyperspaceTech)
// .set("combustionDriveTech", this.combustionDriveTech)
// .set("impulseDriveTech", this.impulseDriveTech)
// .set("hyperspaceDriveTech", this.hyperspaceDriveTech)
// .set("laserTech", this.laserTech)
// .set("ionTech", this.ionTech)
// .set("plasmaTech", this.plasmaTech)
// .set("intergalacticResearchTech", this.intergalacticResearchTech)
// .set("gravitonTech", this.gravitonTech)
// .toString();
//
// Database.query(query)
// .then(() => {
// return resolve(this);
// })
// .catch(error => {
// Logger.error(error);
// return reject(error);
// });
// });
// }
}