ogamejs 2.1.1 → 2.1.4
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/CHANGELOG.md +4 -0
- package/README.md +202 -27
- package/build/buildings/infocompte.js +18 -2
- package/build/buildings/infocompte.test.js +3 -1
- package/package.json +3 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [2.1.3](https://github.com/rolljee/ogamejs/compare/v2.1.2...v2.1.3) (2020-04-16)
|
|
6
|
+
|
|
7
|
+
### [2.1.2](https://github.com/rolljee/ogamejs/compare/v2.1.1...v2.1.2) (2020-04-12)
|
|
8
|
+
|
|
5
9
|
### [2.1.1](https://github.com/rolljee/ogamejs/compare/v2.1.0...v2.1.1) (2020-04-12)
|
|
6
10
|
|
|
7
11
|
### [2.0.4](https://github.com/rolljee/ogamejs/compare/v2.0.3...v2.0.4) (2020-04-08)
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Introduction
|
|
4
4
|
|
|
5
|
-
I always wanted an Ogame calculator that suited me, all those I could see online are, either too old in graphic terms, or it didn't work, it was calculating badly the number of resources to send for each exchange...
|
|
5
|
+
I always wanted an Ogame calculator that suited me, all those I could see online are, either too old in graphic terms, or it didn't work, it was calculating badly the number of resources to send for each exchange...
|
|
6
6
|
|
|
7
7
|
So I decided to write a library in Javascript to create accessible methods to perform all calculations in a simple way for anyone who wants to create a graphical interface.
|
|
8
8
|
|
|
@@ -10,51 +10,226 @@ So I decided to write a library in Javascript to create accessible methods to pe
|
|
|
10
10
|
|
|
11
11
|
All available methods will be listed below
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
### Building
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
* `getCrystalMine` Return information about the crystal mine given a specific level
|
|
16
|
+
|
|
17
|
+
``` javascript
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* Return information about the crystal mine given a specific level
|
|
21
|
+
* @param {object} mine The crystal mine base information
|
|
22
|
+
* @param {number} targetLevel the crystal mine target level
|
|
23
|
+
* @param {number} pos pos 1/2/3 have a 15/10/5%
|
|
24
|
+
* @param {number} universeSpeed production factor is increased for some universe
|
|
25
|
+
* @returns {Object} informations about the crystal mine at this specific level
|
|
26
|
+
*/
|
|
27
|
+
function getCrystalMine(mine, targetLevel, pos, universeSpeed = 1) {
|
|
28
|
+
@return {
|
|
29
|
+
crystal: Number,
|
|
30
|
+
deut: Number,
|
|
31
|
+
energy: Number,
|
|
32
|
+
metal: Number,
|
|
33
|
+
production: Number
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
* `getDeutSynth` Return information about the deuterium synth given a specific level
|
|
39
|
+
|
|
40
|
+
``` javascript
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* Return information about the deuterium synth given a specific level
|
|
44
|
+
* @param {object} mine The deut synth base information
|
|
45
|
+
* @param {number} targetLevel the deuterieum synth target level
|
|
46
|
+
* @param {number} avg planet average temperature - The lower the higher the prod is
|
|
47
|
+
* @param {number} universeSpeed production factor is increased for some universe
|
|
48
|
+
* @returns {Object} informations about the deut synth at this specific level
|
|
49
|
+
*/
|
|
50
|
+
function getDeutSynth(mine, targetLevel, avg, universeSpeed = 1) {
|
|
51
|
+
@return {
|
|
52
|
+
crystal: Number,
|
|
53
|
+
deut: Number,
|
|
54
|
+
energy: Number,
|
|
55
|
+
metal: Number,
|
|
56
|
+
production: Number
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
* `getMetalMine` Return information about the metal mine given a specific level
|
|
62
|
+
|
|
63
|
+
``` javascript
|
|
64
|
+
/**
|
|
65
|
+
*
|
|
66
|
+
* Return information about the metal mine given a specific level
|
|
67
|
+
* @param {object} mine The metal mine base information
|
|
68
|
+
* @param {number} targetLevel
|
|
69
|
+
* @param {number} universeSpeed production factor is increased for some universe
|
|
70
|
+
* @returns {Object} informations about the metal mine at this specific level
|
|
71
|
+
*/
|
|
72
|
+
function getMetalMine(mine, targetLevel, universeSpeed = 1) {
|
|
73
|
+
@return {
|
|
74
|
+
crystal: Number,
|
|
75
|
+
deut: Number,
|
|
76
|
+
energy: Number,
|
|
77
|
+
metal: Number,
|
|
78
|
+
production: Number
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
* `getSolarPlant` Return information about the solar plant given a specific level
|
|
84
|
+
|
|
85
|
+
``` javascript
|
|
86
|
+
/**
|
|
87
|
+
*
|
|
88
|
+
* Return information about the solar plant given a specific level
|
|
89
|
+
* @param {object} solarPlant The solarPlant base information
|
|
90
|
+
* @param {number} targetLevel
|
|
91
|
+
* @returns {Object} informations about the solar plant at this specific level
|
|
92
|
+
*/
|
|
93
|
+
function getSolarPlant(solarPlant, targetLevel) {
|
|
94
|
+
@return {
|
|
95
|
+
crystal: Number,
|
|
96
|
+
deut: Number,
|
|
97
|
+
energy: Number,
|
|
98
|
+
metal: Number,
|
|
99
|
+
production: Number
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
* `getFusionReactor` Return information about the fusion reactor given a specific level
|
|
105
|
+
|
|
106
|
+
``` javascript
|
|
107
|
+
/**
|
|
108
|
+
*
|
|
109
|
+
* Return information about the fusion reactor given a specific level
|
|
110
|
+
* @param {object} reactor The fusion react base information
|
|
111
|
+
* @param {number} targetLevel
|
|
112
|
+
* @param {number} energyTech The technology energy level
|
|
113
|
+
* @param {number} universeSpeed production factor is increased for some universe
|
|
114
|
+
* @returns {Object} informations about the fusion reactor at this specific level
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
function getFusionReactor(reactor, targetLevel, energyTech, universeSpeed = 1) {
|
|
118
|
+
@return {
|
|
119
|
+
crystal: Number,
|
|
120
|
+
deut: Number,
|
|
121
|
+
energy: Number,
|
|
122
|
+
metal: Number,
|
|
123
|
+
production: Number
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
* `parseInfoCompteData` Return the number of debris generated
|
|
129
|
+
|
|
130
|
+
``` javascript
|
|
131
|
+
/**
|
|
132
|
+
*
|
|
133
|
+
* Return information about the crystal mine given a specific level
|
|
134
|
+
* @param {object} data The infocompte bb-code
|
|
135
|
+
* @returns {Object} The parsed JSON object of infocompte
|
|
136
|
+
*/
|
|
137
|
+
function parseInfoCompteData(data) {
|
|
138
|
+
@return {
|
|
139
|
+
planet: String,
|
|
140
|
+
metal: String,
|
|
141
|
+
crystal: String,
|
|
142
|
+
deut: String,
|
|
143
|
+
temperature: Number,
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Fleet
|
|
149
|
+
|
|
150
|
+
* `getDebris` Return the number of debris generated
|
|
151
|
+
|
|
152
|
+
``` javascript
|
|
153
|
+
/**
|
|
154
|
+
*
|
|
155
|
+
* Returns the number of debris generated
|
|
156
|
+
* @param {number} shipId The ship identifier
|
|
157
|
+
* @param {number} number The number of ship
|
|
158
|
+
* @param {number} factor The universe debris factor
|
|
159
|
+
* @return {Object} The debris generated
|
|
160
|
+
*/
|
|
161
|
+
getDebris(ship, number, facror) {
|
|
162
|
+
@return {
|
|
163
|
+
metal: Number,
|
|
164
|
+
crystal: Number,
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Trader
|
|
170
|
+
|
|
171
|
+
* `sellDeut` Exchange of deuterium against `Metal` and `Crystal`
|
|
172
|
+
|
|
173
|
+
``` javascript
|
|
16
174
|
// All params are optionnals
|
|
17
175
|
// values placed here will be used if not specified
|
|
18
|
-
sellDeut(deut = 0, percentM = 60, percentC = 40, rate = '2:1.5:1')
|
|
19
|
-
@return {
|
|
20
|
-
|
|
21
|
-
|
|
176
|
+
sellDeut(deut = 0, percentM = 60, percentC = 40, rate = '2:1.5:1') {
|
|
177
|
+
@return {
|
|
178
|
+
metal: Number,
|
|
179
|
+
crystal: Number
|
|
180
|
+
}
|
|
22
181
|
}
|
|
23
182
|
```
|
|
24
183
|
|
|
25
|
-
|
|
184
|
+
* `sellMetal` Exchange of deuterium against `Metal` and `Crystal`
|
|
26
185
|
|
|
27
|
-
```javascript
|
|
186
|
+
``` javascript
|
|
28
187
|
// All params are optionnals
|
|
29
188
|
// values placed here will be used if not specified
|
|
30
|
-
sellMetal(metal = 0, percentD = 40, percentC = 60, rate = '2:1.5:1')
|
|
31
|
-
@return {
|
|
32
|
-
|
|
33
|
-
|
|
189
|
+
sellMetal(metal = 0, percentD = 40, percentC = 60, rate = '2:1.5:1') {
|
|
190
|
+
@return {
|
|
191
|
+
deut: Number,
|
|
192
|
+
metal: Number
|
|
193
|
+
}
|
|
34
194
|
}
|
|
35
195
|
```
|
|
36
196
|
|
|
37
|
-
|
|
197
|
+
* `sellCrystal` Exchange of deuterium against `Metal` and `Crystal`
|
|
38
198
|
|
|
39
|
-
```javascript
|
|
199
|
+
``` javascript
|
|
40
200
|
// All params are optionnals
|
|
41
201
|
// values placed here will be used if not specified
|
|
42
|
-
sellCrystal(crystal = 0, percentD = 40, percentM = 60, rate = '2:1.5:1')
|
|
43
|
-
@return {
|
|
44
|
-
|
|
45
|
-
|
|
202
|
+
sellCrystal(crystal = 0, percentD = 40, percentM = 60, rate = '2:1.5:1') {
|
|
203
|
+
@return {
|
|
204
|
+
deut: Number,
|
|
205
|
+
metal: Number
|
|
206
|
+
}
|
|
46
207
|
}
|
|
47
208
|
```
|
|
48
209
|
|
|
49
|
-
|
|
210
|
+
* `parseRate()` Parse the exchange rate
|
|
50
211
|
|
|
51
|
-
```javascript
|
|
212
|
+
``` javascript
|
|
52
213
|
// All params are optionnals
|
|
53
214
|
// values placed here will be used if not specified
|
|
54
|
-
parseRate(rate = '2:1.5:1') {
|
|
55
|
-
@return {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
};
|
|
215
|
+
parseRate(rate = '2:1.5:1') {
|
|
216
|
+
@return {
|
|
217
|
+
rateDeut: Number,
|
|
218
|
+
rateMetal: Number,
|
|
219
|
+
rateCrystal: Number
|
|
220
|
+
};
|
|
221
|
+
}
|
|
60
222
|
```
|
|
223
|
+
|
|
224
|
+
### Models
|
|
225
|
+
|
|
226
|
+
Listed below are categories of Buildings / Ships / Defenses
|
|
227
|
+
|
|
228
|
+
#### Buildings
|
|
229
|
+
|
|
230
|
+
[Buildings](./src/models/buildings.js) Here you will find all listed Buildings in the game
|
|
231
|
+
|
|
232
|
+
#### Destroyable
|
|
233
|
+
|
|
234
|
+
[Destroyable](./src/models/destroyable.js) Here you will find all listed Ships / Defense in the game
|
|
235
|
+
|
|
@@ -23,9 +23,23 @@ function toNumber() {
|
|
|
23
23
|
var number = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
24
24
|
return Number(number.split('.').join(''));
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* Return information about the crystal mine given a specific level
|
|
29
|
+
* @param {object} data The infocompte bb-code
|
|
30
|
+
* @returns {Object} The parsed JSON object of infocompte
|
|
31
|
+
*/
|
|
32
|
+
|
|
26
33
|
|
|
27
34
|
function parseInfoCompteData(data) {
|
|
28
|
-
|
|
35
|
+
var universeDataRe = new RegExp('([0-9]{3}-[a-z]{2})');
|
|
36
|
+
|
|
37
|
+
var _data$match$1$split = data.match(universeDataRe)[1].split('-'),
|
|
38
|
+
_data$match$1$split2 = _slicedToArray(_data$match$1$split, 2),
|
|
39
|
+
universe = _data$match$1$split2[0],
|
|
40
|
+
lang = _data$match$1$split2[1]; // eslint-disable-next-line security/detect-unsafe-regex
|
|
41
|
+
|
|
42
|
+
|
|
29
43
|
var planetsRe = new RegExp('(?:Planète [0-9]+(.+))(?:s+(?:Planète [0-9]+))*', 'g');
|
|
30
44
|
var planets = data.matchAll(planetsRe);
|
|
31
45
|
var metalPointRe = new RegExp('Points dans les mines de métal : (.+)');
|
|
@@ -87,7 +101,9 @@ function parseInfoCompteData(data) {
|
|
|
87
101
|
deut: deutPoint,
|
|
88
102
|
total: metalPoint + crystalPoint + deutPoint
|
|
89
103
|
},
|
|
90
|
-
plasma: plasmaTechLevel
|
|
104
|
+
plasma: plasmaTechLevel,
|
|
105
|
+
universe: Number(universe),
|
|
106
|
+
lang: lang
|
|
91
107
|
}; // eslint-disable-next-line no-restricted-syntax
|
|
92
108
|
|
|
93
109
|
var _iterator = _createForOfIteratorHelper(planets),
|
package/package.json
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ogamejs",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"start": "babel-node index.js",
|
|
8
8
|
"commit": "git-cz",
|
|
9
|
-
"
|
|
10
|
-
"release": "standard-version",
|
|
11
|
-
"release:beta": "standard-version -p beta",
|
|
9
|
+
"build": "babel src -d build",
|
|
12
10
|
"lint": "eslint .",
|
|
13
11
|
"test": "jest"
|
|
14
12
|
},
|
|
@@ -49,7 +47,7 @@
|
|
|
49
47
|
"git-cz": "^4.3.1",
|
|
50
48
|
"jest": "^25.3.0",
|
|
51
49
|
"regenerator-runtime": "^0.13.5",
|
|
52
|
-
"standard-version": "^
|
|
50
|
+
"standard-version": "^8.0.1"
|
|
53
51
|
},
|
|
54
52
|
"dependencies": {
|
|
55
53
|
"lodash": "^4.17.15"
|