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.
- package/README.md +492 -228
- package/package.json +51 -4
- package/src/buildings/buildTime.js +25 -0
- package/src/buildings/crystal.js +18 -36
- package/src/buildings/deut.js +19 -34
- package/src/buildings/fusion-reactor.js +19 -34
- package/src/buildings/index.js +11 -0
- package/src/buildings/info.js +42 -0
- package/src/buildings/infocompte.js +116 -57
- package/src/buildings/metal.js +13 -28
- package/src/buildings/production.js +150 -0
- package/src/buildings/solar-plant.js +13 -21
- 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 +11 -10
- package/src/fleets/index.js +12 -0
- package/src/fleets/speed.js +108 -0
- package/src/i18n.js +43 -0
- package/src/index.js +12 -1
- package/src/models/buildings.js +285 -25
- package/src/models/destroyable.js +216 -110
- package/src/models/research.js +169 -0
- package/src/research/index.js +9 -0
- package/src/research/researchTime.js +25 -0
- package/src/trades/parseRate.js +7 -2
- 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
|
@@ -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"}
|