ogamejs 3.0.0 → 4.0.1

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 (93) hide show
  1. package/README.md +492 -228
  2. package/package.json +51 -4
  3. package/src/buildings/buildTime.js +25 -0
  4. package/src/buildings/crystal.js +18 -36
  5. package/src/buildings/deut.js +19 -34
  6. package/src/buildings/fusion-reactor.js +19 -34
  7. package/src/buildings/index.js +11 -0
  8. package/src/buildings/info.js +42 -0
  9. package/src/buildings/infocompte.js +116 -57
  10. package/src/buildings/metal.js +13 -28
  11. package/src/buildings/production.js +150 -0
  12. package/src/buildings/solar-plant.js +13 -21
  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 +11 -10
  19. package/src/fleets/index.js +12 -0
  20. package/src/fleets/speed.js +108 -0
  21. package/src/i18n.js +43 -0
  22. package/src/index.js +12 -1
  23. package/src/models/buildings.js +285 -25
  24. package/src/models/destroyable.js +216 -110
  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/parseRate.js +7 -2
  29. package/src/types.js +146 -0
  30. package/types/buildings/buildTime.d.ts +16 -0
  31. package/types/buildings/buildTime.d.ts.map +1 -0
  32. package/types/buildings/crystal.d.ts +12 -0
  33. package/types/buildings/crystal.d.ts.map +1 -0
  34. package/types/buildings/deut.d.ts +12 -0
  35. package/types/buildings/deut.d.ts.map +1 -0
  36. package/types/buildings/fusion-reactor.d.ts +15 -0
  37. package/types/buildings/fusion-reactor.d.ts.map +1 -0
  38. package/types/buildings/index.d.ts +27 -0
  39. package/types/buildings/index.d.ts.map +1 -0
  40. package/types/buildings/info.d.ts +17 -0
  41. package/types/buildings/info.d.ts.map +1 -0
  42. package/types/buildings/infocompte.d.ts +41 -0
  43. package/types/buildings/infocompte.d.ts.map +1 -0
  44. package/types/buildings/metal.d.ts +11 -0
  45. package/types/buildings/metal.d.ts.map +1 -0
  46. package/types/buildings/production.d.ts +78 -0
  47. package/types/buildings/production.d.ts.map +1 -0
  48. package/types/buildings/solar-plant.d.ts +10 -0
  49. package/types/buildings/solar-plant.d.ts.map +1 -0
  50. package/types/buildings/storage.d.ts +29 -0
  51. package/types/buildings/storage.d.ts.map +1 -0
  52. package/types/cost.d.ts +25 -0
  53. package/types/cost.d.ts.map +1 -0
  54. package/types/fleets/combat.d.ts +57 -0
  55. package/types/fleets/combat.d.ts.map +1 -0
  56. package/types/fleets/distance.d.ts +13 -0
  57. package/types/fleets/distance.d.ts.map +1 -0
  58. package/types/fleets/flight.d.ts +57 -0
  59. package/types/fleets/flight.d.ts.map +1 -0
  60. package/types/fleets/getDebris.d.ts +12 -0
  61. package/types/fleets/getDebris.d.ts.map +1 -0
  62. package/types/fleets/index.d.ts +18 -0
  63. package/types/fleets/index.d.ts.map +1 -0
  64. package/types/fleets/speed.d.ts +54 -0
  65. package/types/fleets/speed.d.ts.map +1 -0
  66. package/types/i18n.d.ts +23 -0
  67. package/types/i18n.d.ts.map +1 -0
  68. package/types/index.d.ts +1316 -0
  69. package/types/index.d.ts.map +1 -0
  70. package/types/models/buildings.d.ts +373 -0
  71. package/types/models/buildings.d.ts.map +1 -0
  72. package/types/models/destroyable.d.ts +695 -0
  73. package/types/models/destroyable.d.ts.map +1 -0
  74. package/types/models/research.d.ts +262 -0
  75. package/types/models/research.d.ts.map +1 -0
  76. package/types/research/index.d.ts +8 -0
  77. package/types/research/index.d.ts.map +1 -0
  78. package/types/research/researchTime.d.ts +16 -0
  79. package/types/research/researchTime.d.ts.map +1 -0
  80. package/types/trades/crystal.d.ts +6 -0
  81. package/types/trades/crystal.d.ts.map +1 -0
  82. package/types/trades/deut.d.ts +6 -0
  83. package/types/trades/deut.d.ts.map +1 -0
  84. package/types/trades/index.d.ts +12 -0
  85. package/types/trades/index.d.ts.map +1 -0
  86. package/types/trades/metal.d.ts +6 -0
  87. package/types/trades/metal.d.ts.map +1 -0
  88. package/types/trades/parseRate.d.ts +2 -0
  89. package/types/trades/parseRate.d.ts.map +1 -0
  90. package/types/trades/utils.d.ts +2 -0
  91. package/types/trades/utils.d.ts.map +1 -0
  92. package/types/types.d.ts +449 -0
  93. package/types/types.d.ts.map +1 -0
@@ -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;
@@ -20,9 +20,14 @@ function extract(rate, type) {
20
20
  rateDeut: deut / crystal,
21
21
  };
22
22
  } else if (type === 'deut') {
23
+ // Like the two branches above: express the other terms in units of the one
24
+ // being sold, so its own term becomes 1. Reading `metal` and `crystal` raw
25
+ // here only happened to work because rates are usually written against 1
26
+ // deuterium — `4:3:2` is the same rate as `2:1.5:1`, but used to pay twice
27
+ // as much for the very same deuterium.
23
28
  res = {
24
- rateMetal: metal,
25
- rateCrystal: crystal,
29
+ rateMetal: metal / deut,
30
+ rateCrystal: crystal / deut,
26
31
  rateDeut: 1,
27
32
  };
28
33
  } else {
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"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Plasma technology is worth more on metal than on crystal, and more on crystal
3
+ * than on deuterium.
4
+ */
5
+ declare const PLASMA_BONUS: Readonly<{
6
+ metal: 0.01;
7
+ crystal: 0.0066;
8
+ deuterium: 0.0033;
9
+ }>;
10
+ /** The geologist officer adds a flat 10% to the three mines. */
11
+ declare const GEOLOGIST_BONUS = 0.1;
12
+ /** The collector class adds 25% to mine production. */
13
+ declare const COLLECTOR_BONUS = 0.25;
14
+ /**
15
+ * Every planet produces this much per hour on its own, mines or not. It is a
16
+ * flat income: no bonus applies to it.
17
+ */
18
+ declare const BASE_INCOME: Readonly<{
19
+ metal: 30;
20
+ crystal: 15;
21
+ deuterium: 0;
22
+ }>;
23
+ /**
24
+ *
25
+ * Return the production multiplier of each resource
26
+ *
27
+ * The multipliers add up, they are not compounded: plasma 15, a geologist and
28
+ * the collector class give 1 + 0.15 + 0.1 + 0.25 on metal.
29
+ * @param {object} [options] The bonuses that apply
30
+ * @param {number} [options.plasmaTech] The Plasma Technology level
31
+ * @param {boolean} [options.geologist] Whether the geologist officer is hired
32
+ * @param {boolean} [options.collectorClass] Whether the player plays collector
33
+ * @param {object} [options.items] Booster items in place, as fractions per
34
+ * resource — a 30% metal booster is `{ metal: 0.3 }`
35
+ * @returns {import('../types.js').Resources} One multiplier per resource
36
+ */
37
+ declare function getProductionBonus(options?: {
38
+ plasmaTech?: number;
39
+ geologist?: boolean;
40
+ collectorClass?: boolean;
41
+ items?: object;
42
+ }): import('../types.js').Resources;
43
+ /**
44
+ *
45
+ * Return the hourly production of a whole planet, bonuses included
46
+ *
47
+ * Mine levels, planet position and temperature give the raw mine output; the
48
+ * plasma, officer, class and item bonuses are then applied, and the flat planet
49
+ * income is added on top.
50
+ * @param {object} planet The planet description
51
+ * @param {number} planet.metalMine The metal mine level
52
+ * @param {number} planet.crystalMine The crystal mine level
53
+ * @param {number} planet.deutSynth The deuterium synthesizer level
54
+ * @param {number} planet.position The planet position, 1 to 3 produce more crystal
55
+ * @param {number} planet.temperature The planet average temperature
56
+ * @param {number} [planet.universeSpeed] The universe economy speed
57
+ * @param {number} [planet.energyEfficiency] The share of the required energy that
58
+ * is actually available, between 0 and 1 — mines run at that rate when the
59
+ * planet is in an energy deficit
60
+ * @param {object} [bonuses] Passed straight to `getProductionBonus`
61
+ * @returns {import('../types.js').Resources & {energyConsumption: number, bonus: import('../types.js').Resources}}
62
+ * The hourly production, what it costs in energy, and the multipliers used
63
+ */
64
+ declare function getPlanetProduction(planet: {
65
+ metalMine: number;
66
+ crystalMine: number;
67
+ deutSynth: number;
68
+ position: number;
69
+ temperature: number;
70
+ universeSpeed?: number;
71
+ energyEfficiency?: number;
72
+ }, bonuses?: object): import('../types.js').Resources & {
73
+ energyConsumption: number;
74
+ bonus: import('../types.js').Resources;
75
+ };
76
+ export { getProductionBonus, PLASMA_BONUS, GEOLOGIST_BONUS, COLLECTOR_BONUS, BASE_INCOME, };
77
+ export default getPlanetProduction;
78
+ //# sourceMappingURL=production.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"production.d.ts","sourceRoot":"","sources":["../../src/buildings/production.js"],"names":[],"mappings":"AAKA;;;GAGG;AACH,QAAA,MAAM,YAAY;;;;EAAqE,CAAC;AAExF,gEAAgE;AAChE,QAAA,MAAM,eAAe,MAAM,CAAC;AAE5B,uDAAuD;AACvD,QAAA,MAAM,eAAe,OAAO,CAAC;AAE7B;;;GAGG;AACH,QAAA,MAAM,WAAW;;;;EAA0D,CAAC;AAY5E;;;;;;;;;;;;;GAaG;AACH,iBAAS,kBAAkB,CAAC,OAAO,AARhC,CAMA,EALA;IAAyB,UAAU,AAAnC,CACA,EADQ,MAAM,CACd;IAA0B,SAAS,AAAnC,CACA,EADQ,OAAO,CACf;IAA0B,cAAc,AAAxC,CACA,EADQ,OAAO,CACf;IAAyB,KAAK,AAA9B,CAEA,EAFQ,MAAM,CAEd;CAEqC,GAF3B,OAAO,aAAa,EAAE,SAAS,CAuB3C;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,iBAAS,mBAAmB,CAAC,MAAM,EAbhC;IAAuB,SAAS,EAAxB,MAAM,CACd;IAAuB,WAAW,EAA1B,MAAM,CACd;IAAuB,SAAS,EAAxB,MAAM,CACd;IAAuB,QAAQ,EAAvB,MAAM,CACd;IAAuB,WAAW,EAA1B,MAAM,CACd;IAAwB,aAAa,AAArC,CACA,EADQ,MAAM,CACd;IAAwB,gBAAgB,AAAxC,CAGA,EAHQ,MAAM,CAGd;CAIgC,EAAE,OAAO,AAJzC,CACA,EADQ,MAIsC,GAHpC,OAAO,aAAa,EAAE,SAAS,GAAG;IAAC,iBAAiB,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,aAAa,EAAE,SAAS,CAAA;CAAC,CAoDjH;AAED,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,eAAe,EACf,WAAW,GACZ,CAAC;eACa,mBAAmB"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ *
3
+ * Return information about the solar plant at a given level
4
+ * @param {import('../types.js').BuildingEntry} solarPlant The solar plant entry, `Buildings[4]`
5
+ * @param {number} targetLevel The level to reach, >= 1
6
+ * @returns {import('../types.js').BuildingInfo} Cost of the plant, and the energy it produces
7
+ */
8
+ declare function getSolarPlant(solarPlant: import('../types.js').BuildingEntry, targetLevel: number): import('../types.js').BuildingInfo;
9
+ export default getSolarPlant;
10
+ //# sourceMappingURL=solar-plant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solar-plant.d.ts","sourceRoot":"","sources":["../../src/buildings/solar-plant.js"],"names":[],"mappings":"AAQA;;;;;;GAMG;AACH,iBAAS,aAAa,CAAC,UAAU,EAJtB,OAAO,aAAa,EAAE,aAIA,EAAE,WAAW,EAHnC,MAGmC,GAFjC,OAAO,aAAa,EAAE,YAAY,CAS9C;eAEc,aAAa"}