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
|
@@ -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"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Return the capacity of a storage building at a given level
|
|
4
|
+
*
|
|
5
|
+
* Level 0 is the free 10.000 units every planet starts with.
|
|
6
|
+
* @param {number} level The storage level, >= 0
|
|
7
|
+
* @returns {number} The protected capacity, in resource units
|
|
8
|
+
*/
|
|
9
|
+
declare function getStorageCapacity(level: number): number;
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* Return the cost and the capacity of a storage building at a given level
|
|
13
|
+
* @param {import('../types.js').BuildingEntry} storage A storage entry of models/buildings.js (22, 23 or 24)
|
|
14
|
+
* @param {number} targetLevel The level to reach, >= 1
|
|
15
|
+
* @returns {import('../types.js').Cost & {capacity: number}} The cost of that level plus the capacity
|
|
16
|
+
*/
|
|
17
|
+
declare function getStorage(storage: import('../types.js').BuildingEntry, targetLevel: number): import('../types.js').Cost & {
|
|
18
|
+
capacity: number;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* Return the lowest storage level able to protect a given amount of resources
|
|
23
|
+
* @param {number} amount The amount of resources to protect
|
|
24
|
+
* @returns {number} The required storage level
|
|
25
|
+
*/
|
|
26
|
+
declare function getStorageLevelFor(amount: number): number;
|
|
27
|
+
export { getStorageCapacity, getStorageLevelFor };
|
|
28
|
+
export default getStorage;
|
|
29
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/buildings/storage.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,iBAAS,kBAAkB,CAAC,KAAK,EAHtB,MAGsB,GAFpB,MAAM,CAQlB;AAED;;;;;;GAMG;AACH,iBAAS,UAAU,CAAC,OAAO,EAJhB,OAAO,aAAa,EAAE,aAIN,EAAE,WAAW,EAH7B,MAG6B,GAF3B,OAAO,aAAa,EAAE,IAAI,GAAG;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,CAa3D;AAED;;;;;GAKG;AACH,iBAAS,kBAAkB,CAAC,MAAM,EAHvB,MAGuB,GAFrB,MAAM,CAalB;AAED,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,CAAC;eACnC,UAAU"}
|
package/types/cost.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare function assertLevel(targetLevel: any): void;
|
|
2
|
+
/**
|
|
3
|
+
* Guard against the pre-4.0 habit of passing `Buildings[id].base` around.
|
|
4
|
+
* Every calculator now needs the whole entry, because the cost `factor` lives
|
|
5
|
+
* on it and not on its `base`.
|
|
6
|
+
*/
|
|
7
|
+
declare function assertEntry(entry: any, targetLevel: any): void;
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* Return the cost of a building or a technology at a given level
|
|
11
|
+
*
|
|
12
|
+
* Works for anything carrying a `base` and a `factor`, so both
|
|
13
|
+
* `models/buildings.js` and `models/research.js` entries are accepted.
|
|
14
|
+
* Use the dedicated `getMetalMine`/`getCrystalMine`/... helpers when you also
|
|
15
|
+
* need the production or the consumption of a mine or a plant.
|
|
16
|
+
*
|
|
17
|
+
* @param {import('./types.js').BuildingEntry|import('./types.js').ResearchEntry} entry A Buildings or
|
|
18
|
+
* Research entry (not its `base`)
|
|
19
|
+
* @param {number} targetLevel The level to reach, >= 1
|
|
20
|
+
* @returns {import('./types.js').Cost} The resources, and the energy, paid to reach that level
|
|
21
|
+
*/
|
|
22
|
+
declare function getCost(entry: import('./types.js').BuildingEntry | import('./types.js').ResearchEntry, targetLevel: number): import('./types.js').Cost;
|
|
23
|
+
export { assertLevel, assertEntry };
|
|
24
|
+
export default getCost;
|
|
25
|
+
//# sourceMappingURL=cost.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost.d.ts","sourceRoot":"","sources":["../src/cost.js"],"names":[],"mappings":"AAAA,iBAAS,WAAW,CAAC,WAAW,KAAA,QAI/B;AAED;;;;GAIG;AACH,iBAAS,WAAW,CAAC,KAAK,KAAA,EAAE,WAAW,KAAA,QAgBtC;AAYD;;;;;;;;;;;;;GAaG;AACH,iBAAS,OAAO,CAAC,KAAK,EALX,OAAO,YAAY,EAAE,aAAa,GAAC,OAAO,YAAY,EAAE,aAK7C,EAAE,WAAW,EAHxB,MAGwB,GAFtB,OAAO,YAAY,EAAE,IAAI,CAerC;AAED,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;eACrB,OAAO"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
declare const ROUNDS = 6;
|
|
2
|
+
/**
|
|
3
|
+
* A tiny deterministic PRNG (mulberry32), so a battle can be replayed.
|
|
4
|
+
*/
|
|
5
|
+
declare function createRandom(seed: any): () => number;
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* Simulate a battle between two fleets
|
|
9
|
+
*
|
|
10
|
+
* Follows the game rules: up to six rounds, every unit fires once per round at a
|
|
11
|
+
* random enemy, rapid fire grants extra shots, shots below 1% of the target
|
|
12
|
+
* shield bounce off, shields come back every round, and a unit under 70% hull
|
|
13
|
+
* may explode at the end of the round.
|
|
14
|
+
*
|
|
15
|
+
* A battle is random, so one run is one possible outcome. The `seed` makes a run
|
|
16
|
+
* reproducible; average several seeds to get a feel for the likely result.
|
|
17
|
+
* @param {object} attacker The attacking side
|
|
18
|
+
* @param {import('../types.js').FleetEntry[]} attacker.fleet Its ships
|
|
19
|
+
* @param {import('../types.js').CombatTechs} [attacker.techs] Its combat technology levels
|
|
20
|
+
* @param {object} defender The defending side, same shape, defenses included
|
|
21
|
+
* @param {object} [options] Simulation options
|
|
22
|
+
* @param {number} [options.seed] The PRNG seed, for a reproducible battle
|
|
23
|
+
* @param {number} [options.debrisFactor] The universe debris factor
|
|
24
|
+
* @param {number} [options.deuteriumDebrisFactor] The universe deuterium debris factor
|
|
25
|
+
* @param {boolean} [options.defenseDebris] Whether destroyed defenses leave debris
|
|
26
|
+
* @returns {{
|
|
27
|
+
* winner: 'attacker'|'defender'|'draw', rounds: number, seed: number,
|
|
28
|
+
* attacker: {survivors: import('../types.js').FleetEntry[], losses: import('../types.js').FleetEntry[]},
|
|
29
|
+
* defender: {survivors: import('../types.js').FleetEntry[], losses: import('../types.js').FleetEntry[]},
|
|
30
|
+
* debris: import('../types.js').Resources,
|
|
31
|
+
* }} Who won, how long it took, what is left on each side, and the debris field
|
|
32
|
+
*/
|
|
33
|
+
declare function simulateCombat(attacker: {
|
|
34
|
+
fleet: import('../types.js').FleetEntry[];
|
|
35
|
+
techs?: import('../types.js').CombatTechs;
|
|
36
|
+
}, defender: object, options?: {
|
|
37
|
+
seed?: number;
|
|
38
|
+
debrisFactor?: number;
|
|
39
|
+
deuteriumDebrisFactor?: number;
|
|
40
|
+
defenseDebris?: boolean;
|
|
41
|
+
}): {
|
|
42
|
+
winner: 'attacker' | 'defender' | 'draw';
|
|
43
|
+
rounds: number;
|
|
44
|
+
seed: number;
|
|
45
|
+
attacker: {
|
|
46
|
+
survivors: import('../types.js').FleetEntry[];
|
|
47
|
+
losses: import('../types.js').FleetEntry[];
|
|
48
|
+
};
|
|
49
|
+
defender: {
|
|
50
|
+
survivors: import('../types.js').FleetEntry[];
|
|
51
|
+
losses: import('../types.js').FleetEntry[];
|
|
52
|
+
};
|
|
53
|
+
debris: import('../types.js').Resources;
|
|
54
|
+
};
|
|
55
|
+
export { createRandom, ROUNDS };
|
|
56
|
+
export default simulateCombat;
|
|
57
|
+
//# sourceMappingURL=combat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combat.d.ts","sourceRoot":"","sources":["../../src/fleets/combat.js"],"names":[],"mappings":"AAGA,QAAA,MAAM,MAAM,IAAI,CAAC;AAmCjB;;GAEG;AACH,iBAAS,YAAY,CAAC,IAAI,KAAA,gBAWzB;AAqJD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,iBAAS,cAAc,CAAC,QAAQ,EAf7B;IAAqD,KAAK,EAAlD,OAAO,aAAa,EAAE,UAAU,EAAE,CAC1C;IAAqD,KAAK,AAA1D,CACA,EADQ,OAAO,aAAa,EAAE,WAAW,CACzC;CAa6B,EAAE,QAAQ,EAb/B,MAa+B,EAAE,OAAO,AAZhD,CAKA,EAJA;IAAyB,IAAI,AAA7B,CACA,EADQ,MAAM,CACd;IAAyB,YAAY,AAArC,CACA,EADQ,MAAM,CACd;IAAyB,qBAAqB,AAA9C,CACA,EADQ,MAAM,CACd;IAA0B,aAAa,AAAvC,CACA,EADQ,OAAO,CACf;CAOqD,GAP3C;IACR,MAAM,EAAE,UAAU,GAAC,UAAU,GAAC,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IACnE,QAAQ,EAAE;QAAC,SAAS,EAAE,OAAO,aAAa,EAAE,UAAU,EAAE,CAAC;QAAC,MAAM,EAAE,OAAO,aAAa,EAAE,UAAU,EAAE,CAAA;KAAC,CAAC;IACtG,QAAQ,EAAE;QAAC,SAAS,EAAE,OAAO,aAAa,EAAE,UAAU,EAAE,CAAC;QAAC,MAAM,EAAE,OAAO,aAAa,EAAE,UAAU,EAAE,CAAA;KAAC,CAAC;IACtG,MAAM,EAAE,OAAO,aAAa,EAAE,SAAS,CAAC;CACzC,CA6DH;AAED,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC;eACjB,cAAc"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Return the distance between two coordinates, in OGame distance units
|
|
4
|
+
*
|
|
5
|
+
* The scale is not linear: crossing a galaxy costs far more than crossing a
|
|
6
|
+
* system, which costs far more than moving inside one.
|
|
7
|
+
* @param {import('../types.js').Coordinates} origin Where the fleet leaves from
|
|
8
|
+
* @param {import('../types.js').Coordinates} target Where it goes
|
|
9
|
+
* @returns {number} The distance
|
|
10
|
+
*/
|
|
11
|
+
declare function getDistance(origin: import('../types.js').Coordinates, target: import('../types.js').Coordinates): number;
|
|
12
|
+
export default getDistance;
|
|
13
|
+
//# sourceMappingURL=distance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"distance.d.ts","sourceRoot":"","sources":["../../src/fleets/distance.js"],"names":[],"mappings":"AAQA;;;;;;;;;GASG;AACH,iBAAS,WAAW,CAAC,MAAM,EAJhB,OAAO,aAAa,EAAE,WAIN,EAAE,MAAM,EAHxB,OAAO,aAAa,EAAE,WAGE,GAFtB,MAAM,CAoBlB;eAEc,WAAW"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Return the one way flight time of a fleet
|
|
4
|
+
*
|
|
5
|
+
* `(10 + 35000 / speedPercent * sqrt(distance * 10 / fleetSpeed)) / universeFleetSpeed`
|
|
6
|
+
* @param {number} distance The distance to cross, from `getDistance`
|
|
7
|
+
* @param {number} fleetSpeed The speed of the slowest ship, from `getFleetSpeed`
|
|
8
|
+
* @param {number} [speedPercent] The fleet speed slider, 10 to 100 in game
|
|
9
|
+
* @param {number} [universeFleetSpeed] The universe fleet speed
|
|
10
|
+
* @returns {number} The flight time, in seconds
|
|
11
|
+
*/
|
|
12
|
+
declare function getFlightTime(distance: number, fleetSpeed: number, speedPercent?: number, universeFleetSpeed?: number): number;
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* Return the deuterium a fleet burns for a one way trip
|
|
16
|
+
*
|
|
17
|
+
* `1 + round(sum(consumption * count) * distance / 35000 * (speedPercent / 100 + 1) ** 2)`
|
|
18
|
+
* @param {import('../types.js').FleetEntry[]} fleet The ships taking off
|
|
19
|
+
* @param {number} distance The distance to cross, from `getDistance`
|
|
20
|
+
* @param {number} [speedPercent] The fleet speed slider, 10 to 100 in game
|
|
21
|
+
* @param {import('../types.js').Drives} [drives] Drive levels, needed because a
|
|
22
|
+
* ship that switched drive also changed its consumption
|
|
23
|
+
* @returns {number} The fuel needed, in deuterium
|
|
24
|
+
*/
|
|
25
|
+
declare function getFuelConsumption(fleet: import('../types.js').FleetEntry[], distance: number, speedPercent?: number, drives?: import('../types.js').Drives): number;
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* Return everything about a trip: distance, duration, fuel and cargo left
|
|
29
|
+
* @param {import('../types.js').FleetEntry[]} fleet The ships taking off
|
|
30
|
+
* @param {import('../types.js').Coordinates} origin Where the fleet leaves from
|
|
31
|
+
* @param {import('../types.js').Coordinates} target Where it goes
|
|
32
|
+
* @param {object} [options] Trip options
|
|
33
|
+
* @param {number} [options.speedPercent] The fleet speed slider, 10 to 100 in game
|
|
34
|
+
* @param {number} [options.universeFleetSpeed] The universe fleet speed
|
|
35
|
+
* @param {import('../types.js').Drives} [options.drives] The drive technology levels
|
|
36
|
+
* @param {boolean} [options.roundTrip] Whether to account for the way back too
|
|
37
|
+
* @returns {{
|
|
38
|
+
* distance: number, fleetSpeed: number, duration: number, fuel: number,
|
|
39
|
+
* cargo: number, cargoAfterFuel: number,
|
|
40
|
+
* }} The trip, with durations in seconds and `cargoAfterFuel` the room left once
|
|
41
|
+
* the fuel is loaded
|
|
42
|
+
*/
|
|
43
|
+
declare function getTrip(fleet: import('../types.js').FleetEntry[], origin: import('../types.js').Coordinates, target: import('../types.js').Coordinates, options?: {
|
|
44
|
+
speedPercent?: number;
|
|
45
|
+
universeFleetSpeed?: number;
|
|
46
|
+
drives?: import('../types.js').Drives;
|
|
47
|
+
roundTrip?: boolean;
|
|
48
|
+
}): {
|
|
49
|
+
distance: number;
|
|
50
|
+
fleetSpeed: number;
|
|
51
|
+
duration: number;
|
|
52
|
+
fuel: number;
|
|
53
|
+
cargo: number;
|
|
54
|
+
cargoAfterFuel: number;
|
|
55
|
+
};
|
|
56
|
+
export { getFlightTime, getFuelConsumption, getTrip };
|
|
57
|
+
//# sourceMappingURL=flight.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flight.d.ts","sourceRoot":"","sources":["../../src/fleets/flight.js"],"names":[],"mappings":"AASA;;;;;;;;;;GAUG;AACH,iBAAS,aAAa,CAAC,QAAQ,EANpB,MAMoB,EAAE,UAAU,EALhC,MAKgC,EAAE,YAAY,AAJtD,CACA,EADQ,MAIoD,EAAE,kBAAkB,AAHhF,CACA,EADQ,MAG4E,GAF1E,MAAM,CAYlB;AAED;;;;;;;;;;;GAWG;AACH,iBAAS,kBAAkB,CAAC,KAAK,EAPtB,OAAO,aAAa,EAAE,UAAU,EAOV,EAAE,QAAQ,EANhC,MAMgC,EAAE,YAAY,AALtD,CACA,EADQ,MAKoD,EAAE,MAAM,AAJpE,CAEA,EAFQ,OAAO,aAAa,EAAE,MAI2C,GAF/D,MAAM,CAmBlB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,iBAAS,OAAO,CAAC,KAAK,EAdX,OAAO,aAAa,EAAE,UAAU,EAcrB,EAAE,MAAM,EAbnB,OAAO,aAAa,EAAE,WAaH,EAAE,MAAM,EAZ3B,OAAO,aAAa,EAAE,WAYK,EAAE,OAAO,AAX5C,CAKA,EAJA;IAAyB,YAAY,AAArC,CACA,EADQ,MAAM,CACd;IAAyB,kBAAkB,AAA3C,CACA,EADQ,MAAM,CACd;IAA+C,MAAM,AAArD,CACA,EADQ,OAAO,aAAa,EAAE,MAAM,CACpC;IAA0B,SAAS,AAAnC,CACA,EADQ,OAAO,CACf;CAMiD,GANvC;IACR,QAAQ,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IACrE,KAAK,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAC;CACvC,CAyBH;AAED,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Return the debris field left behind by destroyed ships or defenses
|
|
4
|
+
* @param {import('../types.js').DestroyableEntry} ship An entry of models/destroyable.js
|
|
5
|
+
* @param {number} number The number of destroyed units
|
|
6
|
+
* @param {number} factor The universe debris factor, e.g. 0.3 for 30%
|
|
7
|
+
* @param {number} [deuteriumFactor] The universe deuterium debris factor, 0 on most universes
|
|
8
|
+
* @return {import('../types.js').Resources} The debris generated
|
|
9
|
+
*/
|
|
10
|
+
declare function getDebris(ship: import('../types.js').DestroyableEntry, number: number, factor: number, deuteriumFactor?: number): import('../types.js').Resources;
|
|
11
|
+
export default getDebris;
|
|
12
|
+
//# sourceMappingURL=getDebris.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDebris.d.ts","sourceRoot":"","sources":["../../src/fleets/getDebris.js"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,iBAAS,SAAS,CAAC,IAAI,EANZ,OAAO,aAAa,EAAE,gBAMV,EAAE,MAAM,EALpB,MAKoB,EAAE,MAAM,EAJ5B,MAI4B,EAAE,eAAe,AAHrD,CACA,EADQ,MAGiD,GAFhD,OAAO,aAAa,EAAE,SAAS,CAW1C;eAEc,SAAS"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import getDebris from './getDebris.js';
|
|
2
|
+
import getDistance from './distance.js';
|
|
3
|
+
import getShipSpeed, { getActiveDrive, getFleetSpeed } from './speed.js';
|
|
4
|
+
import { getFlightTime, getFuelConsumption, getTrip } from './flight.js';
|
|
5
|
+
import simulateCombat from './combat.js';
|
|
6
|
+
declare const Fleets: {
|
|
7
|
+
getDebris: typeof getDebris;
|
|
8
|
+
getDistance: typeof getDistance;
|
|
9
|
+
getShipSpeed: typeof getShipSpeed;
|
|
10
|
+
getActiveDrive: typeof getActiveDrive;
|
|
11
|
+
getFleetSpeed: typeof getFleetSpeed;
|
|
12
|
+
getFlightTime: typeof getFlightTime;
|
|
13
|
+
getFuelConsumption: typeof getFuelConsumption;
|
|
14
|
+
getTrip: typeof getTrip;
|
|
15
|
+
simulateCombat: typeof simulateCombat;
|
|
16
|
+
};
|
|
17
|
+
export default Fleets;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fleets/index.js"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,gBAAgB,CAAC;AACvC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,YAAY,EAAE,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,cAAc,MAAM,aAAa,CAAC;AAEzC,QAAA,MAAM,MAAM;;;;;;;;;;CAUX,CAAC;eAEa,MAAM"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
declare const DRIVES: {
|
|
2
|
+
COMBUSTION: string;
|
|
3
|
+
IMPULSE: string;
|
|
4
|
+
HYPERSPACE: string;
|
|
5
|
+
NONE: string;
|
|
6
|
+
};
|
|
7
|
+
/** Each drive level adds that share of the ship base speed. */
|
|
8
|
+
declare const DRIVE_BONUS: Readonly<{
|
|
9
|
+
[DRIVES.COMBUSTION]: 0.1;
|
|
10
|
+
[DRIVES.IMPULSE]: 0.2;
|
|
11
|
+
[DRIVES.HYPERSPACE]: 0.3;
|
|
12
|
+
[DRIVES.NONE]: 0;
|
|
13
|
+
}>;
|
|
14
|
+
/** The research id backing each drive, handy to look the level up. */
|
|
15
|
+
declare const DRIVE_RESEARCH: Readonly<{
|
|
16
|
+
[DRIVES.COMBUSTION]: 115;
|
|
17
|
+
[DRIVES.IMPULSE]: 117;
|
|
18
|
+
[DRIVES.HYPERSPACE]: 118;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* Return the drive a ship actually flies on, and the speed it reaches
|
|
23
|
+
*
|
|
24
|
+
* A few ships switch to a better drive once the matching technology is high
|
|
25
|
+
* enough — a small cargo moves to the impulse drive at Impulse 5. When several
|
|
26
|
+
* drives are available the ship uses whichever ends up fastest.
|
|
27
|
+
* @param {import('../types.js').DestroyableEntry} ship An entry of models/destroyable.js
|
|
28
|
+
* @param {import('../types.js').Drives} [drives] Drive levels
|
|
29
|
+
* @returns {{drive: string, speed: number, fuelConsumption: number}} The active drive
|
|
30
|
+
*/
|
|
31
|
+
declare function getActiveDrive(ship: import('../types.js').DestroyableEntry, drives?: import('../types.js').Drives): {
|
|
32
|
+
drive: string;
|
|
33
|
+
speed: number;
|
|
34
|
+
fuelConsumption: number;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* Return the speed of a ship, drive technologies included
|
|
39
|
+
* @param {import('../types.js').DestroyableEntry} ship An entry of models/destroyable.js
|
|
40
|
+
* @param {import('../types.js').Drives} [drives] Drive levels
|
|
41
|
+
* @returns {number} The speed the ship flies at
|
|
42
|
+
*/
|
|
43
|
+
declare function getShipSpeed(ship: import('../types.js').DestroyableEntry, drives?: import('../types.js').Drives): number;
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
* Return the speed of a whole fleet, which is the speed of its slowest ship
|
|
47
|
+
* @param {import('../types.js').FleetEntry[]} fleet The ships taking off
|
|
48
|
+
* @param {import('../types.js').Drives} [drives] Drive levels
|
|
49
|
+
* @returns {number} The fleet speed
|
|
50
|
+
*/
|
|
51
|
+
declare function getFleetSpeed(fleet: import('../types.js').FleetEntry[], drives?: import('../types.js').Drives): number;
|
|
52
|
+
export { getActiveDrive, getFleetSpeed, DRIVE_BONUS, DRIVE_RESEARCH, };
|
|
53
|
+
export default getShipSpeed;
|
|
54
|
+
//# sourceMappingURL=speed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"speed.d.ts","sourceRoot":"","sources":["../../src/fleets/speed.js"],"names":[],"mappings":"AAEA,QAAA,MAAQ,MAAM;;;;;CAAe,CAAC;AAE9B,+DAA+D;AAC/D,QAAA,MAAM,WAAW;IACf,CAAC,MAAM,CAAC,UAAU,CAAC,MAAK;IACxB,CAAC,MAAM,CAAC,OAAO,CAAC,MAAK;IACrB,CAAC,MAAM,CAAC,UAAU,CAAC,MAAK;IACxB,CAAC,MAAM,CAAC,IAAI,CAAC,IAAG;EAChB,CAAC;AAEH,sEAAsE;AACtE,QAAA,MAAM,cAAc;IAClB,CAAC,MAAM,CAAC,UAAU,CAAC,MAAK;IACxB,CAAC,MAAM,CAAC,OAAO,CAAC,MAAK;IACrB,CAAC,MAAM,CAAC,UAAU,CAAC,MAAK;EACxB,CAAC;AAsBH;;;;;;;;;;GAUG;AACH,iBAAS,cAAc,CAAC,IAAI,EAJjB,OAAO,aAAa,EAAE,gBAIL,EAAE,MAAM,AAHjC,CACA,EADQ,OAAO,aAAa,EAAE,MAGQ,GAF5B;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAC,CAoBnE;AAED;;;;;;GAMG;AACH,iBAAS,YAAY,CAAC,IAAI,EAJf,OAAO,aAAa,EAAE,gBAIP,EAAE,MAAM,AAH/B,CACA,EADQ,OAAO,aAAa,EAAE,MAGM,GAF1B,MAAM,CAIlB;AAED;;;;;;GAMG;AACH,iBAAS,aAAa,CAAC,KAAK,EAJjB,OAAO,aAAa,EAAE,UAAU,EAIf,EAAE,MAAM,AAHjC,CACA,EADQ,OAAO,aAAa,EAAE,MAGQ,GAF5B,MAAM,CAgBlB;AAED,OAAO,EACL,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc,GAC3D,CAAC;eACa,YAAY"}
|
package/types/i18n.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
declare const LANGS: readonly string[];
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* Return the localised name of a model entry
|
|
5
|
+
* @param {{names: import('./types.js').Names}} entry An entry of Buildings, Destroyable or Research
|
|
6
|
+
* @param {import('./types.js').Lang} [lang] 'en' or 'fr', defaults to 'en'
|
|
7
|
+
* @returns {string} The localised name
|
|
8
|
+
*/
|
|
9
|
+
declare function getName(entry: {
|
|
10
|
+
names: import('./types.js').Names;
|
|
11
|
+
}, lang?: import('./types.js').Lang): string;
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* Look an entry up by any of its localised names, case and accent insensitive
|
|
15
|
+
* @param {Record<string|number, {names: import('./types.js').Names}>} model Buildings, Destroyable or Research
|
|
16
|
+
* @param {string} name The name to look for, in any supported language
|
|
17
|
+
* @returns {object|undefined} The matching entry, or undefined
|
|
18
|
+
*/
|
|
19
|
+
declare function findByName(model: Record<string | number, {
|
|
20
|
+
names: import('./types.js').Names;
|
|
21
|
+
}>, name: string): object | undefined;
|
|
22
|
+
export { getName, findByName, LANGS };
|
|
23
|
+
//# sourceMappingURL=i18n.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../src/i18n.js"],"names":[],"mappings":"AAEA,QAAA,MAAM,KAAK,mBAA8B,CAAC;AAE1C;;;;;;GAMG;AACH,iBAAS,OAAO,CAAC,KAAK,EAJX;IAAC,KAAK,EAAE,OAAO,YAAY,EAAE,KAAK,CAAA;CAIvB,EAAE,IAAI,AAHzB,CACA,EADQ,OAAO,YAAY,EAAE,IAGW,GAF9B,MAAM,CASlB;AAED;;;;;;GAMG;AACH,iBAAS,UAAU,CAAC,KAAK,EAJd,MAAM,CAAC,MAAM,GAAC,MAAM,EAAE;IAAC,KAAK,EAAE,OAAO,YAAY,EAAE,KAAK,CAAA;CAAC,CAI3C,EAAE,IAAI,EAHpB,MAGoB,GAFlB,MAAM,GAAC,SAAS,CAe5B;AAED,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC"}
|