@rpg-engine/long-bow 0.6.47 → 0.6.49

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.47",
3
+ "version": "0.6.49",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -34,9 +34,18 @@ export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
34
34
  const [level, setLevel] = useState(initialLevel);
35
35
  const [skillPoints, setSkillPoints] = useState(initialSkillPoints);
36
36
  const [skillPointsToNextLevel, setSkillPointsToNextLevel] = useState(
37
- initialSkillPointsToNextLevel ?? getSPForLevel(initialLevel + 1)
37
+ initialSkillPointsToNextLevel || getSPForLevel(initialLevel + 1)
38
38
  );
39
39
 
40
+ // Update skill points and level from props when they change
41
+ useEffect(() => {
42
+ setLevel(initialLevel);
43
+ setSkillPoints(initialSkillPoints);
44
+ setSkillPointsToNextLevel(
45
+ initialSkillPointsToNextLevel || getSPForLevel(initialLevel + 1)
46
+ );
47
+ }, [initialLevel, initialSkillPoints, initialSkillPointsToNextLevel]);
48
+
40
49
  useEffect(() => {
41
50
  if (skillPoints >= skillPointsToNextLevel) {
42
51
  const excessSkillPoints = skillPoints - skillPointsToNextLevel;
@@ -47,13 +56,12 @@ export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
47
56
  }
48
57
  }, [skillPoints, skillPointsToNextLevel, level]);
49
58
 
50
- // Calculate the ratio for progress bar, ensuring it doesn't exceed 100%
59
+ // Calculate the ratio, ensuring it doesn't exceed 100%
51
60
  const ratio = Math.min((skillPoints / skillPointsToNextLevel) * 100, 100);
52
61
 
53
62
  const skillsBuffsCalc = (level: number, buffAndDebuff: number): string => {
54
63
  const result = level * (buffAndDebuff / 100);
55
-
56
- return result > 0 ? `+${result.toFixed(2)}` : `${result.toFixed(2)}`;
64
+ return result > 0 ? `+${result}` : `${result}`;
57
65
  };
58
66
 
59
67
  return (
@@ -124,7 +132,9 @@ export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
124
132
  </ProgressBody>
125
133
  {showSkillPoints && (
126
134
  <SkillDisplayContainer>
127
- <SkillPointsDisplay>{ratio.toFixed(2)}%</SkillPointsDisplay>
135
+ <SkillPointsDisplay>
136
+ {skillPoints} / {skillPointsToNextLevel} ({ratio.toFixed(2)}%)
137
+ </SkillPointsDisplay>
128
138
  </SkillDisplayContainer>
129
139
  )}
130
140
  </>
@@ -153,7 +163,7 @@ const SkillDisplayContainer = styled.div`
153
163
  `;
154
164
 
155
165
  const SkillPointsDisplay = styled.p`
156
- font-size: 0.6rem !important;
166
+ font-size: 0.55rem !important;
157
167
  font-weight: bold;
158
168
  text-align: center;
159
169
  `;