ogamejs 2.1.6 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +485 -228
- package/package.json +71 -33
- package/src/buildings/buildTime.js +25 -0
- package/src/buildings/crystal.js +35 -0
- package/src/buildings/deut.js +31 -0
- package/src/buildings/fusion-reactor.js +35 -0
- package/src/buildings/index.js +28 -0
- package/src/buildings/info.js +42 -0
- package/src/buildings/infocompte.js +150 -0
- package/src/buildings/metal.js +26 -0
- package/src/buildings/production.js +150 -0
- package/src/buildings/solar-plant.js +25 -0
- package/src/buildings/storage.js +59 -0
- package/src/cost.js +70 -0
- package/src/fleets/combat.js +291 -0
- package/src/fleets/distance.js +39 -0
- package/src/fleets/flight.js +105 -0
- package/src/fleets/getDebris.js +21 -0
- package/src/fleets/index.js +19 -0
- package/src/fleets/speed.js +108 -0
- package/src/i18n.js +43 -0
- package/src/index.js +28 -0
- package/src/models/buildings.js +319 -0
- package/src/models/destroyable.js +929 -0
- package/src/models/research.js +169 -0
- package/src/research/index.js +9 -0
- package/src/research/researchTime.js +25 -0
- package/src/trades/crystal.js +16 -0
- package/src/trades/deut.js +16 -0
- package/src/trades/index.js +13 -0
- package/src/trades/metal.js +16 -0
- package/src/trades/parseRate.js +49 -0
- package/src/trades/utils.js +9 -0
- package/src/types.js +146 -0
- package/types/buildings/buildTime.d.ts +16 -0
- package/types/buildings/buildTime.d.ts.map +1 -0
- package/types/buildings/crystal.d.ts +12 -0
- package/types/buildings/crystal.d.ts.map +1 -0
- package/types/buildings/deut.d.ts +12 -0
- package/types/buildings/deut.d.ts.map +1 -0
- package/types/buildings/fusion-reactor.d.ts +15 -0
- package/types/buildings/fusion-reactor.d.ts.map +1 -0
- package/types/buildings/index.d.ts +27 -0
- package/types/buildings/index.d.ts.map +1 -0
- package/types/buildings/info.d.ts +17 -0
- package/types/buildings/info.d.ts.map +1 -0
- package/types/buildings/infocompte.d.ts +41 -0
- package/types/buildings/infocompte.d.ts.map +1 -0
- package/types/buildings/metal.d.ts +11 -0
- package/types/buildings/metal.d.ts.map +1 -0
- package/types/buildings/production.d.ts +78 -0
- package/types/buildings/production.d.ts.map +1 -0
- package/types/buildings/solar-plant.d.ts +10 -0
- package/types/buildings/solar-plant.d.ts.map +1 -0
- package/types/buildings/storage.d.ts +29 -0
- package/types/buildings/storage.d.ts.map +1 -0
- package/types/cost.d.ts +25 -0
- package/types/cost.d.ts.map +1 -0
- package/types/fleets/combat.d.ts +57 -0
- package/types/fleets/combat.d.ts.map +1 -0
- package/types/fleets/distance.d.ts +13 -0
- package/types/fleets/distance.d.ts.map +1 -0
- package/types/fleets/flight.d.ts +57 -0
- package/types/fleets/flight.d.ts.map +1 -0
- package/types/fleets/getDebris.d.ts +12 -0
- package/types/fleets/getDebris.d.ts.map +1 -0
- package/types/fleets/index.d.ts +18 -0
- package/types/fleets/index.d.ts.map +1 -0
- package/types/fleets/speed.d.ts +54 -0
- package/types/fleets/speed.d.ts.map +1 -0
- package/types/i18n.d.ts +23 -0
- package/types/i18n.d.ts.map +1 -0
- package/types/index.d.ts +1316 -0
- package/types/index.d.ts.map +1 -0
- package/types/models/buildings.d.ts +373 -0
- package/types/models/buildings.d.ts.map +1 -0
- package/types/models/destroyable.d.ts +695 -0
- package/types/models/destroyable.d.ts.map +1 -0
- package/types/models/research.d.ts +262 -0
- package/types/models/research.d.ts.map +1 -0
- package/types/research/index.d.ts +8 -0
- package/types/research/index.d.ts.map +1 -0
- package/types/research/researchTime.d.ts +16 -0
- package/types/research/researchTime.d.ts.map +1 -0
- package/types/trades/crystal.d.ts +6 -0
- package/types/trades/crystal.d.ts.map +1 -0
- package/types/trades/deut.d.ts +6 -0
- package/types/trades/deut.d.ts.map +1 -0
- package/types/trades/index.d.ts +12 -0
- package/types/trades/index.d.ts.map +1 -0
- package/types/trades/metal.d.ts +6 -0
- package/types/trades/metal.d.ts.map +1 -0
- package/types/trades/parseRate.d.ts +2 -0
- package/types/trades/parseRate.d.ts.map +1 -0
- package/types/trades/utils.d.ts +2 -0
- package/types/trades/utils.d.ts.map +1 -0
- package/types/types.d.ts +449 -0
- package/types/types.d.ts.map +1 -0
- package/CHANGELOG.md +0 -50
- package/build/buildings/crystal.js +0 -61
- package/build/buildings/crystal.test.js +0 -32
- package/build/buildings/deut.js +0 -56
- package/build/buildings/deut.test.js +0 -32
- package/build/buildings/fusion-reactor.js +0 -60
- package/build/buildings/fusion-reactor.test.js +0 -22
- package/build/buildings/index.js +0 -31
- package/build/buildings/infocompte.js +0 -150
- package/build/buildings/infocompte.test.js +0 -107
- package/build/buildings/metal.js +0 -50
- package/build/buildings/metal.test.js +0 -32
- package/build/buildings/solar-plant.js +0 -42
- package/build/buildings/solar-plant.test.js +0 -21
- package/build/fleets/getDebris.js +0 -27
- package/build/fleets/getDebris.test.js +0 -26
- package/build/fleets/index.js +0 -16
- package/build/index.js +0 -30
- package/build/models/buildings.js +0 -65
- package/build/models/destroyable.js +0 -730
- package/build/trades/crystal.js +0 -33
- package/build/trades/crystal.test.js +0 -16
- package/build/trades/deut.js +0 -33
- package/build/trades/deut.test.js +0 -16
- package/build/trades/index.js +0 -25
- package/build/trades/metal.js +0 -33
- package/build/trades/metal.test.js +0 -16
- package/build/trades/parseRate.js +0 -60
- package/build/trades/parseRate.test.js +0 -40
- package/build/trades/trades.js +0 -119
- package/build/trades/trades.test.js +0 -65
- package/build/trades/utils.js +0 -17
- package/build/trades/utils.test.js +0 -16
- package/build/winston.js +0 -16
package/types/types.d.ts
ADDED
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared type definitions.
|
|
3
|
+
*
|
|
4
|
+
* This module holds no runtime code: it only exists so the JSDoc of the rest of
|
|
5
|
+
* the library — and the generated `.d.ts` files — can point at named types
|
|
6
|
+
* instead of a bare `object`.
|
|
7
|
+
*
|
|
8
|
+
* @module types
|
|
9
|
+
*/
|
|
10
|
+
export type Lang = 'en' | 'fr';
|
|
11
|
+
export type Names = {
|
|
12
|
+
/**
|
|
13
|
+
* The English name
|
|
14
|
+
*/
|
|
15
|
+
en: string;
|
|
16
|
+
/**
|
|
17
|
+
* The French name
|
|
18
|
+
*/
|
|
19
|
+
fr: string;
|
|
20
|
+
};
|
|
21
|
+
export type BuildingBase = {
|
|
22
|
+
/**
|
|
23
|
+
* Metal paid to build it
|
|
24
|
+
*/
|
|
25
|
+
metal: number;
|
|
26
|
+
/**
|
|
27
|
+
* Crystal paid to build it
|
|
28
|
+
*/
|
|
29
|
+
crystal: number;
|
|
30
|
+
/**
|
|
31
|
+
* Deuterium paid to build it
|
|
32
|
+
*/
|
|
33
|
+
deuterium: number;
|
|
34
|
+
/**
|
|
35
|
+
* Energy paid to build it
|
|
36
|
+
*/
|
|
37
|
+
energyCost: number;
|
|
38
|
+
/**
|
|
39
|
+
* Energy it consumes once built
|
|
40
|
+
*/
|
|
41
|
+
energyConsumption: number;
|
|
42
|
+
/**
|
|
43
|
+
* Deuterium it burns once built
|
|
44
|
+
*/
|
|
45
|
+
deuteriumConsumption: number;
|
|
46
|
+
/**
|
|
47
|
+
* What it produces, resources or energy
|
|
48
|
+
*/
|
|
49
|
+
production: number;
|
|
50
|
+
};
|
|
51
|
+
export type BuildingEntry = {
|
|
52
|
+
/**
|
|
53
|
+
* The id OGame itself uses
|
|
54
|
+
*/
|
|
55
|
+
ogameId: number;
|
|
56
|
+
/**
|
|
57
|
+
* The localised labels
|
|
58
|
+
*/
|
|
59
|
+
names: Names;
|
|
60
|
+
/**
|
|
61
|
+
* `resources`, `facilities` or `moon`
|
|
62
|
+
*/
|
|
63
|
+
category: string;
|
|
64
|
+
/**
|
|
65
|
+
* The per-level cost multiplier
|
|
66
|
+
*/
|
|
67
|
+
factor: number;
|
|
68
|
+
/**
|
|
69
|
+
* The level 1 values
|
|
70
|
+
*/
|
|
71
|
+
base: BuildingBase;
|
|
72
|
+
/**
|
|
73
|
+
* A separate multiplier for the energy cost
|
|
74
|
+
*/
|
|
75
|
+
energyFactor?: number;
|
|
76
|
+
/**
|
|
77
|
+
* The resource it stores, on storage buildings only
|
|
78
|
+
*/
|
|
79
|
+
storage?: string;
|
|
80
|
+
};
|
|
81
|
+
export type ResearchBase = {
|
|
82
|
+
/**
|
|
83
|
+
* Metal cost
|
|
84
|
+
*/
|
|
85
|
+
metal: number;
|
|
86
|
+
/**
|
|
87
|
+
* Crystal cost
|
|
88
|
+
*/
|
|
89
|
+
crystal: number;
|
|
90
|
+
/**
|
|
91
|
+
* Deuterium cost
|
|
92
|
+
*/
|
|
93
|
+
deuterium: number;
|
|
94
|
+
/**
|
|
95
|
+
* Energy cost, Graviton technology only
|
|
96
|
+
*/
|
|
97
|
+
energyCost: number;
|
|
98
|
+
};
|
|
99
|
+
export type ResearchEntry = {
|
|
100
|
+
/**
|
|
101
|
+
* The id OGame itself uses
|
|
102
|
+
*/
|
|
103
|
+
ogameId: number;
|
|
104
|
+
/**
|
|
105
|
+
* The localised labels
|
|
106
|
+
*/
|
|
107
|
+
names: Names;
|
|
108
|
+
/**
|
|
109
|
+
* `basic`, `drive`, `advanced` or `combat`
|
|
110
|
+
*/
|
|
111
|
+
category: string;
|
|
112
|
+
/**
|
|
113
|
+
* The per-level cost multiplier
|
|
114
|
+
*/
|
|
115
|
+
factor: number;
|
|
116
|
+
/**
|
|
117
|
+
* The level 1 cost
|
|
118
|
+
*/
|
|
119
|
+
base: ResearchBase;
|
|
120
|
+
/**
|
|
121
|
+
* Rounding step, Astrophysics only
|
|
122
|
+
*/
|
|
123
|
+
roundTo?: number;
|
|
124
|
+
};
|
|
125
|
+
export type Cost = {
|
|
126
|
+
/**
|
|
127
|
+
* Metal cost
|
|
128
|
+
*/
|
|
129
|
+
metal: number;
|
|
130
|
+
/**
|
|
131
|
+
* Crystal cost
|
|
132
|
+
*/
|
|
133
|
+
crystal: number;
|
|
134
|
+
/**
|
|
135
|
+
* Deuterium cost
|
|
136
|
+
*/
|
|
137
|
+
deuterium: number;
|
|
138
|
+
/**
|
|
139
|
+
* Energy cost
|
|
140
|
+
*/
|
|
141
|
+
energyCost: number;
|
|
142
|
+
};
|
|
143
|
+
export type BuildingInfo = {
|
|
144
|
+
/**
|
|
145
|
+
* Metal paid to reach that level
|
|
146
|
+
*/
|
|
147
|
+
metal: number;
|
|
148
|
+
/**
|
|
149
|
+
* Crystal paid to reach that level
|
|
150
|
+
*/
|
|
151
|
+
crystal: number;
|
|
152
|
+
/**
|
|
153
|
+
* Deuterium paid to reach that level
|
|
154
|
+
*/
|
|
155
|
+
deuterium: number;
|
|
156
|
+
/**
|
|
157
|
+
* Energy paid to reach that level
|
|
158
|
+
*/
|
|
159
|
+
energyCost: number;
|
|
160
|
+
/**
|
|
161
|
+
* Energy consumed at that level
|
|
162
|
+
*/
|
|
163
|
+
energyConsumption: number;
|
|
164
|
+
/**
|
|
165
|
+
* Deuterium burned at that level
|
|
166
|
+
*/
|
|
167
|
+
deuteriumConsumption: number;
|
|
168
|
+
/**
|
|
169
|
+
* Resources, or energy, produced at that level
|
|
170
|
+
*/
|
|
171
|
+
production: number;
|
|
172
|
+
};
|
|
173
|
+
export type RapidFire = {
|
|
174
|
+
/**
|
|
175
|
+
* The library id of the unit it applies to
|
|
176
|
+
*/
|
|
177
|
+
target: number;
|
|
178
|
+
/**
|
|
179
|
+
* How many shots it can chain
|
|
180
|
+
*/
|
|
181
|
+
fire: number;
|
|
182
|
+
};
|
|
183
|
+
export type DriveUpgrade = {
|
|
184
|
+
/**
|
|
185
|
+
* The drive it moves to
|
|
186
|
+
*/
|
|
187
|
+
drive: string;
|
|
188
|
+
/**
|
|
189
|
+
* The drive level that unlocks it
|
|
190
|
+
*/
|
|
191
|
+
minLevel: number;
|
|
192
|
+
/**
|
|
193
|
+
* The new base speed
|
|
194
|
+
*/
|
|
195
|
+
speed: number;
|
|
196
|
+
/**
|
|
197
|
+
* The new base fuel consumption
|
|
198
|
+
*/
|
|
199
|
+
fuelConsumption: number;
|
|
200
|
+
};
|
|
201
|
+
export type DestroyableEntry = {
|
|
202
|
+
/**
|
|
203
|
+
* The id OGame itself uses
|
|
204
|
+
*/
|
|
205
|
+
ogameId: number;
|
|
206
|
+
/**
|
|
207
|
+
* The localised labels
|
|
208
|
+
*/
|
|
209
|
+
names: Names;
|
|
210
|
+
/**
|
|
211
|
+
* The metal plus crystal cost, hull is a tenth of it
|
|
212
|
+
*/
|
|
213
|
+
structure: number;
|
|
214
|
+
/**
|
|
215
|
+
* The base shield
|
|
216
|
+
*/
|
|
217
|
+
shield: number;
|
|
218
|
+
/**
|
|
219
|
+
* The base attack
|
|
220
|
+
*/
|
|
221
|
+
attack: number;
|
|
222
|
+
/**
|
|
223
|
+
* The base speed, before any drive bonus
|
|
224
|
+
*/
|
|
225
|
+
speed: number;
|
|
226
|
+
/**
|
|
227
|
+
* The cargo capacity
|
|
228
|
+
*/
|
|
229
|
+
cargo: number;
|
|
230
|
+
/**
|
|
231
|
+
* The base deuterium burned
|
|
232
|
+
*/
|
|
233
|
+
fuelConsumption: number;
|
|
234
|
+
/**
|
|
235
|
+
* The drive powering it
|
|
236
|
+
*/
|
|
237
|
+
drive: string;
|
|
238
|
+
/**
|
|
239
|
+
* `attack`, `civil` or `defense`
|
|
240
|
+
*/
|
|
241
|
+
type: string;
|
|
242
|
+
/**
|
|
243
|
+
* `ships`, `defenses` or `missiles`
|
|
244
|
+
*/
|
|
245
|
+
category: string;
|
|
246
|
+
/**
|
|
247
|
+
* Its rapid-fire table
|
|
248
|
+
*/
|
|
249
|
+
rapidFire: RapidFire[];
|
|
250
|
+
/**
|
|
251
|
+
* What it costs to build
|
|
252
|
+
*/
|
|
253
|
+
cost: {
|
|
254
|
+
metal: number;
|
|
255
|
+
crystal: number;
|
|
256
|
+
deuterium: number;
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* The drives it can switch to
|
|
260
|
+
*/
|
|
261
|
+
driveUpgrades?: DriveUpgrade[];
|
|
262
|
+
};
|
|
263
|
+
export type Coordinates = {
|
|
264
|
+
/**
|
|
265
|
+
* The galaxy
|
|
266
|
+
*/
|
|
267
|
+
galaxy: number;
|
|
268
|
+
/**
|
|
269
|
+
* The system
|
|
270
|
+
*/
|
|
271
|
+
system: number;
|
|
272
|
+
/**
|
|
273
|
+
* The position in the system
|
|
274
|
+
*/
|
|
275
|
+
position: number;
|
|
276
|
+
};
|
|
277
|
+
export type FleetEntry = {
|
|
278
|
+
/**
|
|
279
|
+
* The ship
|
|
280
|
+
*/
|
|
281
|
+
ship: DestroyableEntry;
|
|
282
|
+
/**
|
|
283
|
+
* How many of them
|
|
284
|
+
*/
|
|
285
|
+
count: number;
|
|
286
|
+
};
|
|
287
|
+
export type Drives = {
|
|
288
|
+
/**
|
|
289
|
+
* The Combustion Drive level
|
|
290
|
+
*/
|
|
291
|
+
combustion?: number;
|
|
292
|
+
/**
|
|
293
|
+
* The Impulse Drive level
|
|
294
|
+
*/
|
|
295
|
+
impulse?: number;
|
|
296
|
+
/**
|
|
297
|
+
* The Hyperspace Drive level
|
|
298
|
+
*/
|
|
299
|
+
hyperspace?: number;
|
|
300
|
+
};
|
|
301
|
+
export type CombatTechs = {
|
|
302
|
+
/**
|
|
303
|
+
* The Weapons Technology level
|
|
304
|
+
*/
|
|
305
|
+
weapons?: number;
|
|
306
|
+
/**
|
|
307
|
+
* The Shielding Technology level
|
|
308
|
+
*/
|
|
309
|
+
shielding?: number;
|
|
310
|
+
/**
|
|
311
|
+
* The Armour Technology level
|
|
312
|
+
*/
|
|
313
|
+
armour?: number;
|
|
314
|
+
};
|
|
315
|
+
export type Resources = {
|
|
316
|
+
/**
|
|
317
|
+
* Metal
|
|
318
|
+
*/
|
|
319
|
+
metal: number;
|
|
320
|
+
/**
|
|
321
|
+
* Crystal
|
|
322
|
+
*/
|
|
323
|
+
crystal: number;
|
|
324
|
+
/**
|
|
325
|
+
* Deuterium
|
|
326
|
+
*/
|
|
327
|
+
deuterium: number;
|
|
328
|
+
};
|
|
329
|
+
/**
|
|
330
|
+
* @typedef {'en' | 'fr'} Lang A supported language
|
|
331
|
+
*/
|
|
332
|
+
/**
|
|
333
|
+
* @typedef {object} Names
|
|
334
|
+
* @property {string} en The English name
|
|
335
|
+
* @property {string} fr The French name
|
|
336
|
+
*/
|
|
337
|
+
/**
|
|
338
|
+
* @typedef {object} BuildingBase The level 1 values of a building
|
|
339
|
+
* @property {number} metal Metal paid to build it
|
|
340
|
+
* @property {number} crystal Crystal paid to build it
|
|
341
|
+
* @property {number} deuterium Deuterium paid to build it
|
|
342
|
+
* @property {number} energyCost Energy paid to build it
|
|
343
|
+
* @property {number} energyConsumption Energy it consumes once built
|
|
344
|
+
* @property {number} deuteriumConsumption Deuterium it burns once built
|
|
345
|
+
* @property {number} production What it produces, resources or energy
|
|
346
|
+
*/
|
|
347
|
+
/**
|
|
348
|
+
* @typedef {object} BuildingEntry An entry of `models/buildings.js`
|
|
349
|
+
* @property {number} ogameId The id OGame itself uses
|
|
350
|
+
* @property {Names} names The localised labels
|
|
351
|
+
* @property {string} category `resources`, `facilities` or `moon`
|
|
352
|
+
* @property {number} factor The per-level cost multiplier
|
|
353
|
+
* @property {BuildingBase} base The level 1 values
|
|
354
|
+
* @property {number} [energyFactor] A separate multiplier for the energy cost
|
|
355
|
+
* @property {string} [storage] The resource it stores, on storage buildings only
|
|
356
|
+
*/
|
|
357
|
+
/**
|
|
358
|
+
* @typedef {object} ResearchBase The level 1 cost of a technology
|
|
359
|
+
* @property {number} metal Metal cost
|
|
360
|
+
* @property {number} crystal Crystal cost
|
|
361
|
+
* @property {number} deuterium Deuterium cost
|
|
362
|
+
* @property {number} energyCost Energy cost, Graviton technology only
|
|
363
|
+
*/
|
|
364
|
+
/**
|
|
365
|
+
* @typedef {object} ResearchEntry An entry of `models/research.js`
|
|
366
|
+
* @property {number} ogameId The id OGame itself uses
|
|
367
|
+
* @property {Names} names The localised labels
|
|
368
|
+
* @property {string} category `basic`, `drive`, `advanced` or `combat`
|
|
369
|
+
* @property {number} factor The per-level cost multiplier
|
|
370
|
+
* @property {ResearchBase} base The level 1 cost
|
|
371
|
+
* @property {number} [roundTo] Rounding step, Astrophysics only
|
|
372
|
+
*/
|
|
373
|
+
/**
|
|
374
|
+
* @typedef {object} Cost The resources a level costs
|
|
375
|
+
* @property {number} metal Metal cost
|
|
376
|
+
* @property {number} crystal Crystal cost
|
|
377
|
+
* @property {number} deuterium Deuterium cost
|
|
378
|
+
* @property {number} energyCost Energy cost
|
|
379
|
+
*/
|
|
380
|
+
/**
|
|
381
|
+
* @typedef {object} BuildingInfo Everything about a building at a given level
|
|
382
|
+
* @property {number} metal Metal paid to reach that level
|
|
383
|
+
* @property {number} crystal Crystal paid to reach that level
|
|
384
|
+
* @property {number} deuterium Deuterium paid to reach that level
|
|
385
|
+
* @property {number} energyCost Energy paid to reach that level
|
|
386
|
+
* @property {number} energyConsumption Energy consumed at that level
|
|
387
|
+
* @property {number} deuteriumConsumption Deuterium burned at that level
|
|
388
|
+
* @property {number} production Resources, or energy, produced at that level
|
|
389
|
+
*/
|
|
390
|
+
/**
|
|
391
|
+
* @typedef {object} RapidFire A rapid-fire bonus against another unit
|
|
392
|
+
* @property {number} target The library id of the unit it applies to
|
|
393
|
+
* @property {number} fire How many shots it can chain
|
|
394
|
+
*/
|
|
395
|
+
/**
|
|
396
|
+
* @typedef {object} DriveUpgrade A better drive a ship switches to
|
|
397
|
+
* @property {string} drive The drive it moves to
|
|
398
|
+
* @property {number} minLevel The drive level that unlocks it
|
|
399
|
+
* @property {number} speed The new base speed
|
|
400
|
+
* @property {number} fuelConsumption The new base fuel consumption
|
|
401
|
+
*/
|
|
402
|
+
/**
|
|
403
|
+
* @typedef {object} DestroyableEntry An entry of `models/destroyable.js`
|
|
404
|
+
* @property {number} ogameId The id OGame itself uses
|
|
405
|
+
* @property {Names} names The localised labels
|
|
406
|
+
* @property {number} structure The metal plus crystal cost, hull is a tenth of it
|
|
407
|
+
* @property {number} shield The base shield
|
|
408
|
+
* @property {number} attack The base attack
|
|
409
|
+
* @property {number} speed The base speed, before any drive bonus
|
|
410
|
+
* @property {number} cargo The cargo capacity
|
|
411
|
+
* @property {number} fuelConsumption The base deuterium burned
|
|
412
|
+
* @property {string} drive The drive powering it
|
|
413
|
+
* @property {string} type `attack`, `civil` or `defense`
|
|
414
|
+
* @property {string} category `ships`, `defenses` or `missiles`
|
|
415
|
+
* @property {RapidFire[]} rapidFire Its rapid-fire table
|
|
416
|
+
* @property {{metal: number, crystal: number, deuterium: number}} cost What it costs to build
|
|
417
|
+
* @property {DriveUpgrade[]} [driveUpgrades] The drives it can switch to
|
|
418
|
+
*/
|
|
419
|
+
/**
|
|
420
|
+
* @typedef {object} Coordinates A place in the universe
|
|
421
|
+
* @property {number} galaxy The galaxy
|
|
422
|
+
* @property {number} system The system
|
|
423
|
+
* @property {number} position The position in the system
|
|
424
|
+
*/
|
|
425
|
+
/**
|
|
426
|
+
* @typedef {object} FleetEntry A group of identical ships
|
|
427
|
+
* @property {DestroyableEntry} ship The ship
|
|
428
|
+
* @property {number} count How many of them
|
|
429
|
+
*/
|
|
430
|
+
/**
|
|
431
|
+
* @typedef {object} Drives The drive technology levels
|
|
432
|
+
* @property {number} [combustion] The Combustion Drive level
|
|
433
|
+
* @property {number} [impulse] The Impulse Drive level
|
|
434
|
+
* @property {number} [hyperspace] The Hyperspace Drive level
|
|
435
|
+
*/
|
|
436
|
+
/**
|
|
437
|
+
* @typedef {object} CombatTechs The combat technology levels
|
|
438
|
+
* @property {number} [weapons] The Weapons Technology level
|
|
439
|
+
* @property {number} [shielding] The Shielding Technology level
|
|
440
|
+
* @property {number} [armour] The Armour Technology level
|
|
441
|
+
*/
|
|
442
|
+
/**
|
|
443
|
+
* @typedef {object} Resources An amount of each resource
|
|
444
|
+
* @property {number} metal Metal
|
|
445
|
+
* @property {number} crystal Crystal
|
|
446
|
+
* @property {number} deuterium Deuterium
|
|
447
|
+
*/
|
|
448
|
+
export {};
|
|
449
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|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;;;GAIG;AAEH;;;;;GAKG;AAEH;;;;;GAKG;AAEH;;;;;GAKG;AAEH,OAAO,EAAE,CAAC"}
|
package/CHANGELOG.md
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
|
-
|
|
5
|
-
### [2.1.3](https://github.com/rolljee/ogamejs/compare/v2.1.2...v2.1.3) (2020-04-16)
|
|
6
|
-
|
|
7
|
-
### [2.1.2](https://github.com/rolljee/ogamejs/compare/v2.1.1...v2.1.2) (2020-04-12)
|
|
8
|
-
|
|
9
|
-
### [2.1.1](https://github.com/rolljee/ogamejs/compare/v2.1.0...v2.1.1) (2020-04-12)
|
|
10
|
-
|
|
11
|
-
### [2.0.4](https://github.com/rolljee/ogamejs/compare/v2.0.3...v2.0.4) (2020-04-08)
|
|
12
|
-
|
|
13
|
-
### [2.0.3](https://github.com/rolljee/ogamejs/compare/v2.0.2...v2.0.3) (2020-04-08)
|
|
14
|
-
|
|
15
|
-
### [2.0.2](https://github.com/rolljee/ogamejs/compare/v2.0.0...v2.0.2) (2020-04-02)
|
|
16
|
-
|
|
17
|
-
## [2.0.0](https://github.com/rolljee/ogamejs/compare/v2.0.0-beta.0...v2.0.0) (2020-03-20)
|
|
18
|
-
|
|
19
|
-
## [2.0.0-beta.0](https://github.com/rolljee/ogamejs/compare/v1.1.2...v2.0.0-beta.0) (2020-03-06)
|
|
20
|
-
|
|
21
|
-
<a name="1.1.2"></a>
|
|
22
|
-
## [1.1.2](https://github.com/rolljee/ogamejs/compare/v1.1.1...v1.1.2) (2019-02-08)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
<a name="1.1.1"></a>
|
|
27
|
-
## [1.1.1](https://github.com/rolljee/ogamejs/compare/v1.1.0...v1.1.1) (2019-01-30)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
### Bug Fixes
|
|
31
|
-
|
|
32
|
-
* 🐛 Fix issues in tests ([82bce05](https://github.com/rolljee/ogamejs/commit/82bce05))
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
<a name="1.1.0"></a>
|
|
37
|
-
# 1.1.0 (2019-01-29)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
### Features
|
|
41
|
-
|
|
42
|
-
* 🎸 added metal and crystal calcul ([07371e0](https://github.com/rolljee/ogamejs/commit/07371e0))
|
|
43
|
-
* 🎸 Rework the way of parsing rates ([aa63c19](https://github.com/rolljee/ogamejs/commit/aa63c19))
|
|
44
|
-
* 🎸 SellDeut & ParseRate ([47b83f2](https://github.com/rolljee/ogamejs/commit/47b83f2))
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
# Change Log
|
|
49
|
-
|
|
50
|
-
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
function getPositionFactor(pos) {
|
|
9
|
-
var factor = {
|
|
10
|
-
1: 1.3,
|
|
11
|
-
2: 1.225,
|
|
12
|
-
3: 1.15
|
|
13
|
-
};
|
|
14
|
-
return factor[Number.parseInt(pos, 10)] ? factor[Number.parseInt(pos, 10)] : 1;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function getMineProduction(baseProduction, targetLevel, pos, universeSpeed) {
|
|
18
|
-
var positionFactor = getPositionFactor(pos);
|
|
19
|
-
var levelFactor = Math.pow(1.1, targetLevel);
|
|
20
|
-
return Math.floor(baseProduction * targetLevel * levelFactor * universeSpeed * positionFactor);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function getEnergyCost(baseEnergyCost, targetLevel) {
|
|
24
|
-
var level = targetLevel;
|
|
25
|
-
var levelFactor = Math.pow(1.1, level);
|
|
26
|
-
return Math.floor(baseEnergyCost * level * levelFactor);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function getMetalCost(baseMetalCost, targetLevel) {
|
|
30
|
-
var level = targetLevel - 1;
|
|
31
|
-
return Math.floor(baseMetalCost * Math.pow(1.6, level));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function getCrystalCost(baseCrystalCost, targetLevel) {
|
|
35
|
-
var level = targetLevel - 1;
|
|
36
|
-
return Math.floor(baseCrystalCost * Math.pow(1.6, level));
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
*
|
|
40
|
-
* Return information about the crystal mine given a specific level
|
|
41
|
-
* @param {object} mine The crystal mine base information
|
|
42
|
-
* @param {number} targetLevel the crystal mine target level
|
|
43
|
-
* @param {number} pos pos 1/2/3 have a 15/10/5%
|
|
44
|
-
* @param {number} universeSpeed production factor is increased for some universe
|
|
45
|
-
* @returns {Object} informations about the crystal mine at this specific level
|
|
46
|
-
*/
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
function getCrystalMine(mine, targetLevel, pos) {
|
|
50
|
-
var universeSpeed = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
51
|
-
return {
|
|
52
|
-
crystal: getCrystalCost(mine.crystal, targetLevel),
|
|
53
|
-
deuterium: 0,
|
|
54
|
-
energy: getEnergyCost(mine.energy, targetLevel),
|
|
55
|
-
metal: getMetalCost(mine.metal, targetLevel),
|
|
56
|
-
production: getMineProduction(mine.production, targetLevel, pos, universeSpeed)
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
var _default = getCrystalMine;
|
|
61
|
-
exports["default"] = _default;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _crystal = _interopRequireDefault(require("./crystal"));
|
|
4
|
-
|
|
5
|
-
var _buildings = _interopRequireDefault(require("../models/buildings"));
|
|
6
|
-
|
|
7
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
8
|
-
|
|
9
|
-
describe('Crystal mine informations should be correctly return when', function () {
|
|
10
|
-
it('Level 30 is given and universe speed is 5 and position is 1', function () {
|
|
11
|
-
var mine = _buildings["default"][2].base;
|
|
12
|
-
var crystalMine = (0, _crystal["default"])(mine, 30, 1, 5);
|
|
13
|
-
expect(crystalMine).toEqual({
|
|
14
|
-
production: 68052,
|
|
15
|
-
energy: 5234,
|
|
16
|
-
metal: 39876839,
|
|
17
|
-
crystal: 19938419,
|
|
18
|
-
deuterium: 0
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
it('Level 30 is given and universe speed is 5 and position is 15', function () {
|
|
22
|
-
var mine = _buildings["default"][2].base;
|
|
23
|
-
var crystalMine = (0, _crystal["default"])(mine, 30, 15, 5);
|
|
24
|
-
expect(crystalMine).toEqual({
|
|
25
|
-
production: 52348,
|
|
26
|
-
energy: 5234,
|
|
27
|
-
metal: 39876839,
|
|
28
|
-
crystal: 19938419,
|
|
29
|
-
deuterium: 0
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
});
|
package/build/buildings/deut.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
|
-
function getPositionFactor(avg) {
|
|
9
|
-
return 0.68 - 0.002 * avg;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function getMineProduction(energyCost, avg, universeSpeed) {
|
|
13
|
-
var factor = getPositionFactor(avg);
|
|
14
|
-
return Math.floor(universeSpeed * energyCost * factor);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function getEnergyCost(baseEnergyCost, targetLevel) {
|
|
18
|
-
var level = targetLevel;
|
|
19
|
-
var levelFactor = Math.pow(1.1, level);
|
|
20
|
-
return Math.floor(baseEnergyCost * level * levelFactor);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function getMetalCost(baseMetalCost, targetLevel) {
|
|
24
|
-
var level = targetLevel - 1;
|
|
25
|
-
return Math.floor(baseMetalCost * Math.pow(1.5, level));
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function getCrystalCost(baseCrystalCost, targetLevel) {
|
|
29
|
-
var level = targetLevel - 1;
|
|
30
|
-
return Math.floor(baseCrystalCost * Math.pow(1.5, level));
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
*
|
|
34
|
-
* Return information about the deuterium synth given a specific level
|
|
35
|
-
* @param {object} mine The deut synth base information
|
|
36
|
-
* @param {number} targetLevel the deuterieum synth target level
|
|
37
|
-
* @param {number} avg planet average temperature - The lower the higher the prod is
|
|
38
|
-
* @param {number} universeSpeed production factor is increased for some universe
|
|
39
|
-
* @returns {Object} informations about the deut synth at this specific level
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
function getDeutSynth(mine, targetLevel, avg) {
|
|
44
|
-
var universeSpeed = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
45
|
-
var energyCost = getEnergyCost(mine.energy, targetLevel);
|
|
46
|
-
return {
|
|
47
|
-
crystal: getCrystalCost(mine.crystal, targetLevel),
|
|
48
|
-
energy: energyCost,
|
|
49
|
-
deuterium: 0,
|
|
50
|
-
metal: getMetalCost(mine.metal, targetLevel),
|
|
51
|
-
production: getMineProduction(energyCost, avg, universeSpeed)
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
var _default = getDeutSynth;
|
|
56
|
-
exports["default"] = _default;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _deut = _interopRequireDefault(require("./deut"));
|
|
4
|
-
|
|
5
|
-
var _buildings = _interopRequireDefault(require("../models/buildings"));
|
|
6
|
-
|
|
7
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
8
|
-
|
|
9
|
-
describe('Deut mine informations should be correctly return when', function () {
|
|
10
|
-
it('Level 30 is given and universe speed is 5 and average temperature is 37', function () {
|
|
11
|
-
var mine = _buildings["default"][3].base;
|
|
12
|
-
var crystalMine = (0, _deut["default"])(mine, 30, 37, 5);
|
|
13
|
-
expect(crystalMine).toEqual({
|
|
14
|
-
production: 31721,
|
|
15
|
-
energy: 10469,
|
|
16
|
-
metal: 28762658,
|
|
17
|
-
crystal: 9587552,
|
|
18
|
-
deuterium: 0
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
it('Level 32 is given and universe speed is 5 and average temperature is 138', function () {
|
|
22
|
-
var mine = _buildings["default"][3].base;
|
|
23
|
-
var crystalMine = (0, _deut["default"])(mine, 31, -138, 5);
|
|
24
|
-
expect(crystalMine).toEqual({
|
|
25
|
-
production: 56882,
|
|
26
|
-
energy: 11900,
|
|
27
|
-
metal: 43143988,
|
|
28
|
-
crystal: 14381329,
|
|
29
|
-
deuterium: 0
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
});
|