ogamejs 2.1.4 → 3.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/package.json +22 -31
- package/{build → src}/buildings/crystal.js +16 -24
- package/{build → src}/buildings/deut.js +12 -22
- package/{build → src}/buildings/fusion-reactor.js +12 -22
- package/src/buildings/index.js +17 -0
- package/src/buildings/infocompte.js +91 -0
- package/{build → src}/buildings/metal.js +12 -21
- package/{build → src}/buildings/solar-plant.js +8 -17
- package/src/fleets/getDebris.js +20 -0
- package/src/fleets/index.js +7 -0
- package/src/index.js +17 -0
- package/{build → src}/models/buildings.js +14 -20
- package/{build → src}/models/destroyable.js +425 -332
- 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/CHANGELOG.md +0 -50
- package/build/buildings/crystal.test.js +0 -32
- package/build/buildings/deut.test.js +0 -32
- 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.test.js +0 -32
- 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/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
package/package.json
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ogamejs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "",
|
|
5
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.js",
|
|
7
|
+
"exports": "./src/index.js",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=24"
|
|
10
|
+
},
|
|
6
11
|
"scripts": {
|
|
7
|
-
"start": "babel-node index.js",
|
|
8
12
|
"commit": "git-cz",
|
|
9
|
-
"build": "babel src -d build",
|
|
10
13
|
"lint": "eslint .",
|
|
11
|
-
"test": "
|
|
14
|
+
"test": "vitest run",
|
|
15
|
+
"test:watch": "vitest",
|
|
16
|
+
"release": "semantic-release"
|
|
12
17
|
},
|
|
13
18
|
"files": [
|
|
14
|
-
"
|
|
19
|
+
"src",
|
|
20
|
+
"!src/**/*.test.js"
|
|
15
21
|
],
|
|
16
22
|
"repository": {
|
|
17
23
|
"type": "git",
|
|
@@ -25,32 +31,17 @@
|
|
|
25
31
|
],
|
|
26
32
|
"author": "n.riquelmebareiro@gmail.com",
|
|
27
33
|
"license": "MIT",
|
|
28
|
-
"jest": {
|
|
29
|
-
"transform": {
|
|
30
|
-
"^.+\\.jsx?$": "babel-jest"
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
34
|
"devDependencies": {
|
|
34
|
-
"@
|
|
35
|
-
"@
|
|
36
|
-
"@
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"cz
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"eslint-plugin-jsx-a11y": "^6.2.3",
|
|
45
|
-
"eslint-plugin-react": "^7.19.0",
|
|
46
|
-
"eslint-plugin-security": "^1.4.0",
|
|
47
|
-
"git-cz": "^4.3.1",
|
|
48
|
-
"jest": "^25.3.0",
|
|
49
|
-
"regenerator-runtime": "^0.13.5",
|
|
50
|
-
"standard-version": "^8.0.1"
|
|
51
|
-
},
|
|
52
|
-
"dependencies": {
|
|
53
|
-
"lodash": "^4.17.15"
|
|
35
|
+
"@eslint/js": "^9.19.0",
|
|
36
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
37
|
+
"@semantic-release/git": "^10.0.1",
|
|
38
|
+
"cz-conventional-changelog": "^3.3.0",
|
|
39
|
+
"eslint": "^9.19.0",
|
|
40
|
+
"eslint-plugin-security": "^3.0.1",
|
|
41
|
+
"git-cz": "^4.9.0",
|
|
42
|
+
"globals": "^15.14.0",
|
|
43
|
+
"semantic-release": "^25.0.8",
|
|
44
|
+
"vitest": "^3.0.4"
|
|
54
45
|
},
|
|
55
46
|
"config": {
|
|
56
47
|
"commitizen": {
|
|
@@ -1,40 +1,36 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
1
|
function getPositionFactor(pos) {
|
|
9
|
-
|
|
2
|
+
const factor = {
|
|
10
3
|
1: 1.3,
|
|
11
4
|
2: 1.225,
|
|
12
|
-
3: 1.15
|
|
5
|
+
3: 1.15,
|
|
13
6
|
};
|
|
7
|
+
|
|
14
8
|
return factor[Number.parseInt(pos, 10)] ? factor[Number.parseInt(pos, 10)] : 1;
|
|
15
9
|
}
|
|
16
10
|
|
|
17
11
|
function getMineProduction(baseProduction, targetLevel, pos, universeSpeed) {
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
const positionFactor = getPositionFactor(pos);
|
|
13
|
+
const levelFactor = 1.1 ** targetLevel;
|
|
14
|
+
|
|
20
15
|
return Math.floor(baseProduction * targetLevel * levelFactor * universeSpeed * positionFactor);
|
|
21
16
|
}
|
|
22
17
|
|
|
23
18
|
function getEnergyCost(baseEnergyCost, targetLevel) {
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
const level = targetLevel;
|
|
20
|
+
const levelFactor = 1.1 ** level;
|
|
26
21
|
return Math.floor(baseEnergyCost * level * levelFactor);
|
|
27
22
|
}
|
|
28
23
|
|
|
29
24
|
function getMetalCost(baseMetalCost, targetLevel) {
|
|
30
|
-
|
|
31
|
-
return Math.floor(baseMetalCost *
|
|
25
|
+
const level = targetLevel - 1;
|
|
26
|
+
return Math.floor(baseMetalCost * 1.6 ** level);
|
|
32
27
|
}
|
|
33
28
|
|
|
34
29
|
function getCrystalCost(baseCrystalCost, targetLevel) {
|
|
35
|
-
|
|
36
|
-
return Math.floor(baseCrystalCost *
|
|
30
|
+
const level = targetLevel - 1;
|
|
31
|
+
return Math.floor(baseCrystalCost * 1.6 ** level);
|
|
37
32
|
}
|
|
33
|
+
|
|
38
34
|
/**
|
|
39
35
|
*
|
|
40
36
|
* Return information about the crystal mine given a specific level
|
|
@@ -44,18 +40,14 @@ function getCrystalCost(baseCrystalCost, targetLevel) {
|
|
|
44
40
|
* @param {number} universeSpeed production factor is increased for some universe
|
|
45
41
|
* @returns {Object} informations about the crystal mine at this specific level
|
|
46
42
|
*/
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
function getCrystalMine(mine, targetLevel, pos) {
|
|
50
|
-
var universeSpeed = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
43
|
+
function getCrystalMine(mine, targetLevel, pos, universeSpeed = 1) {
|
|
51
44
|
return {
|
|
52
45
|
crystal: getCrystalCost(mine.crystal, targetLevel),
|
|
53
46
|
deuterium: 0,
|
|
54
47
|
energy: getEnergyCost(mine.energy, targetLevel),
|
|
55
48
|
metal: getMetalCost(mine.metal, targetLevel),
|
|
56
|
-
production: getMineProduction(mine.production, targetLevel, pos, universeSpeed)
|
|
49
|
+
production: getMineProduction(mine.production, targetLevel, pos, universeSpeed),
|
|
57
50
|
};
|
|
58
51
|
}
|
|
59
52
|
|
|
60
|
-
|
|
61
|
-
exports["default"] = _default;
|
|
53
|
+
export default getCrystalMine;
|
|
@@ -1,34 +1,28 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
1
|
function getPositionFactor(avg) {
|
|
9
2
|
return 0.68 - 0.002 * avg;
|
|
10
3
|
}
|
|
11
4
|
|
|
12
5
|
function getMineProduction(energyCost, avg, universeSpeed) {
|
|
13
|
-
|
|
6
|
+
const factor = getPositionFactor(avg);
|
|
14
7
|
return Math.floor(universeSpeed * energyCost * factor);
|
|
15
8
|
}
|
|
16
9
|
|
|
17
10
|
function getEnergyCost(baseEnergyCost, targetLevel) {
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
const level = targetLevel;
|
|
12
|
+
const levelFactor = 1.1 ** level;
|
|
20
13
|
return Math.floor(baseEnergyCost * level * levelFactor);
|
|
21
14
|
}
|
|
22
15
|
|
|
23
16
|
function getMetalCost(baseMetalCost, targetLevel) {
|
|
24
|
-
|
|
25
|
-
return Math.floor(baseMetalCost *
|
|
17
|
+
const level = targetLevel - 1;
|
|
18
|
+
return Math.floor(baseMetalCost * 1.5 ** level);
|
|
26
19
|
}
|
|
27
20
|
|
|
28
21
|
function getCrystalCost(baseCrystalCost, targetLevel) {
|
|
29
|
-
|
|
30
|
-
return Math.floor(baseCrystalCost *
|
|
22
|
+
const level = targetLevel - 1;
|
|
23
|
+
return Math.floor(baseCrystalCost * 1.5 ** level);
|
|
31
24
|
}
|
|
25
|
+
|
|
32
26
|
/**
|
|
33
27
|
*
|
|
34
28
|
* Return information about the deuterium synth given a specific level
|
|
@@ -38,19 +32,15 @@ function getCrystalCost(baseCrystalCost, targetLevel) {
|
|
|
38
32
|
* @param {number} universeSpeed production factor is increased for some universe
|
|
39
33
|
* @returns {Object} informations about the deut synth at this specific level
|
|
40
34
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
function getDeutSynth(mine, targetLevel, avg) {
|
|
44
|
-
var universeSpeed = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
45
|
-
var energyCost = getEnergyCost(mine.energy, targetLevel);
|
|
35
|
+
function getDeutSynth(mine, targetLevel, avg, universeSpeed = 1) {
|
|
36
|
+
const energyCost = getEnergyCost(mine.energy, targetLevel);
|
|
46
37
|
return {
|
|
47
38
|
crystal: getCrystalCost(mine.crystal, targetLevel),
|
|
48
39
|
energy: energyCost,
|
|
49
40
|
deuterium: 0,
|
|
50
41
|
metal: getMetalCost(mine.metal, targetLevel),
|
|
51
|
-
production: getMineProduction(energyCost, avg, universeSpeed)
|
|
42
|
+
production: getMineProduction(energyCost, avg, universeSpeed),
|
|
52
43
|
};
|
|
53
44
|
}
|
|
54
45
|
|
|
55
|
-
|
|
56
|
-
exports["default"] = _default;
|
|
46
|
+
export default getDeutSynth;
|
|
@@ -1,38 +1,32 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
1
|
function getEnergyFactor(energyTech) {
|
|
9
2
|
return 1.05 + 0.01 * energyTech;
|
|
10
3
|
}
|
|
11
4
|
|
|
12
5
|
function getEnergyProduction(baseProduction, targetLevel, energyTech) {
|
|
13
|
-
|
|
6
|
+
const factor = getEnergyFactor(energyTech) ** targetLevel;
|
|
14
7
|
return Math.floor(baseProduction * targetLevel * factor);
|
|
15
8
|
}
|
|
16
9
|
|
|
17
10
|
function getMetalCost(baseMetalCost, targetLevel) {
|
|
18
|
-
|
|
19
|
-
return Math.floor(baseMetalCost *
|
|
11
|
+
const level = targetLevel - 1;
|
|
12
|
+
return Math.floor(baseMetalCost * 1.8 ** level);
|
|
20
13
|
}
|
|
21
14
|
|
|
22
15
|
function getCrystalCost(baseCrystalCost, targetLevel) {
|
|
23
|
-
|
|
24
|
-
return Math.floor(baseCrystalCost *
|
|
16
|
+
const level = targetLevel - 1;
|
|
17
|
+
return Math.floor(baseCrystalCost * 1.8 ** level);
|
|
25
18
|
}
|
|
26
19
|
|
|
27
20
|
function getDeuteriumCost(baseDeuteriumCost, targetLevel) {
|
|
28
|
-
|
|
29
|
-
return Math.floor(baseDeuteriumCost *
|
|
21
|
+
const level = targetLevel - 1;
|
|
22
|
+
return Math.floor(baseDeuteriumCost * 1.8 ** level);
|
|
30
23
|
}
|
|
31
24
|
|
|
32
25
|
function getConsumption(baseConsumption, targetLevel, universeSpeed) {
|
|
33
|
-
|
|
26
|
+
const levelFactor = 1.1 ** targetLevel;
|
|
34
27
|
return Math.floor(baseConsumption * targetLevel * levelFactor * universeSpeed);
|
|
35
28
|
}
|
|
29
|
+
|
|
36
30
|
/**
|
|
37
31
|
*
|
|
38
32
|
* Return information about the fusion reactor given a specific level
|
|
@@ -42,19 +36,15 @@ function getConsumption(baseConsumption, targetLevel, universeSpeed) {
|
|
|
42
36
|
* @param {number} universeSpeed production factor is increased for some universe
|
|
43
37
|
* @returns {Object} informations about the fusion reactor at this specific level
|
|
44
38
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
function getFusionReactor(reactor, targetLevel, energyTech) {
|
|
48
|
-
var universeSpeed = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
39
|
+
function getFusionReactor(reactor, targetLevel, energyTech, universeSpeed = 1) {
|
|
49
40
|
return {
|
|
50
41
|
crystal: getCrystalCost(reactor.crystal, targetLevel),
|
|
51
42
|
energy: 0,
|
|
52
43
|
consumption: getConsumption(reactor.consumption, targetLevel, universeSpeed),
|
|
53
44
|
deuterium: getDeuteriumCost(reactor.deutrium, targetLevel),
|
|
54
45
|
metal: getMetalCost(reactor.metal, targetLevel),
|
|
55
|
-
production: getEnergyProduction(reactor.production, targetLevel, energyTech)
|
|
46
|
+
production: getEnergyProduction(reactor.production, targetLevel, energyTech),
|
|
56
47
|
};
|
|
57
48
|
}
|
|
58
49
|
|
|
59
|
-
|
|
60
|
-
exports["default"] = _default;
|
|
50
|
+
export default getFusionReactor;
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
|
|
8
|
+
const Buildings = {
|
|
9
|
+
getCrystalMine,
|
|
10
|
+
getDeutSynth,
|
|
11
|
+
getMetalMine,
|
|
12
|
+
getSolarPlant,
|
|
13
|
+
getFusionReactor,
|
|
14
|
+
parseInfoCompteData,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default Buildings;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
function toNumber(number = '') {
|
|
2
|
+
return Number(number.split('.').join(''));
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* Return information about the crystal mine given a specific level
|
|
8
|
+
* @param {object} data The infocompte bb-code
|
|
9
|
+
* @returns {Object} The parsed JSON object of infocompte
|
|
10
|
+
*/
|
|
11
|
+
function parseInfoCompteData(data) {
|
|
12
|
+
const universeDataRe = new RegExp('([0-9]{3}-[a-z]{2})');
|
|
13
|
+
const [universe, lang] = data.match(universeDataRe)[1].split('-');
|
|
14
|
+
|
|
15
|
+
// eslint-disable-next-line security/detect-unsafe-regex
|
|
16
|
+
const planetsRe = new RegExp('(?:Planète [0-9]+(.+))(?:s+(?:Planète [0-9]+))*', 'g');
|
|
17
|
+
const planets = data.matchAll(planetsRe);
|
|
18
|
+
|
|
19
|
+
const metalPointRe = new RegExp('Points dans les mines de métal : (.+)');
|
|
20
|
+
const metalPoint = toNumber(data.match(metalPointRe)[1]);
|
|
21
|
+
|
|
22
|
+
const crystalPointRe = new RegExp('Points dans les mines de cristal : (.+)');
|
|
23
|
+
const crystalPoint = toNumber(data.match(crystalPointRe)[1]);
|
|
24
|
+
|
|
25
|
+
const deutRe = new RegExp('Points dans les mines de deut : (.+)');
|
|
26
|
+
const deutPoint = toNumber(data.match(deutRe)[1]);
|
|
27
|
+
|
|
28
|
+
const plasmaRe = new RegExp('Technologie Plasma : (.+)');
|
|
29
|
+
const plasmaTechLevel = toNumber(data.match(plasmaRe)[1]);
|
|
30
|
+
|
|
31
|
+
const hourlyRe = new RegExp('Par heure : (.+)');
|
|
32
|
+
const hourly = data.match(hourlyRe);
|
|
33
|
+
|
|
34
|
+
const [hourlyMetal, hourlyCristal, hourlyDeut] = hourly[1].split('/');
|
|
35
|
+
|
|
36
|
+
const [hourlyMetalValue] = hourlyMetal.split(' ');
|
|
37
|
+
const hourlyMetalNumber = toNumber(hourlyMetalValue);
|
|
38
|
+
|
|
39
|
+
const [hourlyCristalValue] = hourlyCristal.split(' ').filter(Boolean);
|
|
40
|
+
const hourlyCristalNumber = toNumber(hourlyCristalValue);
|
|
41
|
+
|
|
42
|
+
const [hourlyDeutValue] = hourlyDeut.split(' ').filter(Boolean);
|
|
43
|
+
const hourlyDeutNumber = toNumber(hourlyDeutValue);
|
|
44
|
+
|
|
45
|
+
const response = {
|
|
46
|
+
planets: [],
|
|
47
|
+
production: {
|
|
48
|
+
hourly: {
|
|
49
|
+
metal: hourlyMetalNumber,
|
|
50
|
+
crystal: hourlyCristalNumber,
|
|
51
|
+
deut: hourlyDeutNumber,
|
|
52
|
+
},
|
|
53
|
+
daily: {
|
|
54
|
+
metal: hourlyMetalNumber * 24,
|
|
55
|
+
crystal: hourlyCristalNumber * 24,
|
|
56
|
+
deut: hourlyDeutNumber * 24,
|
|
57
|
+
},
|
|
58
|
+
weekly: {
|
|
59
|
+
metal: hourlyMetalNumber * 24 * 7,
|
|
60
|
+
crystal: hourlyCristalNumber * 24 * 7,
|
|
61
|
+
deut: hourlyDeutNumber * 24 * 7,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
points: {
|
|
65
|
+
metal: metalPoint,
|
|
66
|
+
crystal: crystalPoint,
|
|
67
|
+
deut: deutPoint,
|
|
68
|
+
total: metalPoint + crystalPoint + deutPoint,
|
|
69
|
+
},
|
|
70
|
+
plasma: plasmaTechLevel,
|
|
71
|
+
universe: Number(universe),
|
|
72
|
+
lang,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
for (const planet of planets) {
|
|
76
|
+
const [planetMetal, crystal, deut, temperatureText] = planet[0].split('/');
|
|
77
|
+
const [temperature] = temperatureText.split('°');
|
|
78
|
+
const [thePlanet, metal] = planetMetal.split(':');
|
|
79
|
+
|
|
80
|
+
response.planets.push({
|
|
81
|
+
planet: thePlanet.trim(),
|
|
82
|
+
metal: metal.trim().split(' ')[1],
|
|
83
|
+
crystal: crystal.trim().split(' ')[1],
|
|
84
|
+
deut: deut.trim().split(' ')[1],
|
|
85
|
+
temperature: Number.parseInt(temperature.trim(), 10),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return response;
|
|
90
|
+
}
|
|
91
|
+
export default parseInfoCompteData;
|
|
@@ -1,30 +1,25 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
1
|
function getMineProduction(baseProduction, targetLevel, universeSpeed) {
|
|
9
|
-
|
|
2
|
+
const levelFactor = 1.1 ** targetLevel;
|
|
3
|
+
|
|
10
4
|
return Math.floor(baseProduction * targetLevel * levelFactor * universeSpeed);
|
|
11
5
|
}
|
|
12
6
|
|
|
13
7
|
function getEnergyCost(baseEnergyCost, targetLevel) {
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
const level = targetLevel;
|
|
9
|
+
const levelFactor = 1.1 ** level;
|
|
16
10
|
return Math.floor(baseEnergyCost * level * levelFactor);
|
|
17
11
|
}
|
|
18
12
|
|
|
19
13
|
function getMetalCost(baseMetalCost, targetLevel) {
|
|
20
|
-
|
|
21
|
-
return Math.floor(baseMetalCost *
|
|
14
|
+
const level = targetLevel - 1;
|
|
15
|
+
return Math.floor(baseMetalCost * 1.5 ** level);
|
|
22
16
|
}
|
|
23
17
|
|
|
24
18
|
function getCrystalCost(baseCrystalCost, targetLevel) {
|
|
25
|
-
|
|
26
|
-
return Math.floor(baseCrystalCost *
|
|
19
|
+
const level = targetLevel - 1;
|
|
20
|
+
return Math.floor(baseCrystalCost * 1.5 ** level);
|
|
27
21
|
}
|
|
22
|
+
|
|
28
23
|
/**
|
|
29
24
|
*
|
|
30
25
|
* Return information about the metal mine given a specific level
|
|
@@ -33,18 +28,14 @@ function getCrystalCost(baseCrystalCost, targetLevel) {
|
|
|
33
28
|
* @param {number} universeSpeed production factor is increased for some universe
|
|
34
29
|
* @returns {Object} informations about the metal mine at this specific level
|
|
35
30
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
function getMetalMine(mine, targetLevel) {
|
|
39
|
-
var universeSpeed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
31
|
+
function getMetalMine(mine, targetLevel, universeSpeed = 1) {
|
|
40
32
|
return {
|
|
41
33
|
crystal: getCrystalCost(mine.crystal, targetLevel),
|
|
42
34
|
deuterium: 0,
|
|
43
35
|
energy: getEnergyCost(mine.energy, targetLevel),
|
|
44
36
|
metal: getMetalCost(mine.metal, targetLevel),
|
|
45
|
-
production: getMineProduction(mine.production, targetLevel, universeSpeed)
|
|
37
|
+
production: getMineProduction(mine.production, targetLevel, universeSpeed),
|
|
46
38
|
};
|
|
47
39
|
}
|
|
48
40
|
|
|
49
|
-
|
|
50
|
-
exports["default"] = _default;
|
|
41
|
+
export default getMetalMine;
|
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
|
|
8
1
|
function getEnergyProduction(baseProduction, targetLevel) {
|
|
9
|
-
|
|
2
|
+
const levelFactor = 1.1 ** targetLevel;
|
|
10
3
|
return Math.floor(baseProduction * targetLevel * levelFactor);
|
|
11
4
|
}
|
|
12
5
|
|
|
13
6
|
function getMetalCost(baseMetalCost, targetLevel) {
|
|
14
|
-
|
|
15
|
-
return Math.floor(baseMetalCost *
|
|
7
|
+
const level = targetLevel - 1;
|
|
8
|
+
return Math.floor(baseMetalCost * 1.5 ** level);
|
|
16
9
|
}
|
|
17
10
|
|
|
18
11
|
function getCrystalCost(baseCrystalCost, targetLevel) {
|
|
19
|
-
|
|
20
|
-
return Math.floor(baseCrystalCost *
|
|
12
|
+
const level = targetLevel - 1;
|
|
13
|
+
return Math.floor(baseCrystalCost * 1.5 ** level);
|
|
21
14
|
}
|
|
15
|
+
|
|
22
16
|
/**
|
|
23
17
|
*
|
|
24
18
|
* Return information about the solar plant given a specific level
|
|
@@ -26,17 +20,14 @@ function getCrystalCost(baseCrystalCost, targetLevel) {
|
|
|
26
20
|
* @param {number} targetLevel
|
|
27
21
|
* @returns {Object} informations about the solar plant at this specific level
|
|
28
22
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
23
|
function getSolarPlant(solarPlant, targetLevel) {
|
|
32
24
|
return {
|
|
33
25
|
crystal: getCrystalCost(solarPlant.crystal, targetLevel),
|
|
34
26
|
energy: 0,
|
|
35
27
|
deuterium: 0,
|
|
36
28
|
metal: getMetalCost(solarPlant.metal, targetLevel),
|
|
37
|
-
production: getEnergyProduction(solarPlant.production, targetLevel)
|
|
29
|
+
production: getEnergyProduction(solarPlant.production, targetLevel),
|
|
38
30
|
};
|
|
39
31
|
}
|
|
40
32
|
|
|
41
|
-
|
|
42
|
-
exports["default"] = _default;
|
|
33
|
+
export default getSolarPlant;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Returns the number of debris generated
|
|
4
|
+
* @param {number} shipId The ship identifier
|
|
5
|
+
* @param {number} number The number of ship
|
|
6
|
+
* @param {number} factor The universe debris factor
|
|
7
|
+
* @return {Object} The debris generated
|
|
8
|
+
*/
|
|
9
|
+
function getDebris(ship, number, factor) {
|
|
10
|
+
const { cost } = ship;
|
|
11
|
+
const metalDebris = cost.metal ? cost.metal * factor : 0;
|
|
12
|
+
const crystalDebris = cost.crystal ? cost.crystal * factor : 0;
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
metal: metalDebris * number,
|
|
16
|
+
crystal: crystalDebris * number,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default getDebris;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import Trader from './trades/index.js';
|
|
2
|
+
import Building from './buildings/index.js';
|
|
3
|
+
import Fleets from './fleets/index.js';
|
|
4
|
+
import Buildings from './models/buildings.js';
|
|
5
|
+
import Destroyable from './models/destroyable.js';
|
|
6
|
+
|
|
7
|
+
const Ogame = {
|
|
8
|
+
Trader,
|
|
9
|
+
Building,
|
|
10
|
+
Fleets,
|
|
11
|
+
models: {
|
|
12
|
+
Buildings,
|
|
13
|
+
Destroyable,
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default Ogame;
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var BUILDINGS = Object.freeze({
|
|
1
|
+
const BUILDINGS = Object.freeze({
|
|
8
2
|
1: {
|
|
9
3
|
name: 'Mine de métal',
|
|
10
4
|
base: {
|
|
@@ -13,8 +7,8 @@ var BUILDINGS = Object.freeze({
|
|
|
13
7
|
metal: 60,
|
|
14
8
|
crystal: 15,
|
|
15
9
|
deutrium: 0,
|
|
16
|
-
energy: 10
|
|
17
|
-
}
|
|
10
|
+
energy: 10,
|
|
11
|
+
},
|
|
18
12
|
},
|
|
19
13
|
2: {
|
|
20
14
|
name: 'Mine de cristal',
|
|
@@ -24,8 +18,8 @@ var BUILDINGS = Object.freeze({
|
|
|
24
18
|
metal: 48,
|
|
25
19
|
crystal: 24,
|
|
26
20
|
deutrium: 0,
|
|
27
|
-
energy: 10
|
|
28
|
-
}
|
|
21
|
+
energy: 10,
|
|
22
|
+
},
|
|
29
23
|
},
|
|
30
24
|
3: {
|
|
31
25
|
name: 'Synthétiseur de deutérium',
|
|
@@ -35,8 +29,8 @@ var BUILDINGS = Object.freeze({
|
|
|
35
29
|
metal: 225,
|
|
36
30
|
crystal: 75,
|
|
37
31
|
deutrium: 0,
|
|
38
|
-
energy: 20
|
|
39
|
-
}
|
|
32
|
+
energy: 20,
|
|
33
|
+
},
|
|
40
34
|
},
|
|
41
35
|
4: {
|
|
42
36
|
name: 'Centrale électrique solaire',
|
|
@@ -46,8 +40,8 @@ var BUILDINGS = Object.freeze({
|
|
|
46
40
|
metal: 75,
|
|
47
41
|
crystal: 30,
|
|
48
42
|
deutrium: 0,
|
|
49
|
-
energy: 0
|
|
50
|
-
}
|
|
43
|
+
energy: 0,
|
|
44
|
+
},
|
|
51
45
|
},
|
|
52
46
|
5: {
|
|
53
47
|
name: 'Centrale électrique de fusion',
|
|
@@ -57,9 +51,9 @@ var BUILDINGS = Object.freeze({
|
|
|
57
51
|
metal: 900,
|
|
58
52
|
crystal: 360,
|
|
59
53
|
deutrium: 180,
|
|
60
|
-
energy: 0
|
|
61
|
-
}
|
|
62
|
-
}
|
|
54
|
+
energy: 0,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
63
57
|
});
|
|
64
|
-
|
|
65
|
-
|
|
58
|
+
|
|
59
|
+
export default BUILDINGS;
|