@rpg-engine/long-bow 0.8.82 → 0.8.84
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 +38 -16
- 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 +39 -17
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/components/SkillProgressBar.tsx +47 -24
- package/src/mocks/skills.mocks.ts +0 -1
- package/src/stories/Character/skills/SkillsContainer.stories.tsx +3 -0
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.84",
|
|
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.33",
|
|
88
88
|
"dayjs": "^1.11.2",
|
|
89
89
|
"font-awesome": "^4.7.0",
|
|
90
90
|
"fs-extra": "^10.1.0",
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CharacterClass,
|
|
3
|
+
getLevelFromSP,
|
|
2
4
|
getSPForLevel,
|
|
3
5
|
getSPForLevelExponential,
|
|
4
6
|
getSkillConstants,
|
|
5
|
-
CharacterClass,
|
|
6
7
|
} from '@rpg-engine/shared';
|
|
7
|
-
import React
|
|
8
|
+
import React from 'react';
|
|
8
9
|
import styled from 'styled-components';
|
|
9
10
|
import { uiColors } from '../constants/uiColors';
|
|
10
11
|
import { ErrorBoundary } from './Item/Inventory/ErrorBoundary';
|
|
@@ -34,7 +35,7 @@ export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
|
|
|
34
35
|
characterClass,
|
|
35
36
|
level,
|
|
36
37
|
skillPoints: currentSkillPoints,
|
|
37
|
-
|
|
38
|
+
|
|
38
39
|
texturePath,
|
|
39
40
|
showSkillPoints = true,
|
|
40
41
|
atlasIMG,
|
|
@@ -42,26 +43,48 @@ export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
|
|
|
42
43
|
|
|
43
44
|
buffAndDebuff,
|
|
44
45
|
}) => {
|
|
45
|
-
//
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
// Use CharacterClass.None as default if skillKey is provided but characterClass is not
|
|
47
|
+
const effectiveClass = characterClass ?? CharacterClass.None;
|
|
48
|
+
|
|
49
|
+
// Calculate the effective level based on actual SP (handles data inconsistencies)
|
|
50
|
+
const calculateEffectiveLevel = (): number => {
|
|
51
|
+
if (!skillKey) {
|
|
52
|
+
return level; // Fallback to stored level for general "Level" display
|
|
50
53
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
|
|
55
|
+
const { A, b, c } = getSkillConstants(skillKey, effectiveClass);
|
|
56
|
+
const actualLevel = Math.floor(getLevelFromSP(currentSkillPoints, A, b, c));
|
|
57
|
+
return Math.max(1, actualLevel); // Minimum level is always 1 in our system
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const effectiveLevel = calculateEffectiveLevel();
|
|
61
|
+
|
|
62
|
+
// Calculate progress based on actual SP position
|
|
54
63
|
const calculateProgress = (): number => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
);
|
|
64
|
+
if (!skillKey) {
|
|
65
|
+
// Fallback for general "Level" display: simple ratio of current SP to next level
|
|
66
|
+
const spForCurrentLevel = getSPForLevel(level);
|
|
67
|
+
const spForNextLevel = getSPForLevel(level + 1);
|
|
68
|
+
const range = spForNextLevel - spForCurrentLevel;
|
|
69
|
+
const progress = currentSkillPoints - spForCurrentLevel;
|
|
70
|
+
return Math.min(100, Math.max(0, (progress / range) * 100));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const { A, b, c } = getSkillConstants(skillKey, effectiveClass);
|
|
74
|
+
|
|
75
|
+
// Get the actual calculated level (might be 0 for magic)
|
|
76
|
+
const actualLevel = Math.floor(getLevelFromSP(currentSkillPoints, A, b, c));
|
|
77
|
+
const calcLevel = Math.max(c, actualLevel); // Use c as minimum for calculation
|
|
78
|
+
|
|
79
|
+
// Calculate SP thresholds based on actual position
|
|
80
|
+
const spForCalcLevel = getSPForLevelExponential(calcLevel, A, b, c);
|
|
81
|
+
const spForNextLevel = getSPForLevelExponential(calcLevel + 1, A, b, c);
|
|
82
|
+
|
|
83
|
+
// Progress within current level range
|
|
84
|
+
const range = spForNextLevel - spForCalcLevel;
|
|
85
|
+
const progressInLevel = currentSkillPoints - spForCalcLevel;
|
|
86
|
+
|
|
87
|
+
return Math.min(100, Math.max(0, (progressInLevel / Math.max(1, range)) * 100));
|
|
65
88
|
};
|
|
66
89
|
|
|
67
90
|
const progress = calculateProgress();
|
|
@@ -85,7 +108,7 @@ export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
|
|
|
85
108
|
<TitleNameContainer>
|
|
86
109
|
<TitleNameBuff>{skillName}</TitleNameBuff>
|
|
87
110
|
<TitleNameBuff>
|
|
88
|
-
lv {
|
|
111
|
+
lv {effectiveLevel} ({skillsBuffsCalc(effectiveLevel, buffAndDebuff)})
|
|
89
112
|
</TitleNameBuff>
|
|
90
113
|
</TitleNameContainer>
|
|
91
114
|
<TitleNameBuffContainer>
|
|
@@ -99,7 +122,7 @@ export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
|
|
|
99
122
|
<TitleNameContainer>
|
|
100
123
|
<TitleNameDebuff>{skillName}</TitleNameDebuff>
|
|
101
124
|
<TitleNameDebuff>
|
|
102
|
-
lv {
|
|
125
|
+
lv {effectiveLevel} ({skillsBuffsCalc(effectiveLevel, buffAndDebuff)})
|
|
103
126
|
</TitleNameDebuff>
|
|
104
127
|
</TitleNameContainer>
|
|
105
128
|
<div>
|
|
@@ -116,7 +139,7 @@ export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
|
|
|
116
139
|
{!buffAndDebuff && (
|
|
117
140
|
<TitleNameContainer>
|
|
118
141
|
<TitleName>{skillName}</TitleName>
|
|
119
|
-
<ValueDisplay>lv {
|
|
142
|
+
<ValueDisplay>lv {effectiveLevel}</ValueDisplay>
|
|
120
143
|
</TitleNameContainer>
|
|
121
144
|
)}
|
|
122
145
|
</ProgressTitle>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CharacterClass } from '@rpg-engine/shared';
|
|
1
2
|
import { Meta, Story } from '@storybook/react';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import { RPGUIRoot } from '../../../components/RPGUI/RPGUIRoot';
|
|
@@ -21,6 +22,7 @@ const Template: Story<ISkillContainerProps> = args => (
|
|
|
21
22
|
<SkillsContainer
|
|
22
23
|
{...args}
|
|
23
24
|
skill={skillMock}
|
|
25
|
+
characterClass={CharacterClass.Warrior}
|
|
24
26
|
onCloseButton={() => console.log('close skill container')}
|
|
25
27
|
atlasIMG={atlasIMG}
|
|
26
28
|
atlasJSON={atlasJSON}
|
|
@@ -32,4 +34,5 @@ export const Default = Template.bind([]);
|
|
|
32
34
|
|
|
33
35
|
Default.args = {
|
|
34
36
|
skill: skillMock,
|
|
37
|
+
characterClass: CharacterClass.Warrior,
|
|
35
38
|
};
|