Skip to content
This repository was archived by the owner on Jan 28, 2026. It is now read-only.

Commit 79a19c8

Browse files
committed
Update 2.0.0
Updated class skill parsing to support new skill data structure and improved deduplication. Enhanced equipment and consumable item parsers to better classify item types and extract additional stats. Improved NPC parser to handle new prefab formats and more robust quest file discovery. Also updated version comparison logic to support both old and new version formats. Bumped package version to 2.0.0.
1 parent b21cadd commit 79a19c8

File tree

8 files changed

+240
-179
lines changed

8 files changed

+240
-179
lines changed

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "atlyss-kb",
33
"productName": "atlyss-kb",
4-
"version": "1.1.0",
4+
"version": "2.0.0",
55
"description": "A knowledge base for the game ATLYSS",
66
"main": ".webpack/main",
77
"scripts": {

src/compareVersions.js

Lines changed: 54 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,70 @@
11
export default function(version1, version2) {
2-
// Parse version strings into components
3-
const parseVersion = (version) => {
2+
// Helper to detect format
3+
const isOldFormat = (v) => /^(Alpha|Beta)?\s?\d+\.\d+\.\d+[a-z]?$/i.test(v);
4+
const isNewFormat = (v) => /^\d+\.[a-z]\d+$/i.test(v);
5+
6+
// Parse old format: Beta 1.6.2b
7+
const parseOld = (version) => {
48
const regex = /^(Alpha|Beta)?\s?(\d+)\.(\d+)\.(\d+)([a-z]?)$/i;
59
const match = version.match(regex);
6-
7-
if (!match) throw new Error(`Invalid version format: ${version}`);
8-
10+
if (!match) throw new Error(`Invalid old version format: ${version}`);
911
const [, preRelease, major, minor, patch, suffix] = match;
1012
return {
11-
preRelease: preRelease ? preRelease.toLowerCase() : "", // e.g., "alpha", "beta"
13+
type: 'old',
14+
preRelease: preRelease ? preRelease.toLowerCase() : '',
1215
major: parseInt(major, 10),
1316
minor: parseInt(minor, 10),
1417
patch: parseInt(patch, 10),
15-
suffix: suffix ? suffix.charCodeAt(0) : 0 // Convert suffix to ASCII value for comparison
18+
suffix: suffix ? suffix.charCodeAt(0) : 0
19+
};
20+
};
21+
22+
// Parse new format: 72025.a3
23+
const parseNew = (version) => {
24+
const regex = /^(\d+)\.([a-z])(\d+)$/i;
25+
const match = version.match(regex);
26+
if (!match) throw new Error(`Invalid new version format: ${version}`);
27+
const [, build, letter, num] = match;
28+
return {
29+
type: 'new',
30+
build: parseInt(build, 10),
31+
letter: letter.toLowerCase().charCodeAt(0),
32+
num: parseInt(num, 10)
1633
};
1734
};
1835

36+
// Unified parse
37+
const parseVersion = (v) => {
38+
if (isOldFormat(v)) return parseOld(v);
39+
if (isNewFormat(v)) return parseNew(v);
40+
throw new Error(`Unknown version format: ${v}`);
41+
};
42+
1943
const v1 = parseVersion(version1);
2044
const v2 = parseVersion(version2);
2145

2246
// Comparison logic
23-
const compare = (a, b) => (a > b) - (a < b); // Simplified comparison function
47+
const compare = (a, b) => (a > b) - (a < b);
2448

25-
const preReleaseOrder = { alpha: 1, beta: 2, "": 3 }; // Define order for pre-release identifiers
26-
return (
27-
compare(preReleaseOrder[v1.preRelease], preReleaseOrder[v2.preRelease]) ||
28-
compare(v1.major, v2.major) ||
29-
compare(v1.minor, v2.minor) ||
30-
compare(v1.patch, v2.patch) ||
31-
compare(v1.suffix, v2.suffix)
32-
);
33-
};
49+
// If both are old format
50+
if (v1.type === 'old' && v2.type === 'old') {
51+
const preReleaseOrder = { alpha: 1, beta: 2, '': 3 };
52+
return (
53+
compare(preReleaseOrder[v1.preRelease], preReleaseOrder[v2.preRelease]) ||
54+
compare(v1.major, v2.major) ||
55+
compare(v1.minor, v2.minor) ||
56+
compare(v1.patch, v2.patch) ||
57+
compare(v1.suffix, v2.suffix)
58+
);
59+
}
60+
// If both are new format
61+
if (v1.type === 'new' && v2.type === 'new') {
62+
return (
63+
compare(v1.build, v2.build) ||
64+
compare(v1.letter, v2.letter) ||
65+
compare(v1.num, v2.num)
66+
);
67+
}
68+
// If mixed, treat new format as always newer than old format
69+
return v1.type === 'new' ? 1 : -1;
70+
}

0 commit comments

Comments
 (0)