Fixed a bug where XP levels were being improperly loaded.
This commit is contained in:
+11
-5
@@ -117,12 +117,18 @@
|
|||||||
const response = await fetch('levels.csv');
|
const response = await fetch('levels.csv');
|
||||||
const text = await response.text();
|
const text = await response.text();
|
||||||
|
|
||||||
xpThresholds = text
|
const lines = text.trim().split('\n');
|
||||||
.trim()
|
|
||||||
.split('\n')
|
|
||||||
.map(line => parseInt(line.split(',')[1].replace(/,/g, ''), 10));
|
|
||||||
|
|
||||||
console.log("Loaded XP thresholds:", xpThresholds);
|
let cumulative = 0;
|
||||||
|
xpThresholds = lines.map((line, i) => {
|
||||||
|
const parts = line.split(',');
|
||||||
|
let xp = parseInt(parts[1].replace(/,/g, ''), 10);
|
||||||
|
if (i === 0) return 0; // Level 1 starts at 0 XP
|
||||||
|
cumulative += xp;
|
||||||
|
return cumulative;
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("Loaded cumulative XP thresholds:", xpThresholds);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
alert("Failed to load levels.csv. Please ensure it's in the same folder as index.html.");
|
alert("Failed to load levels.csv. Please ensure it's in the same folder as index.html.");
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|||||||
Reference in New Issue
Block a user