aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuben Beltran del Rio <jj@r.bdr.sh>2025-12-12 15:33:04 +0100
committerRuben Beltran del Rio <jj@r.bdr.sh>2025-12-12 18:01:10 +0100
commit80aefd27ffc19a948c74f2418a2a5bf5f95a6868 (patch)
tree87467674eadfacae3c4d3fecbbcb95a9c28519c7 /src
parentaee5dffd8013f6f6a6b77e5d00edd981bcfcad48 (diff)
Use stage instead of number, and use an actual signed value
Diffstat (limited to 'src')
-rw-r--r--src/index.js10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/index.js b/src/index.js
index 24a2c2e..f705f5a 100644
--- a/src/index.js
+++ b/src/index.js
@@ -44,7 +44,7 @@
* An override for the width of an evolution stage.
* @typedef {Object} Stage
* @property {'stage'} type - Entity type
- * @property {string} number - Stage number (i, ii, iii, iv)
+ * @property {string} stage - Stage number (i, ii, iii, iv)
* @property {number} value - Stage value
*/
@@ -67,7 +67,6 @@
* @typedef {Object} Evolution
* @property {'evolution'} type - Entity type
* @property {string} component - Component label
- * @property {boolean} isPositive - Whether evolution is positive (+) or negative (-)
* @property {number} value - Evolution value
*/
@@ -142,7 +141,7 @@ function parseKeywordEntity(line, start, length) {
// Skip whitespace after ']'
while (i < length && isWhitespace(line[i])) i++;
- // Stage: [I|II|III|IV] number
+ // Stage: [I|II|III|IV] stage
if (
keyword === "i" ||
keyword === "ii" ||
@@ -154,7 +153,7 @@ function parseKeywordEntity(line, start, length) {
if (i > numStart) {
return {
type: "stage",
- number: keyword,
+ stage: keyword,
value: parseFloat(line.substring(numStart, i)),
};
}
@@ -250,8 +249,7 @@ function parseKeywordEntity(line, start, length) {
return {
type: "evolution",
component,
- isPositive: signCharacter === "+",
- value: parseFloat(line.substring(numStart, indexOfNumber)),
+ value: (signCharacter === "+" ? 1 : -1) * parseFloat(line.substring(numStart, indexOfNumber)),
};
}