@rpg-engine/long-bow 0.6.49 → 0.6.50
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 +15 -31
- 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 +15 -31
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/SkillProgressBar.tsx +21 -31
- package/src/mocks/skills.mocks.ts +9 -5
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getSPForLevel } from '@rpg-engine/shared';
|
|
2
|
-
import React
|
|
2
|
+
import React from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
import { uiColors } from '../constants/uiColors';
|
|
5
5
|
import { ErrorBoundary } from './Item/Inventory/ErrorBoundary';
|
|
@@ -22,46 +22,36 @@ export interface ISkillProgressBarProps {
|
|
|
22
22
|
export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
|
|
23
23
|
bgColor,
|
|
24
24
|
skillName,
|
|
25
|
-
level
|
|
26
|
-
skillPoints
|
|
27
|
-
skillPointsToNextLevel
|
|
25
|
+
level,
|
|
26
|
+
skillPoints,
|
|
27
|
+
skillPointsToNextLevel,
|
|
28
28
|
texturePath,
|
|
29
29
|
showSkillPoints = true,
|
|
30
30
|
atlasIMG,
|
|
31
31
|
atlasJSON,
|
|
32
32
|
buffAndDebuff,
|
|
33
33
|
}) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
initialSkillPointsToNextLevel || getSPForLevel(initialLevel + 1)
|
|
38
|
-
);
|
|
34
|
+
if (!skillPointsToNextLevel) {
|
|
35
|
+
skillPointsToNextLevel = getSPForLevel(level + 1);
|
|
36
|
+
}
|
|
39
37
|
|
|
40
|
-
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
setLevel(initialLevel);
|
|
43
|
-
setSkillPoints(initialSkillPoints);
|
|
44
|
-
setSkillPointsToNextLevel(
|
|
45
|
-
initialSkillPointsToNextLevel || getSPForLevel(initialLevel + 1)
|
|
46
|
-
);
|
|
47
|
-
}, [initialLevel, initialSkillPoints, initialSkillPointsToNextLevel]);
|
|
48
|
-
|
|
49
|
-
useEffect(() => {
|
|
50
|
-
if (skillPoints >= skillPointsToNextLevel) {
|
|
51
|
-
const excessSkillPoints = skillPoints - skillPointsToNextLevel;
|
|
52
|
-
const newLevel = level + 1;
|
|
53
|
-
setLevel(newLevel);
|
|
54
|
-
setSkillPoints(excessSkillPoints);
|
|
55
|
-
setSkillPointsToNextLevel(getSPForLevel(newLevel + 1));
|
|
56
|
-
}
|
|
57
|
-
}, [skillPoints, skillPointsToNextLevel, level]);
|
|
38
|
+
const baseSkillPoints = getSPForLevel(level);
|
|
58
39
|
|
|
59
|
-
|
|
60
|
-
|
|
40
|
+
const excessSkillPoints = skillPoints - baseSkillPoints;
|
|
41
|
+
|
|
42
|
+
const ratio = Math.min(
|
|
43
|
+
(excessSkillPoints / skillPointsToNextLevel) * 100,
|
|
44
|
+
100
|
|
45
|
+
);
|
|
61
46
|
|
|
62
47
|
const skillsBuffsCalc = (level: number, buffAndDebuff: number): string => {
|
|
63
48
|
const result = level * (buffAndDebuff / 100);
|
|
64
|
-
|
|
49
|
+
|
|
50
|
+
if (result > 0) {
|
|
51
|
+
return `+${result.toFixed(2)}`;
|
|
52
|
+
} else {
|
|
53
|
+
return `${result.toFixed(2)}`;
|
|
54
|
+
}
|
|
65
55
|
};
|
|
66
56
|
|
|
67
57
|
return (
|
|
@@ -133,7 +123,7 @@ export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
|
|
|
133
123
|
{showSkillPoints && (
|
|
134
124
|
<SkillDisplayContainer>
|
|
135
125
|
<SkillPointsDisplay>
|
|
136
|
-
{
|
|
126
|
+
{ratio.toFixed(2)}% ({skillPoints} SP)
|
|
137
127
|
</SkillPointsDisplay>
|
|
138
128
|
</SkillDisplayContainer>
|
|
139
129
|
)}
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import { ISkill, SkillType, getSPForLevel } from '@rpg-engine/shared';
|
|
2
2
|
|
|
3
|
+
for (let level = 2; level <= 10; level++) {
|
|
4
|
+
console.log(`SP for level ${level}: ${getSPForLevel(level)}`);
|
|
5
|
+
}
|
|
6
|
+
|
|
3
7
|
export const skillMock = {
|
|
4
8
|
_id: '62aebda8785a9f0089a4f757',
|
|
5
9
|
stamina: {
|
|
6
10
|
type: SkillType.BasicAttributes,
|
|
7
|
-
level:
|
|
8
|
-
skillPoints:
|
|
11
|
+
level: 1,
|
|
12
|
+
skillPoints: 5,
|
|
9
13
|
skillPointsToNextLevel: getSPForLevel(2),
|
|
10
14
|
},
|
|
11
15
|
magic: {
|
|
12
16
|
type: SkillType.BasicAttributes,
|
|
13
|
-
level:
|
|
14
|
-
skillPoints:
|
|
15
|
-
skillPointsToNextLevel: getSPForLevel(2
|
|
17
|
+
level: 1,
|
|
18
|
+
skillPoints: 12,
|
|
19
|
+
skillPointsToNextLevel: getSPForLevel(2),
|
|
16
20
|
buffAndDebuff: -10,
|
|
17
21
|
},
|
|
18
22
|
magicResistance: {
|