@rpg-engine/long-bow 0.6.48 → 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 -25
- 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 -25
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/SkillProgressBar.tsx +21 -22
- 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,37 +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
|
-
if (skillPoints >= skillPointsToNextLevel) {
|
|
42
|
-
const excessSkillPoints = skillPoints - skillPointsToNextLevel;
|
|
43
|
-
const newLevel = level + 1;
|
|
44
|
-
setLevel(newLevel);
|
|
45
|
-
setSkillPoints(excessSkillPoints);
|
|
46
|
-
setSkillPointsToNextLevel(getSPForLevel(newLevel + 1));
|
|
47
|
-
}
|
|
48
|
-
}, [skillPoints, skillPointsToNextLevel, level]);
|
|
38
|
+
const baseSkillPoints = getSPForLevel(level);
|
|
49
39
|
|
|
50
|
-
|
|
51
|
-
|
|
40
|
+
const excessSkillPoints = skillPoints - baseSkillPoints;
|
|
41
|
+
|
|
42
|
+
const ratio = Math.min(
|
|
43
|
+
(excessSkillPoints / skillPointsToNextLevel) * 100,
|
|
44
|
+
100
|
|
45
|
+
);
|
|
52
46
|
|
|
53
47
|
const skillsBuffsCalc = (level: number, buffAndDebuff: number): string => {
|
|
54
48
|
const result = level * (buffAndDebuff / 100);
|
|
55
|
-
|
|
49
|
+
|
|
50
|
+
if (result > 0) {
|
|
51
|
+
return `+${result.toFixed(2)}`;
|
|
52
|
+
} else {
|
|
53
|
+
return `${result.toFixed(2)}`;
|
|
54
|
+
}
|
|
56
55
|
};
|
|
57
56
|
|
|
58
57
|
return (
|
|
@@ -124,7 +123,7 @@ export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
|
|
|
124
123
|
{showSkillPoints && (
|
|
125
124
|
<SkillDisplayContainer>
|
|
126
125
|
<SkillPointsDisplay>
|
|
127
|
-
{
|
|
126
|
+
{ratio.toFixed(2)}% ({skillPoints} SP)
|
|
128
127
|
</SkillPointsDisplay>
|
|
129
128
|
</SkillDisplayContainer>
|
|
130
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: {
|