ogamejs 4.0.2 → 4.2.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 +85 -8
- package/package.json +1 -1
- package/src/fleets/combat.js +145 -36
- package/src/fleets/combatStatistics.js +189 -0
- package/src/fleets/expedition.js +124 -0
- package/src/fleets/index.js +42 -1
- package/src/fleets/moonLock.js +31 -0
- package/src/fleets/moonbreak.js +133 -0
- package/types/fleets/combat.d.ts +88 -24
- package/types/fleets/combat.d.ts.map +1 -1
- package/types/fleets/combatStatistics.d.ts +67 -0
- package/types/fleets/combatStatistics.d.ts.map +1 -0
- package/types/fleets/expedition.d.ts +90 -0
- package/types/fleets/expedition.d.ts.map +1 -0
- package/types/fleets/index.d.ts +16 -1
- package/types/fleets/index.d.ts.map +1 -1
- package/types/fleets/moonLock.d.ts +18 -0
- package/types/fleets/moonLock.d.ts.map +1 -0
- package/types/fleets/moonbreak.d.ts +64 -0
- package/types/fleets/moonbreak.d.ts.map +1 -0
- package/types/index.d.ts +10 -0
- package/types/index.d.ts.map +1 -1
package/types/fleets/index.d.ts
CHANGED
|
@@ -2,7 +2,11 @@ import getDebris from './getDebris.js';
|
|
|
2
2
|
import getDistance from './distance.js';
|
|
3
3
|
import getShipSpeed, { getActiveDrive, getFleetSpeed } from './speed.js';
|
|
4
4
|
import { getFlightTime, getFuelConsumption, getTrip } from './flight.js';
|
|
5
|
-
import simulateCombat from './combat.js';
|
|
5
|
+
import simulateCombat, { DEFAULT_REPAIR_FACTOR, DEFAULT_PLUNDER_RATIO } from './combat.js';
|
|
6
|
+
import { getCombatStatistics, simulateCombats, DEFAULT_RUNS } from './combatStatistics.js';
|
|
7
|
+
import { getWaveChance, getMoonbreakWaves, getMoonbreakChance, getMoonbreakLosses, MIN_MOON_SIZE, MAX_MOON_SIZE, WAVES_PER_ATTACKER } from './moonbreak.js';
|
|
8
|
+
import { getExpeditionFindBase, getExpeditionMaxFind, getCargoCapacity, EXPEDITION_FIND_TIERS, EXPEDITION_TOP_TIER_BASE } from './expedition.js';
|
|
9
|
+
import { getMoonLockShips, MOON_DEBRIS_THRESHOLD, MAX_MOON_CHANCE } from './moonLock.js';
|
|
6
10
|
declare const Fleets: {
|
|
7
11
|
getDebris: typeof getDebris;
|
|
8
12
|
getDistance: typeof getDistance;
|
|
@@ -13,6 +17,17 @@ declare const Fleets: {
|
|
|
13
17
|
getFuelConsumption: typeof getFuelConsumption;
|
|
14
18
|
getTrip: typeof getTrip;
|
|
15
19
|
simulateCombat: typeof simulateCombat;
|
|
20
|
+
simulateCombats: typeof simulateCombats;
|
|
21
|
+
getCombatStatistics: typeof getCombatStatistics;
|
|
22
|
+
getWaveChance: typeof getWaveChance;
|
|
23
|
+
getMoonbreakWaves: typeof getMoonbreakWaves;
|
|
24
|
+
getMoonbreakChance: typeof getMoonbreakChance;
|
|
25
|
+
getMoonbreakLosses: typeof getMoonbreakLosses;
|
|
26
|
+
getExpeditionFindBase: typeof getExpeditionFindBase;
|
|
27
|
+
getExpeditionMaxFind: typeof getExpeditionMaxFind;
|
|
28
|
+
getCargoCapacity: typeof getCargoCapacity;
|
|
29
|
+
getMoonLockShips: typeof getMoonLockShips;
|
|
16
30
|
};
|
|
31
|
+
export { MIN_MOON_SIZE, MAX_MOON_SIZE, WAVES_PER_ATTACKER, EXPEDITION_FIND_TIERS, EXPEDITION_TOP_TIER_BASE, MOON_DEBRIS_THRESHOLD, MAX_MOON_CHANCE, DEFAULT_REPAIR_FACTOR, DEFAULT_PLUNDER_RATIO, DEFAULT_RUNS, };
|
|
17
32
|
export default Fleets;
|
|
18
33
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +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;
|
|
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,EAAE,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAC3F,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC3F,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EAChB,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEzF,QAAA,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;CAoBX,CAAC;AAEF,OAAO,EACL,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,qBAAqB,EACrB,wBAAwB,EACxB,qBAAqB,EACrB,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,YAAY,GACb,CAAC;eAEa,MAAM"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** The debris that gives a moon its maximum chance to appear. */
|
|
2
|
+
declare const MOON_DEBRIS_THRESHOLD = 2000000;
|
|
3
|
+
/** The maximum moon chance, in %, reached at `MOON_DEBRIS_THRESHOLD`. */
|
|
4
|
+
declare const MAX_MOON_CHANCE = 20;
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* Return how many ships must be destroyed on a position to reach the maximum moon chance
|
|
8
|
+
*
|
|
9
|
+
* Only metal and crystal land in the debris field here, and the universe keeps
|
|
10
|
+
* `debrisFactor` of them.
|
|
11
|
+
* @param {import('../types.js').DestroyableEntry} ship An entry of models/destroyable.js
|
|
12
|
+
* @param {number} debrisFactor The universe debris factor, e.g. 0.3 for 30%
|
|
13
|
+
* @param {number} [threshold] The debris to reach, 2 000 000 by default
|
|
14
|
+
* @return {number} The number of ships
|
|
15
|
+
*/
|
|
16
|
+
declare function getMoonLockShips(ship: import('../types.js').DestroyableEntry, debrisFactor: number, threshold?: number): number;
|
|
17
|
+
export { getMoonLockShips, MOON_DEBRIS_THRESHOLD, MAX_MOON_CHANCE };
|
|
18
|
+
//# sourceMappingURL=moonLock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moonLock.d.ts","sourceRoot":"","sources":["../../src/fleets/moonLock.js"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,QAAA,MAAM,qBAAqB,UAAU,CAAC;AAEtC,yEAAyE;AACzE,QAAA,MAAM,eAAe,KAAK,CAAC;AAE3B;;;;;;;;;;GAUG;AACH,iBAAS,gBAAgB,CAAC,IAAI,EALnB,OAAO,aAAa,EAAE,gBAKH,EAAE,YAAY,EAJjC,MAIiC,EAAE,SAAS,AAHpD,CACA,EADQ,MAGoE,GAFnE,MAAM,CAajB;AAED,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** A moon size, in km, can only be in this range. */
|
|
2
|
+
declare const MIN_MOON_SIZE = 3464;
|
|
3
|
+
declare const MAX_MOON_SIZE = 8944;
|
|
4
|
+
/** Each attacker spreads their Deathstars over this many waves. */
|
|
5
|
+
declare const WAVES_PER_ATTACKER = 6;
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* Return the chance that a single wave of Deathstars destroys the moon
|
|
9
|
+
*
|
|
10
|
+
* `(100 - sqrt(moonSize)) * sqrt(rip) / 100`, capped at 1
|
|
11
|
+
* @param {number} moonSize The moon diameter, in km
|
|
12
|
+
* @param {number} rip The number of Deathstars in the wave
|
|
13
|
+
* @return {number} The chance, between 0 and 1
|
|
14
|
+
*/
|
|
15
|
+
declare function getWaveChance(moonSize: number, rip: number): number;
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* Return the waves one attacker sends, in firing order
|
|
19
|
+
*
|
|
20
|
+
* The Deathstars are spread over 6 waves: when the count is not a multiple of 6,
|
|
21
|
+
* the first waves carry one extra ship. Under 6 Deathstars, the last waves are
|
|
22
|
+
* empty, which neither threaten the moon nor lose a ship.
|
|
23
|
+
* @param {number} rip The attacker's Deathstars
|
|
24
|
+
* @return {number[]} The size of each of the 6 waves
|
|
25
|
+
*/
|
|
26
|
+
declare function getMoonbreakWaves(rip: number): number[];
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* Return the chance that a coordinated attack destroys the moon
|
|
30
|
+
*
|
|
31
|
+
* The attackers fire one after the other and the moon is gone as soon as one
|
|
32
|
+
* wave succeeds, so the attack fails only when every wave fails.
|
|
33
|
+
* @param {number} moonSize The moon diameter, in km (3464 to 8944)
|
|
34
|
+
* @param {number[]} fleets The Deathstars of each attacker, in firing order
|
|
35
|
+
* @return {number} The chance, between 0 and 1
|
|
36
|
+
*/
|
|
37
|
+
declare function getMoonbreakChance(moonSize: number, fleets: number[]): number;
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* Return the expected Deathstar losses of a coordinated attack
|
|
41
|
+
*
|
|
42
|
+
* Each Deathstar of a wave is destroyed with probability `sqrt(moonSize) / 200`,
|
|
43
|
+
* and a wave only costs ships if every wave before it failed. The variance sums
|
|
44
|
+
* the per-wave binomial variances (the waves are treated as independent), and
|
|
45
|
+
* the spread is summarised as a gaussian around the mean: 1σ / 2σ / 3σ for the
|
|
46
|
+
* 68 / 95 / 99 % bands, clamped between 0 and the whole fleet.
|
|
47
|
+
* @param {number} moonSize The moon diameter, in km (3464 to 8944)
|
|
48
|
+
* @param {number[]} fleets The Deathstars of each attacker, in firing order
|
|
49
|
+
* @return {{
|
|
50
|
+
* mean: number, sigma: number,
|
|
51
|
+
* bands: { confidence: number, min: number, max: number }[],
|
|
52
|
+
* }} The losses, unrounded
|
|
53
|
+
*/
|
|
54
|
+
declare function getMoonbreakLosses(moonSize: number, fleets: number[]): {
|
|
55
|
+
mean: number;
|
|
56
|
+
sigma: number;
|
|
57
|
+
bands: {
|
|
58
|
+
confidence: number;
|
|
59
|
+
min: number;
|
|
60
|
+
max: number;
|
|
61
|
+
}[];
|
|
62
|
+
};
|
|
63
|
+
export { getWaveChance, getMoonbreakWaves, getMoonbreakChance, getMoonbreakLosses, MIN_MOON_SIZE, MAX_MOON_SIZE, WAVES_PER_ATTACKER, };
|
|
64
|
+
//# sourceMappingURL=moonbreak.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moonbreak.d.ts","sourceRoot":"","sources":["../../src/fleets/moonbreak.js"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,QAAA,MAAM,aAAa,OAAO,CAAC;AAC3B,QAAA,MAAM,aAAa,OAAO,CAAC;AAE3B,mEAAmE;AACnE,QAAA,MAAM,kBAAkB,IAAI,CAAC;AAmB7B;;;;;;;;GAQG;AACH,iBAAS,aAAa,CAAC,QAAQ,EAJpB,MAIoB,EAAE,GAAG,EAHzB,MAGyB,GAFxB,MAAM,CAIjB;AAED;;;;;;;;;GASG;AACH,iBAAS,iBAAiB,CAAC,GAAG,EAHnB,MAGmB,GAFlB,MAAM,EAAE,CAOnB;AAED;;;;;;;;;GASG;AACH,iBAAS,kBAAkB,CAAC,QAAQ,EAJzB,MAIyB,EAAE,MAAM,EAHjC,MAAM,EAG2B,GAFhC,MAAM,CAWjB;AAED;;;;;;;;;;;;;;;GAeG;AACH,iBAAS,kBAAkB,CAAC,QAAQ,EAPzB,MAOyB,EAAE,MAAM,EANjC,MAAM,EAM2B,GALhC;IACP,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAC5B,KAAK,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC3D,CAiCH;AAED,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,kBAAkB,GACnB,CAAC"}
|
package/types/index.d.ts
CHANGED
|
@@ -31,6 +31,16 @@ declare const Ogame: {
|
|
|
31
31
|
getFuelConsumption: typeof import("./fleets/flight.js").getFuelConsumption;
|
|
32
32
|
getTrip: typeof import("./fleets/flight.js").getTrip;
|
|
33
33
|
simulateCombat: typeof import("./fleets/combat.js").default;
|
|
34
|
+
simulateCombats: typeof import("./fleets/combatStatistics.js").simulateCombats;
|
|
35
|
+
getCombatStatistics: typeof import("./fleets/combatStatistics.js").getCombatStatistics;
|
|
36
|
+
getWaveChance: typeof import("./fleets/moonbreak.js").getWaveChance;
|
|
37
|
+
getMoonbreakWaves: typeof import("./fleets/moonbreak.js").getMoonbreakWaves;
|
|
38
|
+
getMoonbreakChance: typeof import("./fleets/moonbreak.js").getMoonbreakChance;
|
|
39
|
+
getMoonbreakLosses: typeof import("./fleets/moonbreak.js").getMoonbreakLosses;
|
|
40
|
+
getExpeditionFindBase: typeof import("./fleets/expedition.js").getExpeditionFindBase;
|
|
41
|
+
getExpeditionMaxFind: typeof import("./fleets/expedition.js").getExpeditionMaxFind;
|
|
42
|
+
getCargoCapacity: typeof import("./fleets/expedition.js").getCargoCapacity;
|
|
43
|
+
getMoonLockShips: typeof import("./fleets/moonLock.js").getMoonLockShips;
|
|
34
44
|
};
|
|
35
45
|
Research: {
|
|
36
46
|
getResearchCost: typeof import("./cost.js").default;
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAS,MAAM,WAAW,CAAC;AAEvD,QAAA,MAAM,KAAK
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,UAAU,EAAS,MAAM,WAAW,CAAC;AAEvD,QAAA,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgBV,CAAC;eAEa,KAAK"}
|