@rpg-engine/long-bow 0.8.94 → 0.8.95
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/dist/long-bow.cjs.development.js +17 -8
- package/dist/long-bow.cjs.development.js.map +1 -1
- package/dist/long-bow.cjs.production.min.js +1 -1
- package/dist/long-bow.cjs.production.min.js.map +1 -1
- package/dist/long-bow.esm.js +18 -9
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/components/SkillProgressBar.tsx +23 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpg-engine/long-bow",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.95",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"dependencies": {
|
|
85
85
|
"@capacitor/core": "^6.1.0",
|
|
86
86
|
"@rollup/plugin-image": "^2.1.1",
|
|
87
|
-
"@rpg-engine/shared": "^0.10.
|
|
87
|
+
"@rpg-engine/shared": "^0.10.42",
|
|
88
88
|
"dayjs": "^1.11.2",
|
|
89
89
|
"font-awesome": "^4.7.0",
|
|
90
90
|
"fs-extra": "^10.1.0",
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CharacterClass,
|
|
3
3
|
getLevelFromSP,
|
|
4
|
+
getLevelFromXP,
|
|
4
5
|
getSPForLevelExponential,
|
|
5
6
|
getSkillConstants,
|
|
7
|
+
getXPForLevel,
|
|
6
8
|
} from '@rpg-engine/shared';
|
|
7
9
|
import React from 'react';
|
|
8
10
|
import styled from 'styled-components';
|
|
@@ -32,7 +34,7 @@ export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
|
|
|
32
34
|
skillName,
|
|
33
35
|
skillKey,
|
|
34
36
|
characterClass,
|
|
35
|
-
level,
|
|
37
|
+
// level prop kept in interface for API compatibility, but calculated from skillPoints
|
|
36
38
|
skillPoints: currentSkillPoints,
|
|
37
39
|
|
|
38
40
|
texturePath,
|
|
@@ -45,12 +47,14 @@ export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
|
|
|
45
47
|
// Use CharacterClass.None as default if skillKey is provided but characterClass is not
|
|
46
48
|
const effectiveClass = characterClass ?? CharacterClass.None;
|
|
47
49
|
|
|
48
|
-
// Calculate the effective level based on actual SP (handles data inconsistencies)
|
|
50
|
+
// Calculate the effective level based on actual SP/XP (handles data inconsistencies)
|
|
49
51
|
const calculateEffectiveLevel = (): number => {
|
|
50
52
|
if (!skillKey) {
|
|
51
|
-
|
|
53
|
+
// Character level: uses cubic formula (level³ * 3)
|
|
54
|
+
return Math.max(1, getLevelFromXP(currentSkillPoints));
|
|
52
55
|
}
|
|
53
56
|
|
|
57
|
+
// Skills: use exponential formula with class-based constants
|
|
54
58
|
const { A, b, c } = getSkillConstants(skillKey, effectiveClass);
|
|
55
59
|
const actualLevel = Math.floor(getLevelFromSP(currentSkillPoints, A, b, c));
|
|
56
60
|
return Math.max(1, actualLevel); // Minimum level is always 1 in our system
|
|
@@ -58,12 +62,23 @@ export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
|
|
|
58
62
|
|
|
59
63
|
const effectiveLevel = calculateEffectiveLevel();
|
|
60
64
|
|
|
61
|
-
// Calculate progress based on actual SP position
|
|
65
|
+
// Calculate progress based on actual SP/XP position
|
|
62
66
|
const calculateProgress = (): number => {
|
|
63
|
-
//
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
// Character level uses cubic XP formula, skills use exponential SP formula
|
|
68
|
+
if (!skillKey) {
|
|
69
|
+
// Character level: uses cubic formula (level³ * 3)
|
|
70
|
+
const actualLevel = Math.max(1, getLevelFromXP(currentSkillPoints));
|
|
71
|
+
const currentLevelXP = getXPForLevel(actualLevel);
|
|
72
|
+
const nextLevelXP = getXPForLevel(actualLevel + 1);
|
|
73
|
+
|
|
74
|
+
const range = nextLevelXP - currentLevelXP;
|
|
75
|
+
const progressInLevel = currentSkillPoints - currentLevelXP;
|
|
76
|
+
|
|
77
|
+
return Math.min(99.99, Math.max(0, (progressInLevel / Math.max(1, range)) * 100));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Skills: use exponential formula with class-based constants
|
|
81
|
+
const { A, b, c } = getSkillConstants(skillKey, effectiveClass);
|
|
67
82
|
|
|
68
83
|
// Get the actual calculated level (might be 0 for magic)
|
|
69
84
|
const actualLevel = Math.floor(getLevelFromSP(currentSkillPoints, A, b, c));
|