@rpg-engine/long-bow 0.6.50 → 0.6.51

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpg-engine/long-bow",
3
- "version": "0.6.50",
3
+ "version": "0.6.51",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -23,26 +23,36 @@ export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
23
23
  bgColor,
24
24
  skillName,
25
25
  level,
26
- skillPoints,
27
- skillPointsToNextLevel,
26
+ skillPoints: currentSkillPoints,
27
+
28
28
  texturePath,
29
29
  showSkillPoints = true,
30
30
  atlasIMG,
31
31
  atlasJSON,
32
32
  buffAndDebuff,
33
33
  }) => {
34
- if (!skillPointsToNextLevel) {
35
- skillPointsToNextLevel = getSPForLevel(level + 1);
36
- }
37
-
38
- const baseSkillPoints = getSPForLevel(level);
39
-
40
- const excessSkillPoints = skillPoints - baseSkillPoints;
41
-
42
- const ratio = Math.min(
43
- (excessSkillPoints / skillPointsToNextLevel) * 100,
44
- 100
45
- );
34
+ // Base skill points for the previous level (0 for level 1)
35
+ const baseSkillPointsPrevLevel = level > 1 ? getSPForLevel(level - 1) : 0;
36
+
37
+ // Total skill points needed for the next level
38
+ const nextLevelSkillPoints = getSPForLevel(level + 1);
39
+
40
+ // Calculate excess skill points above the previous level
41
+ const excessSkillPoints = currentSkillPoints - baseSkillPointsPrevLevel;
42
+
43
+ // Calculate progress percentage towards the next level
44
+ const progress =
45
+ nextLevelSkillPoints > baseSkillPointsPrevLevel
46
+ ? Math.max(
47
+ Math.min(
48
+ (excessSkillPoints /
49
+ (nextLevelSkillPoints - baseSkillPointsPrevLevel)) *
50
+ 100,
51
+ 100
52
+ ),
53
+ 0
54
+ )
55
+ : 0;
46
56
 
47
57
  const skillsBuffsCalc = (level: number, buffAndDebuff: number): string => {
48
58
  const result = level * (buffAndDebuff / 100);
@@ -117,14 +127,12 @@ export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
117
127
  </ProgressIconContainer>
118
128
 
119
129
  <ProgressBarContainer>
120
- <SimpleProgressBar value={ratio} bgColor={bgColor} />
130
+ <SimpleProgressBar value={progress} bgColor={bgColor} />
121
131
  </ProgressBarContainer>
122
132
  </ProgressBody>
123
133
  {showSkillPoints && (
124
134
  <SkillDisplayContainer>
125
- <SkillPointsDisplay>
126
- {ratio.toFixed(2)}% ({skillPoints} SP)
127
- </SkillPointsDisplay>
135
+ <SkillPointsDisplay>{progress.toFixed(2)}%</SkillPointsDisplay>
128
136
  </SkillDisplayContainer>
129
137
  )}
130
138
  </>