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.
Files changed (132) hide show
  1. package/README.md +485 -228
  2. package/package.json +71 -33
  3. package/src/buildings/buildTime.js +25 -0
  4. package/src/buildings/crystal.js +35 -0
  5. package/src/buildings/deut.js +31 -0
  6. package/src/buildings/fusion-reactor.js +35 -0
  7. package/src/buildings/index.js +28 -0
  8. package/src/buildings/info.js +42 -0
  9. package/src/buildings/infocompte.js +150 -0
  10. package/src/buildings/metal.js +26 -0
  11. package/src/buildings/production.js +150 -0
  12. package/src/buildings/solar-plant.js +25 -0
  13. package/src/buildings/storage.js +59 -0
  14. package/src/cost.js +70 -0
  15. package/src/fleets/combat.js +291 -0
  16. package/src/fleets/distance.js +39 -0
  17. package/src/fleets/flight.js +105 -0
  18. package/src/fleets/getDebris.js +21 -0
  19. package/src/fleets/index.js +19 -0
  20. package/src/fleets/speed.js +108 -0
  21. package/src/i18n.js +43 -0
  22. package/src/index.js +28 -0
  23. package/src/models/buildings.js +319 -0
  24. package/src/models/destroyable.js +929 -0
  25. package/src/models/research.js +169 -0
  26. package/src/research/index.js +9 -0
  27. package/src/research/researchTime.js +25 -0
  28. package/src/trades/crystal.js +16 -0
  29. package/src/trades/deut.js +16 -0
  30. package/src/trades/index.js +13 -0
  31. package/src/trades/metal.js +16 -0
  32. package/src/trades/parseRate.js +49 -0
  33. package/src/trades/utils.js +9 -0
  34. package/src/types.js +146 -0
  35. package/types/buildings/buildTime.d.ts +16 -0
  36. package/types/buildings/buildTime.d.ts.map +1 -0
  37. package/types/buildings/crystal.d.ts +12 -0
  38. package/types/buildings/crystal.d.ts.map +1 -0
  39. package/types/buildings/deut.d.ts +12 -0
  40. package/types/buildings/deut.d.ts.map +1 -0
  41. package/types/buildings/fusion-reactor.d.ts +15 -0
  42. package/types/buildings/fusion-reactor.d.ts.map +1 -0
  43. package/types/buildings/index.d.ts +27 -0
  44. package/types/buildings/index.d.ts.map +1 -0
  45. package/types/buildings/info.d.ts +17 -0
  46. package/types/buildings/info.d.ts.map +1 -0
  47. package/types/buildings/infocompte.d.ts +41 -0
  48. package/types/buildings/infocompte.d.ts.map +1 -0
  49. package/types/buildings/metal.d.ts +11 -0
  50. package/types/buildings/metal.d.ts.map +1 -0
  51. package/types/buildings/production.d.ts +78 -0
  52. package/types/buildings/production.d.ts.map +1 -0
  53. package/types/buildings/solar-plant.d.ts +10 -0
  54. package/types/buildings/solar-plant.d.ts.map +1 -0
  55. package/types/buildings/storage.d.ts +29 -0
  56. package/types/buildings/storage.d.ts.map +1 -0
  57. package/types/cost.d.ts +25 -0
  58. package/types/cost.d.ts.map +1 -0
  59. package/types/fleets/combat.d.ts +57 -0
  60. package/types/fleets/combat.d.ts.map +1 -0
  61. package/types/fleets/distance.d.ts +13 -0
  62. package/types/fleets/distance.d.ts.map +1 -0
  63. package/types/fleets/flight.d.ts +57 -0
  64. package/types/fleets/flight.d.ts.map +1 -0
  65. package/types/fleets/getDebris.d.ts +12 -0
  66. package/types/fleets/getDebris.d.ts.map +1 -0
  67. package/types/fleets/index.d.ts +18 -0
  68. package/types/fleets/index.d.ts.map +1 -0
  69. package/types/fleets/speed.d.ts +54 -0
  70. package/types/fleets/speed.d.ts.map +1 -0
  71. package/types/i18n.d.ts +23 -0
  72. package/types/i18n.d.ts.map +1 -0
  73. package/types/index.d.ts +1316 -0
  74. package/types/index.d.ts.map +1 -0
  75. package/types/models/buildings.d.ts +373 -0
  76. package/types/models/buildings.d.ts.map +1 -0
  77. package/types/models/destroyable.d.ts +695 -0
  78. package/types/models/destroyable.d.ts.map +1 -0
  79. package/types/models/research.d.ts +262 -0
  80. package/types/models/research.d.ts.map +1 -0
  81. package/types/research/index.d.ts +8 -0
  82. package/types/research/index.d.ts.map +1 -0
  83. package/types/research/researchTime.d.ts +16 -0
  84. package/types/research/researchTime.d.ts.map +1 -0
  85. package/types/trades/crystal.d.ts +6 -0
  86. package/types/trades/crystal.d.ts.map +1 -0
  87. package/types/trades/deut.d.ts +6 -0
  88. package/types/trades/deut.d.ts.map +1 -0
  89. package/types/trades/index.d.ts +12 -0
  90. package/types/trades/index.d.ts.map +1 -0
  91. package/types/trades/metal.d.ts +6 -0
  92. package/types/trades/metal.d.ts.map +1 -0
  93. package/types/trades/parseRate.d.ts +2 -0
  94. package/types/trades/parseRate.d.ts.map +1 -0
  95. package/types/trades/utils.d.ts +2 -0
  96. package/types/trades/utils.d.ts.map +1 -0
  97. package/types/types.d.ts +449 -0
  98. package/types/types.d.ts.map +1 -0
  99. package/CHANGELOG.md +0 -50
  100. package/build/buildings/crystal.js +0 -61
  101. package/build/buildings/crystal.test.js +0 -32
  102. package/build/buildings/deut.js +0 -56
  103. package/build/buildings/deut.test.js +0 -32
  104. package/build/buildings/fusion-reactor.js +0 -60
  105. package/build/buildings/fusion-reactor.test.js +0 -22
  106. package/build/buildings/index.js +0 -31
  107. package/build/buildings/infocompte.js +0 -150
  108. package/build/buildings/infocompte.test.js +0 -107
  109. package/build/buildings/metal.js +0 -50
  110. package/build/buildings/metal.test.js +0 -32
  111. package/build/buildings/solar-plant.js +0 -42
  112. package/build/buildings/solar-plant.test.js +0 -21
  113. package/build/fleets/getDebris.js +0 -27
  114. package/build/fleets/getDebris.test.js +0 -26
  115. package/build/fleets/index.js +0 -16
  116. package/build/index.js +0 -30
  117. package/build/models/buildings.js +0 -65
  118. package/build/models/destroyable.js +0 -730
  119. package/build/trades/crystal.js +0 -33
  120. package/build/trades/crystal.test.js +0 -16
  121. package/build/trades/deut.js +0 -33
  122. package/build/trades/deut.test.js +0 -16
  123. package/build/trades/index.js +0 -25
  124. package/build/trades/metal.js +0 -33
  125. package/build/trades/metal.test.js +0 -16
  126. package/build/trades/parseRate.js +0 -60
  127. package/build/trades/parseRate.test.js +0 -40
  128. package/build/trades/trades.js +0 -119
  129. package/build/trades/trades.test.js +0 -65
  130. package/build/trades/utils.js +0 -17
  131. package/build/trades/utils.test.js +0 -16
  132. package/build/winston.js +0 -16
@@ -0,0 +1,169 @@
1
+ const CATEGORIES = Object.freeze({
2
+ BASIC: 'basic',
3
+ DRIVE: 'drive',
4
+ ADVANCED: 'advanced',
5
+ COMBAT: 'combat',
6
+ });
7
+
8
+ /**
9
+ * Every technology of the game, keyed by its official OGame id.
10
+ *
11
+ * Same shape as `models/buildings.js`: `names` for the localised labels,
12
+ * `base` for the level 1 cost and `factor` for the per-level multiplier —
13
+ * cost(level) = base * factor ** (level - 1).
14
+ *
15
+ * `base.energyCost` is only non zero for Graviton technology, which is paid
16
+ * entirely in energy.
17
+ */
18
+ const RESEARCH = Object.freeze({
19
+ 106: {
20
+ ogameId: 106,
21
+ names: { en: 'Espionage Technology', fr: 'Technologie Espionnage' },
22
+ category: CATEGORIES.BASIC,
23
+ factor: 2,
24
+ base: {
25
+ metal: 200, crystal: 1000, deuterium: 200, energyCost: 0,
26
+ },
27
+ },
28
+ 108: {
29
+ ogameId: 108,
30
+ names: { en: 'Computer Technology', fr: 'Technologie Ordinateur' },
31
+ category: CATEGORIES.BASIC,
32
+ factor: 2,
33
+ base: {
34
+ metal: 0, crystal: 400, deuterium: 600, energyCost: 0,
35
+ },
36
+ },
37
+ 109: {
38
+ ogameId: 109,
39
+ names: { en: 'Weapons Technology', fr: 'Technologie Armes' },
40
+ category: CATEGORIES.COMBAT,
41
+ factor: 2,
42
+ base: {
43
+ metal: 800, crystal: 200, deuterium: 0, energyCost: 0,
44
+ },
45
+ },
46
+ 110: {
47
+ ogameId: 110,
48
+ names: { en: 'Shielding Technology', fr: 'Technologie Bouclier' },
49
+ category: CATEGORIES.COMBAT,
50
+ factor: 2,
51
+ base: {
52
+ metal: 200, crystal: 600, deuterium: 0, energyCost: 0,
53
+ },
54
+ },
55
+ 111: {
56
+ ogameId: 111,
57
+ names: { en: 'Armour Technology', fr: 'Technologie Protection des vaisseaux spatiaux' },
58
+ category: CATEGORIES.COMBAT,
59
+ factor: 2,
60
+ base: {
61
+ metal: 1000, crystal: 0, deuterium: 0, energyCost: 0,
62
+ },
63
+ },
64
+ 113: {
65
+ ogameId: 113,
66
+ names: { en: 'Energy Technology', fr: 'Technologie Énergie' },
67
+ category: CATEGORIES.BASIC,
68
+ factor: 2,
69
+ base: {
70
+ metal: 0, crystal: 800, deuterium: 400, energyCost: 0,
71
+ },
72
+ },
73
+ 114: {
74
+ ogameId: 114,
75
+ names: { en: 'Hyperspace Technology', fr: 'Technologie Hyperespace' },
76
+ category: CATEGORIES.ADVANCED,
77
+ factor: 2,
78
+ base: {
79
+ metal: 0, crystal: 4000, deuterium: 2000, energyCost: 0,
80
+ },
81
+ },
82
+ 115: {
83
+ ogameId: 115,
84
+ names: { en: 'Combustion Drive', fr: 'Réacteur à combustion' },
85
+ category: CATEGORIES.DRIVE,
86
+ factor: 2,
87
+ base: {
88
+ metal: 400, crystal: 0, deuterium: 600, energyCost: 0,
89
+ },
90
+ },
91
+ 117: {
92
+ ogameId: 117,
93
+ names: { en: 'Impulse Drive', fr: 'Réacteur à impulsion' },
94
+ category: CATEGORIES.DRIVE,
95
+ factor: 2,
96
+ base: {
97
+ metal: 2000, crystal: 4000, deuterium: 600, energyCost: 0,
98
+ },
99
+ },
100
+ 118: {
101
+ ogameId: 118,
102
+ names: { en: 'Hyperspace Drive', fr: 'Propulsion hyperespace' },
103
+ category: CATEGORIES.DRIVE,
104
+ factor: 2,
105
+ base: {
106
+ metal: 10000, crystal: 20000, deuterium: 6000, energyCost: 0,
107
+ },
108
+ },
109
+ 120: {
110
+ ogameId: 120,
111
+ names: { en: 'Laser Technology', fr: 'Technologie Laser' },
112
+ category: CATEGORIES.COMBAT,
113
+ factor: 2,
114
+ base: {
115
+ metal: 200, crystal: 100, deuterium: 0, energyCost: 0,
116
+ },
117
+ },
118
+ 121: {
119
+ ogameId: 121,
120
+ names: { en: 'Ion Technology', fr: 'Technologie Ions' },
121
+ category: CATEGORIES.COMBAT,
122
+ factor: 2,
123
+ base: {
124
+ metal: 1000, crystal: 300, deuterium: 100, energyCost: 0,
125
+ },
126
+ },
127
+ 122: {
128
+ ogameId: 122,
129
+ names: { en: 'Plasma Technology', fr: 'Technologie Plasma' },
130
+ category: CATEGORIES.COMBAT,
131
+ factor: 2,
132
+ base: {
133
+ metal: 2000, crystal: 4000, deuterium: 1000, energyCost: 0,
134
+ },
135
+ },
136
+ 123: {
137
+ ogameId: 123,
138
+ names: { en: 'Intergalactic Research Network', fr: 'Réseau de recherche intergalactique' },
139
+ category: CATEGORIES.ADVANCED,
140
+ factor: 2,
141
+ base: {
142
+ metal: 240000, crystal: 400000, deuterium: 160000, energyCost: 0,
143
+ },
144
+ },
145
+ 124: {
146
+ ogameId: 124,
147
+ names: { en: 'Astrophysics', fr: 'Astrophysique' },
148
+ category: CATEGORIES.ADVANCED,
149
+ // Astrophysics is the only technology with a non-integer factor; the game
150
+ // also rounds each level cost up to the nearest hundred.
151
+ factor: 1.75,
152
+ roundTo: 100,
153
+ base: {
154
+ metal: 4000, crystal: 8000, deuterium: 4000, energyCost: 0,
155
+ },
156
+ },
157
+ 199: {
158
+ ogameId: 199,
159
+ names: { en: 'Graviton Technology', fr: 'Technologie Graviton' },
160
+ category: CATEGORIES.ADVANCED,
161
+ factor: 3,
162
+ base: {
163
+ metal: 0, crystal: 0, deuterium: 0, energyCost: 300000,
164
+ },
165
+ },
166
+ });
167
+
168
+ export { CATEGORIES };
169
+ export default RESEARCH;
@@ -0,0 +1,9 @@
1
+ import getCost from '../cost.js';
2
+ import getResearchTime from './researchTime.js';
3
+
4
+ const Research = {
5
+ getResearchCost: getCost,
6
+ getResearchTime,
7
+ };
8
+
9
+ export default Research;
@@ -0,0 +1,25 @@
1
+ import getCost, { assertLevel } from '../cost.js';
2
+
3
+ /**
4
+ *
5
+ * Return the time needed to research a technology at a given level
6
+ *
7
+ * time = (metal + crystal) / (1000 * (1 + labs)) hours, divided by the
8
+ * universe research speed. `labs` is the research lab level, or the sum of
9
+ * every connected lab when the Intergalactic Research Network is up.
10
+ * @param {import('../types.js').ResearchEntry} research A models/research.js entry
11
+ * @param {number} targetLevel The level to reach, >= 1
12
+ * @param {number} [labLevel] The research lab level, or the sum of connected labs
13
+ * @param {number} [researchSpeed] The universe research speed
14
+ * @returns {number} The research time, in seconds
15
+ */
16
+ function getResearchTime(research, targetLevel, labLevel = 0, researchSpeed = 1) {
17
+ assertLevel(targetLevel);
18
+
19
+ const { metal, crystal } = getCost(research, targetLevel);
20
+ const divider = 1000 * (1 + labLevel) * researchSpeed;
21
+
22
+ return Math.round(((metal + crystal) / divider) * 3600);
23
+ }
24
+
25
+ export default getResearchTime;
@@ -0,0 +1,16 @@
1
+ import parseRate from './parseRate.js';
2
+
3
+ function sellCrystal(crystal = 0, percentD = 40, percentM = 60, rate = '2:1.5:1') {
4
+ const pDeut = percentD / 100;
5
+ const pMetal = percentM / 100;
6
+ const { rateDeut, rateMetal } = parseRate(rate, 'crystal');
7
+ const deut = pDeut * rateDeut * crystal;
8
+ const metal = pMetal * rateMetal * crystal;
9
+
10
+ return {
11
+ deut: Math.round(deut),
12
+ metal: Math.round(metal),
13
+ };
14
+ }
15
+
16
+ export default sellCrystal;
@@ -0,0 +1,16 @@
1
+ import parseRate from './parseRate.js';
2
+
3
+ function sellDeut(deut = 0, percentM = 60, percentC = 40, rate = '2:1.5:1') {
4
+ const pMetal = percentM / 100;
5
+ const pCrystal = percentC / 100;
6
+ const { rateMetal, rateCrystal } = parseRate(rate, 'deut');
7
+ const metal = pMetal * rateMetal * deut;
8
+ const crystal = pCrystal * rateCrystal * deut;
9
+
10
+ return {
11
+ metal: Math.round(metal),
12
+ crystal: Math.round(crystal),
13
+ };
14
+ }
15
+
16
+ export default sellDeut;
@@ -0,0 +1,13 @@
1
+ import parseRate from './parseRate.js';
2
+ import sellDeut from './deut.js';
3
+ import sellCrystal from './crystal.js';
4
+ import sellMetal from './metal.js';
5
+
6
+ const Trader = {
7
+ parseRate,
8
+ sellDeut,
9
+ sellCrystal,
10
+ sellMetal,
11
+ };
12
+
13
+ export default Trader;
@@ -0,0 +1,16 @@
1
+ import parseRate from './parseRate.js';
2
+
3
+ function sellMetal(metal = 0, percentD = 40, percentC = 60, rate = '2:1.5:1') {
4
+ const pDeut = percentD / 100;
5
+ const pCrystal = percentC / 100;
6
+ const { rateDeut, rateCrystal } = parseRate(rate, 'metal');
7
+ const deut = pDeut * rateDeut * metal;
8
+ const crystal = pCrystal * rateCrystal * metal;
9
+
10
+ return {
11
+ deut: Math.round(deut),
12
+ crystal: Math.round(crystal),
13
+ };
14
+ }
15
+
16
+ export default sellMetal;
@@ -0,0 +1,49 @@
1
+ import hasNaN from './utils.js';
2
+
3
+ function extract(rate, type) {
4
+ let res = {};
5
+ const split = rate.split(':').map(Number);
6
+ const metal = split[0];
7
+ const crystal = split[1];
8
+ const deut = split[2];
9
+
10
+ if (type === 'metal') {
11
+ res = {
12
+ rateMetal: 1,
13
+ rateCrystal: crystal / metal,
14
+ rateDeut: deut / metal,
15
+ };
16
+ } else if (type === 'crystal') {
17
+ res = {
18
+ rateMetal: metal / crystal,
19
+ rateCrystal: 1,
20
+ rateDeut: deut / crystal,
21
+ };
22
+ } else if (type === 'deut') {
23
+ res = {
24
+ rateMetal: metal,
25
+ rateCrystal: crystal,
26
+ rateDeut: 1,
27
+ };
28
+ } else {
29
+ throw new Error(`${type} is not part of the game, try one of metal, crystal, deut`);
30
+ }
31
+
32
+ return res;
33
+ }
34
+
35
+ export default function parseRate(rate = '2:1.5:1', type = 'deut') {
36
+ const split = rate.split(':');
37
+
38
+ if (split.length !== 3) {
39
+ throw new Error('rate not parsed correctly');
40
+ }
41
+
42
+ const res = extract(rate, type);
43
+
44
+ if (hasNaN(Object.values(res))) {
45
+ throw new Error('rate not parsed correctly');
46
+ }
47
+
48
+ return res;
49
+ }
@@ -0,0 +1,9 @@
1
+ export default function hasNaN(args) {
2
+ let response = false;
3
+ args.forEach((val) => {
4
+ if (Number.isNaN(Number(val))) {
5
+ response = true;
6
+ }
7
+ });
8
+ return response;
9
+ }
package/src/types.js ADDED
@@ -0,0 +1,146 @@
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
+
11
+ /**
12
+ * @typedef {'en' | 'fr'} Lang A supported language
13
+ */
14
+
15
+ /**
16
+ * @typedef {object} Names
17
+ * @property {string} en The English name
18
+ * @property {string} fr The French name
19
+ */
20
+
21
+ /**
22
+ * @typedef {object} BuildingBase The level 1 values of a building
23
+ * @property {number} metal Metal paid to build it
24
+ * @property {number} crystal Crystal paid to build it
25
+ * @property {number} deuterium Deuterium paid to build it
26
+ * @property {number} energyCost Energy paid to build it
27
+ * @property {number} energyConsumption Energy it consumes once built
28
+ * @property {number} deuteriumConsumption Deuterium it burns once built
29
+ * @property {number} production What it produces, resources or energy
30
+ */
31
+
32
+ /**
33
+ * @typedef {object} BuildingEntry An entry of `models/buildings.js`
34
+ * @property {number} ogameId The id OGame itself uses
35
+ * @property {Names} names The localised labels
36
+ * @property {string} category `resources`, `facilities` or `moon`
37
+ * @property {number} factor The per-level cost multiplier
38
+ * @property {BuildingBase} base The level 1 values
39
+ * @property {number} [energyFactor] A separate multiplier for the energy cost
40
+ * @property {string} [storage] The resource it stores, on storage buildings only
41
+ */
42
+
43
+ /**
44
+ * @typedef {object} ResearchBase The level 1 cost of a technology
45
+ * @property {number} metal Metal cost
46
+ * @property {number} crystal Crystal cost
47
+ * @property {number} deuterium Deuterium cost
48
+ * @property {number} energyCost Energy cost, Graviton technology only
49
+ */
50
+
51
+ /**
52
+ * @typedef {object} ResearchEntry An entry of `models/research.js`
53
+ * @property {number} ogameId The id OGame itself uses
54
+ * @property {Names} names The localised labels
55
+ * @property {string} category `basic`, `drive`, `advanced` or `combat`
56
+ * @property {number} factor The per-level cost multiplier
57
+ * @property {ResearchBase} base The level 1 cost
58
+ * @property {number} [roundTo] Rounding step, Astrophysics only
59
+ */
60
+
61
+ /**
62
+ * @typedef {object} Cost The resources a level costs
63
+ * @property {number} metal Metal cost
64
+ * @property {number} crystal Crystal cost
65
+ * @property {number} deuterium Deuterium cost
66
+ * @property {number} energyCost Energy cost
67
+ */
68
+
69
+ /**
70
+ * @typedef {object} BuildingInfo Everything about a building at a given level
71
+ * @property {number} metal Metal paid to reach that level
72
+ * @property {number} crystal Crystal paid to reach that level
73
+ * @property {number} deuterium Deuterium paid to reach that level
74
+ * @property {number} energyCost Energy paid to reach that level
75
+ * @property {number} energyConsumption Energy consumed at that level
76
+ * @property {number} deuteriumConsumption Deuterium burned at that level
77
+ * @property {number} production Resources, or energy, produced at that level
78
+ */
79
+
80
+ /**
81
+ * @typedef {object} RapidFire A rapid-fire bonus against another unit
82
+ * @property {number} target The library id of the unit it applies to
83
+ * @property {number} fire How many shots it can chain
84
+ */
85
+
86
+ /**
87
+ * @typedef {object} DriveUpgrade A better drive a ship switches to
88
+ * @property {string} drive The drive it moves to
89
+ * @property {number} minLevel The drive level that unlocks it
90
+ * @property {number} speed The new base speed
91
+ * @property {number} fuelConsumption The new base fuel consumption
92
+ */
93
+
94
+ /**
95
+ * @typedef {object} DestroyableEntry An entry of `models/destroyable.js`
96
+ * @property {number} ogameId The id OGame itself uses
97
+ * @property {Names} names The localised labels
98
+ * @property {number} structure The metal plus crystal cost, hull is a tenth of it
99
+ * @property {number} shield The base shield
100
+ * @property {number} attack The base attack
101
+ * @property {number} speed The base speed, before any drive bonus
102
+ * @property {number} cargo The cargo capacity
103
+ * @property {number} fuelConsumption The base deuterium burned
104
+ * @property {string} drive The drive powering it
105
+ * @property {string} type `attack`, `civil` or `defense`
106
+ * @property {string} category `ships`, `defenses` or `missiles`
107
+ * @property {RapidFire[]} rapidFire Its rapid-fire table
108
+ * @property {{metal: number, crystal: number, deuterium: number}} cost What it costs to build
109
+ * @property {DriveUpgrade[]} [driveUpgrades] The drives it can switch to
110
+ */
111
+
112
+ /**
113
+ * @typedef {object} Coordinates A place in the universe
114
+ * @property {number} galaxy The galaxy
115
+ * @property {number} system The system
116
+ * @property {number} position The position in the system
117
+ */
118
+
119
+ /**
120
+ * @typedef {object} FleetEntry A group of identical ships
121
+ * @property {DestroyableEntry} ship The ship
122
+ * @property {number} count How many of them
123
+ */
124
+
125
+ /**
126
+ * @typedef {object} Drives The drive technology levels
127
+ * @property {number} [combustion] The Combustion Drive level
128
+ * @property {number} [impulse] The Impulse Drive level
129
+ * @property {number} [hyperspace] The Hyperspace Drive level
130
+ */
131
+
132
+ /**
133
+ * @typedef {object} CombatTechs The combat technology levels
134
+ * @property {number} [weapons] The Weapons Technology level
135
+ * @property {number} [shielding] The Shielding Technology level
136
+ * @property {number} [armour] The Armour Technology level
137
+ */
138
+
139
+ /**
140
+ * @typedef {object} Resources An amount of each resource
141
+ * @property {number} metal Metal
142
+ * @property {number} crystal Crystal
143
+ * @property {number} deuterium Deuterium
144
+ */
145
+
146
+ export {};
@@ -0,0 +1,16 @@
1
+ /**
2
+ *
3
+ * Return the time needed to build a building at a given level
4
+ *
5
+ * time = (metal + crystal) / (2500 * (1 + robotics) * 2 ** nanites) hours,
6
+ * divided by the universe economy speed.
7
+ * @param {import('../types.js').BuildingEntry} building A models/buildings.js entry
8
+ * @param {number} targetLevel The level to reach, >= 1
9
+ * @param {number} [roboticsLevel] The robotics factory level on that planet
10
+ * @param {number} [naniteLevel] The nanite factory level on that planet
11
+ * @param {number} [universeSpeed] The universe economy speed
12
+ * @returns {number} The build time, in seconds
13
+ */
14
+ declare function getBuildTime(building: import('../types.js').BuildingEntry, targetLevel: number, roboticsLevel?: number, naniteLevel?: number, universeSpeed?: number): number;
15
+ export default getBuildTime;
16
+ //# sourceMappingURL=buildTime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildTime.d.ts","sourceRoot":"","sources":["../../src/buildings/buildTime.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,iBAAS,YAAY,CAAC,QAAQ,EAPnB,OAAO,aAAa,EAAE,aAOH,EAAE,WAAW,EANhC,MAMgC,EAAE,aAAa,AALvD,CACA,EADQ,MAKmD,EAAE,WAAW,AAJxE,CACA,EADQ,MAIoE,EAAE,aAAa,AAH3F,CACA,EADQ,MAGuF,GAFrF,MAAM,CASlB;eAEc,YAAY"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ *
3
+ * Return information about the crystal mine at a given level
4
+ * @param {import('../types.js').BuildingEntry} mine The crystal mine entry, `Buildings[2]`
5
+ * @param {number} targetLevel The level to reach, >= 1
6
+ * @param {number} pos The planet position, 1, 2 and 3 produce more crystal
7
+ * @param {number} [universeSpeed] Production is increased on faster universes
8
+ * @returns {import('../types.js').BuildingInfo} Cost, consumption and production at that level
9
+ */
10
+ declare function getCrystalMine(mine: import('../types.js').BuildingEntry, targetLevel: number, pos: number, universeSpeed?: number): import('../types.js').BuildingInfo;
11
+ export default getCrystalMine;
12
+ //# sourceMappingURL=crystal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crystal.d.ts","sourceRoot":"","sources":["../../src/buildings/crystal.js"],"names":[],"mappings":"AAgBA;;;;;;;;GAQG;AACH,iBAAS,cAAc,CAAC,IAAI,EANjB,OAAO,aAAa,EAAE,aAML,EAAE,WAAW,EAL9B,MAK8B,EAAE,GAAG,EAJnC,MAImC,EAAE,aAAa,AAH1D,CACA,EADQ,MAGsD,GAFpD,OAAO,aAAa,EAAE,YAAY,CAS9C;eAEc,cAAc"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ *
3
+ * Return information about the deuterium synthesizer at a given level
4
+ * @param {import('../types.js').BuildingEntry} mine The deuterium synthesizer entry, `Buildings[3]`
5
+ * @param {number} targetLevel The level to reach, >= 1
6
+ * @param {number} avg The planet average temperature, the lower the higher the production
7
+ * @param {number} [universeSpeed] Production is increased on faster universes
8
+ * @returns {import('../types.js').BuildingInfo} Cost, consumption and production at that level
9
+ */
10
+ declare function getDeutSynth(mine: import('../types.js').BuildingEntry, targetLevel: number, avg: number, universeSpeed?: number): import('../types.js').BuildingInfo;
11
+ export default getDeutSynth;
12
+ //# sourceMappingURL=deut.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deut.d.ts","sourceRoot":"","sources":["../../src/buildings/deut.js"],"names":[],"mappings":"AAWA;;;;;;;;GAQG;AACH,iBAAS,YAAY,CAAC,IAAI,EANf,OAAO,aAAa,EAAE,aAMP,EAAE,WAAW,EAL5B,MAK4B,EAAE,GAAG,EAJjC,MAIiC,EAAE,aAAa,AAHxD,CACA,EADQ,MAGoD,GAFlD,OAAO,aAAa,EAAE,YAAY,CAU9C;eAEc,YAAY"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ *
3
+ * Return information about the fusion reactor at a given level
4
+ *
5
+ * `deuteriumConsumption` is the deuterium the reactor burns per hour, and
6
+ * `production` the energy it delivers.
7
+ * @param {import('../types.js').BuildingEntry} reactor The fusion reactor entry, `Buildings[5]`
8
+ * @param {number} targetLevel The level to reach, >= 1
9
+ * @param {number} energyTech The Energy Technology level
10
+ * @param {number} [universeSpeed] Consumption is increased on faster universes
11
+ * @returns {import('../types.js').BuildingInfo} Cost, deuterium consumption and energy production
12
+ */
13
+ declare function getFusionReactor(reactor: import('../types.js').BuildingEntry, targetLevel: number, energyTech: number, universeSpeed?: number): import('../types.js').BuildingInfo;
14
+ export default getFusionReactor;
15
+ //# sourceMappingURL=fusion-reactor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fusion-reactor.d.ts","sourceRoot":"","sources":["../../src/buildings/fusion-reactor.js"],"names":[],"mappings":"AAaA;;;;;;;;;;;GAWG;AACH,iBAAS,gBAAgB,CAAC,OAAO,EANtB,OAAO,aAAa,EAAE,aAMA,EAAE,WAAW,EALnC,MAKmC,EAAE,UAAU,EAJ/C,MAI+C,EAAE,aAAa,AAHtE,CACA,EADQ,MAGkE,GAFhE,OAAO,aAAa,EAAE,YAAY,CAS9C;eAEc,gBAAgB"}
@@ -0,0 +1,27 @@
1
+ import getCrystalMine from './crystal.js';
2
+ import getDeutSynth from './deut.js';
3
+ import getMetalMine from './metal.js';
4
+ import getSolarPlant from './solar-plant.js';
5
+ import getFusionReactor from './fusion-reactor.js';
6
+ import parseInfoCompteData from './infocompte.js';
7
+ import getCost from '../cost.js';
8
+ import getStorage, { getStorageCapacity, getStorageLevelFor } from './storage.js';
9
+ import getBuildTime from './buildTime.js';
10
+ import getPlanetProduction, { getProductionBonus } from './production.js';
11
+ declare const Buildings: {
12
+ getCrystalMine: typeof getCrystalMine;
13
+ getDeutSynth: typeof getDeutSynth;
14
+ getMetalMine: typeof getMetalMine;
15
+ getSolarPlant: typeof getSolarPlant;
16
+ getFusionReactor: typeof getFusionReactor;
17
+ parseInfoCompteData: typeof parseInfoCompteData;
18
+ getBuildingCost: typeof getCost;
19
+ getBuildTime: typeof getBuildTime;
20
+ getStorage: typeof getStorage;
21
+ getStorageCapacity: typeof getStorageCapacity;
22
+ getStorageLevelFor: typeof getStorageLevelFor;
23
+ getPlanetProduction: typeof getPlanetProduction;
24
+ getProductionBonus: typeof getProductionBonus;
25
+ };
26
+ export default Buildings;
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/buildings/index.js"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,cAAc,CAAC;AAC1C,OAAO,YAAY,MAAM,WAAW,CAAC;AACrC,OAAO,YAAY,MAAM,YAAY,CAAC;AACtC,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AACnD,OAAO,mBAAmB,MAAM,iBAAiB,CAAC;AAClD,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,UAAU,EAAE,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClF,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,mBAAmB,EAAE,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1E,QAAA,MAAM,SAAS;;;;;;;;;;;;;;CAcd,CAAC;eAEa,SAAS"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ *
3
+ * Assemble the information every building calculator returns
4
+ *
5
+ * Keeping a single shape means a caller can read `production` or
6
+ * `energyConsumption` without knowing which building it is looking at; the
7
+ * fields that do not apply are simply `0`.
8
+ * @param {import('../types.js').BuildingEntry} entry A models/buildings.js entry
9
+ * @param {number} targetLevel The level to reach, >= 1
10
+ * @param {number} universeSpeed The universe economy speed
11
+ * @param {(base: object, flows: object) => number} computeProduction Production of
12
+ * that building, given its base stats and its already computed consumptions
13
+ * @returns {import('../types.js').BuildingInfo} The full picture of that building at that level
14
+ */
15
+ declare function buildingInfo(entry: import('../types.js').BuildingEntry, targetLevel: number, universeSpeed: number, computeProduction: (base: object, flows: object) => number): import('../types.js').BuildingInfo;
16
+ export default buildingInfo;
17
+ //# sourceMappingURL=info.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"info.d.ts","sourceRoot":"","sources":["../../src/buildings/info.js"],"names":[],"mappings":"AASA;;;;;;;;;;;;;GAaG;AACH,iBAAS,YAAY,CAAC,KAAK,EAPhB,OAAO,aAAa,EAAE,aAON,EAAE,WAAW,EAN7B,MAM6B,EAAE,aAAa,EAL5C,MAK4C,EAAE,iBAAiB,EAJ/D,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAI8B,GAF7D,OAAO,aAAa,EAAE,YAAY,CAkB9C;eAEc,YAAY"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Labels used by the Infocompte export, per game language.
3
+ *
4
+ * The French set is the reference one; the others are best effort. A locale can
5
+ * be overridden per call through the `labels` option, so an unsupported
6
+ * language does not require a release.
7
+ */
8
+ declare const LOCALES: Readonly<{
9
+ fr: {
10
+ planet: string;
11
+ metalPoints: string;
12
+ crystalPoints: string;
13
+ deutPoints: string;
14
+ plasma: string;
15
+ hourly: string;
16
+ };
17
+ en: {
18
+ planet: string;
19
+ metalPoints: string;
20
+ crystalPoints: string;
21
+ deutPoints: string;
22
+ plasma: string;
23
+ hourly: string;
24
+ };
25
+ }>;
26
+ /**
27
+ *
28
+ * Parse the BBCode of an Infocompte report into a structured object
29
+ * @param {string} data The infocompte bb-code
30
+ * @param {object} [options] Parsing options
31
+ * @param {string} [options.locale] Force a locale instead of reading it from the report
32
+ * @param {object} [options.labels] Override the labels, see LOCALES for the shape
33
+ * @returns {Object} The parsed JSON object of infocompte
34
+ */
35
+ declare function parseInfoCompteData(data: string, options?: {
36
+ locale?: string;
37
+ labels?: object;
38
+ }): Object;
39
+ export { LOCALES };
40
+ export default parseInfoCompteData;
41
+ //# sourceMappingURL=infocompte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"infocompte.d.ts","sourceRoot":"","sources":["../../src/buildings/infocompte.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,QAAA,MAAM,OAAO;;QAET,MAAM;QACN,WAAW;QACX,aAAa;QACb,UAAU;QACV,MAAM;QACN,MAAM;;;QAGN,MAAM;QACN,WAAW;QACX,aAAa;QACb,UAAU;QACV,MAAM;QACN,MAAM;;EAER,CAAC;AAsDH;;;;;;;;GAQG;AACH,iBAAS,mBAAmB,CAAC,IAAI,EANtB,MAMsB,EAAE,OAAO,AALvC,CAGA,EAFA;IAAyB,MAAM,AAA/B,CACA,EADQ,MAAM,CACd;IAAyB,MAAM,AAA/B,CACA,EADQ,MAAM,CACd;CAE4C,GAFlC,MAAM,CA6DlB;AAED,OAAO,EAAE,OAAO,EAAE,CAAC;eACJ,mBAAmB"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ *
3
+ * Return information about the metal mine at a given level
4
+ * @param {import('../types.js').BuildingEntry} mine The metal mine entry, `Buildings[1]`
5
+ * @param {number} targetLevel The level to reach, >= 1
6
+ * @param {number} [universeSpeed] Production is increased on faster universes
7
+ * @returns {import('../types.js').BuildingInfo} Cost, consumption and production at that level
8
+ */
9
+ declare function getMetalMine(mine: import('../types.js').BuildingEntry, targetLevel: number, universeSpeed?: number): import('../types.js').BuildingInfo;
10
+ export default getMetalMine;
11
+ //# sourceMappingURL=metal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metal.d.ts","sourceRoot":"","sources":["../../src/buildings/metal.js"],"names":[],"mappings":"AAQA;;;;;;;GAOG;AACH,iBAAS,YAAY,CAAC,IAAI,EALf,OAAO,aAAa,EAAE,aAKP,EAAE,WAAW,EAJ5B,MAI4B,EAAE,aAAa,AAHnD,CACA,EADQ,MAG+C,GAF7C,OAAO,aAAa,EAAE,YAAY,CAS9C;eAEc,YAAY"}