@rpg-engine/long-bow 0.8.81 → 0.8.82
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/components/SkillProgressBar.d.ts +3 -1
- package/dist/components/SkillsContainer.d.ts +2 -2
- package/dist/long-bow.cjs.development.js +55 -36
- 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 +56 -37
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/components/SkillProgressBar.tsx +20 -5
- package/src/components/SkillsContainer.tsx +14 -13
- package/src/mocks/skills.mocks.ts +21 -9
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.82",
|
|
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.32",
|
|
87
|
+
"@rpg-engine/shared": "^0.10.32",
|
|
88
88
|
"dayjs": "^1.11.2",
|
|
89
89
|
"font-awesome": "^4.7.0",
|
|
90
90
|
"fs-extra": "^10.1.0",
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
getSPForLevel,
|
|
3
|
+
getSPForLevelExponential,
|
|
4
|
+
getSkillConstants,
|
|
5
|
+
CharacterClass,
|
|
6
|
+
} from '@rpg-engine/shared';
|
|
7
|
+
import React, { useMemo } from 'react';
|
|
2
8
|
import styled from 'styled-components';
|
|
3
9
|
import { uiColors } from '../constants/uiColors';
|
|
4
10
|
import { ErrorBoundary } from './Item/Inventory/ErrorBoundary';
|
|
@@ -8,13 +14,14 @@ import { Tooltip } from './Tooltip/Tooltip';
|
|
|
8
14
|
|
|
9
15
|
export interface ISkillProgressBarProps {
|
|
10
16
|
skillName: string;
|
|
17
|
+
skillKey?: string;
|
|
18
|
+
characterClass?: CharacterClass;
|
|
11
19
|
bgColor: string;
|
|
12
20
|
level: number;
|
|
13
21
|
skillPoints: number;
|
|
14
22
|
texturePath: string;
|
|
15
23
|
showSkillPoints?: boolean;
|
|
16
24
|
skillPointsToNextLevel: number;
|
|
17
|
-
skillPointsForCurrentLevel: number;
|
|
18
25
|
atlasJSON: any;
|
|
19
26
|
atlasIMG: any;
|
|
20
27
|
buffAndDebuff?: number;
|
|
@@ -23,10 +30,11 @@ export interface ISkillProgressBarProps {
|
|
|
23
30
|
export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
|
|
24
31
|
bgColor,
|
|
25
32
|
skillName,
|
|
33
|
+
skillKey,
|
|
34
|
+
characterClass,
|
|
26
35
|
level,
|
|
27
36
|
skillPoints: currentSkillPoints,
|
|
28
37
|
skillPointsToNextLevel,
|
|
29
|
-
skillPointsForCurrentLevel,
|
|
30
38
|
texturePath,
|
|
31
39
|
showSkillPoints = true,
|
|
32
40
|
atlasIMG,
|
|
@@ -34,8 +42,15 @@ export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
|
|
|
34
42
|
|
|
35
43
|
buffAndDebuff,
|
|
36
44
|
}) => {
|
|
37
|
-
// Skill points needed to start the current level
|
|
38
|
-
const baseSkillPoints =
|
|
45
|
+
// Skill points needed to start the current level
|
|
46
|
+
const baseSkillPoints = useMemo(() => {
|
|
47
|
+
if (skillKey && characterClass) {
|
|
48
|
+
const { A, b, c } = getSkillConstants(skillKey, characterClass);
|
|
49
|
+
return getSPForLevelExponential(level, A, b, c);
|
|
50
|
+
}
|
|
51
|
+
// Fallback to old formula for backwards compatibility
|
|
52
|
+
return getSPForLevel(level);
|
|
53
|
+
}, [level, skillKey, characterClass]);
|
|
39
54
|
const calculateProgress = (): number => {
|
|
40
55
|
const totalPointsForLevelUp = Math.max(
|
|
41
56
|
1,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
CharacterClass,
|
|
3
2
|
ISkill,
|
|
4
3
|
ISkillDetails,
|
|
4
|
+
getSPForLevel,
|
|
5
5
|
getSPForLevelExponential,
|
|
6
6
|
getSkillConstants,
|
|
7
|
+
CharacterClass,
|
|
7
8
|
getXPForLevel,
|
|
8
9
|
} from '@rpg-engine/shared';
|
|
9
10
|
import React from 'react';
|
|
@@ -14,7 +15,7 @@ import { SkillProgressBar } from './SkillProgressBar';
|
|
|
14
15
|
|
|
15
16
|
export interface ISkillContainerProps {
|
|
16
17
|
skill: ISkill;
|
|
17
|
-
characterClass
|
|
18
|
+
characterClass?: CharacterClass;
|
|
18
19
|
onCloseButton: () => void;
|
|
19
20
|
atlasJSON: any;
|
|
20
21
|
atlasIMG: any;
|
|
@@ -114,22 +115,25 @@ export const SkillsContainer: React.FC<ISkillContainerProps> = ({
|
|
|
114
115
|
continue;
|
|
115
116
|
}
|
|
116
117
|
|
|
117
|
-
//
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
118
|
+
// Calculate skillPointsToNextLevel using exponential formula if characterClass available
|
|
119
|
+
const calcSkillPointsToNextLevel = (): number => {
|
|
120
|
+
if (characterClass) {
|
|
121
|
+
const { A, b, c } = getSkillConstants(key, characterClass);
|
|
122
|
+
return Math.round(getSPForLevelExponential(skillDetails.level + 1, A, b, c));
|
|
123
|
+
}
|
|
124
|
+
return Math.round(getSPForLevel(skillDetails.level + 1));
|
|
125
|
+
};
|
|
123
126
|
|
|
124
127
|
output.push(
|
|
125
128
|
<SkillProgressBar
|
|
126
129
|
key={key}
|
|
127
130
|
skillName={skillNameMap[key]}
|
|
131
|
+
skillKey={key}
|
|
132
|
+
characterClass={characterClass}
|
|
128
133
|
bgColor={skillCategoryColor}
|
|
129
134
|
level={skillDetails.level || 0}
|
|
130
135
|
skillPoints={Math.round(skillDetails.skillPoints) || 0}
|
|
131
|
-
skillPointsToNextLevel={
|
|
132
|
-
skillPointsForCurrentLevel={skillPointsForCurrentLevel}
|
|
136
|
+
skillPointsToNextLevel={calcSkillPointsToNextLevel()}
|
|
133
137
|
texturePath={value}
|
|
134
138
|
atlasIMG={atlasIMG}
|
|
135
139
|
atlasJSON={atlasJSON}
|
|
@@ -164,9 +168,6 @@ export const SkillsContainer: React.FC<ISkillContainerProps> = ({
|
|
|
164
168
|
skillPointsToNextLevel={
|
|
165
169
|
Math.round(getXPForLevel(skill.level + 1)) || 0
|
|
166
170
|
}
|
|
167
|
-
skillPointsForCurrentLevel={
|
|
168
|
-
Math.round(getXPForLevel(skill.level)) || 0
|
|
169
|
-
}
|
|
170
171
|
texturePath={'swords/broad-sword.png'}
|
|
171
172
|
atlasIMG={atlasIMG}
|
|
172
173
|
atlasJSON={atlasJSON}
|
|
@@ -2,16 +2,28 @@ import {
|
|
|
2
2
|
ISkill,
|
|
3
3
|
SkillType,
|
|
4
4
|
getSPForLevel,
|
|
5
|
+
getSPForLevelExponential,
|
|
6
|
+
getSkillConstants,
|
|
7
|
+
CharacterClass,
|
|
5
8
|
getXPForLevel,
|
|
6
9
|
} from '@rpg-engine/shared';
|
|
7
10
|
|
|
11
|
+
// Use Warrior as default character class for mock data
|
|
12
|
+
const mockCharacterClass = CharacterClass.Warrior;
|
|
13
|
+
|
|
14
|
+
// Helper function to get SP for next level using exponential formula
|
|
15
|
+
const getMockSPForNextLevel = (skillKey: string, level: number): number => {
|
|
16
|
+
const { A, b, c } = getSkillConstants(skillKey, mockCharacterClass);
|
|
17
|
+
return Math.round(getSPForLevelExponential(level, A, b, c));
|
|
18
|
+
};
|
|
19
|
+
|
|
8
20
|
export const skillMock = {
|
|
9
21
|
_id: '62aebda8785a9f0089a4f757',
|
|
10
22
|
stamina: {
|
|
11
23
|
type: SkillType.BasicAttributes,
|
|
12
24
|
level: 1,
|
|
13
25
|
skillPoints: 10,
|
|
14
|
-
skillPointsToNextLevel:
|
|
26
|
+
skillPointsToNextLevel: getMockSPForNextLevel('stamina', 2),
|
|
15
27
|
},
|
|
16
28
|
magic: {
|
|
17
29
|
type: SkillType.BasicAttributes,
|
|
@@ -43,49 +55,49 @@ export const skillMock = {
|
|
|
43
55
|
type: SkillType.BasicAttributes,
|
|
44
56
|
level: 2,
|
|
45
57
|
skillPoints: 70,
|
|
46
|
-
skillPointsToNextLevel:
|
|
58
|
+
skillPointsToNextLevel: getMockSPForNextLevel('dexterity', 3),
|
|
47
59
|
},
|
|
48
60
|
first: {
|
|
49
61
|
type: SkillType.Combat,
|
|
50
62
|
level: 1,
|
|
51
63
|
skillPoints: 22,
|
|
52
|
-
skillPointsToNextLevel:
|
|
64
|
+
skillPointsToNextLevel: getMockSPForNextLevel('first', 2),
|
|
53
65
|
},
|
|
54
66
|
club: {
|
|
55
67
|
type: SkillType.Combat,
|
|
56
68
|
level: 2,
|
|
57
69
|
skillPoints: 22,
|
|
58
|
-
skillPointsToNextLevel:
|
|
70
|
+
skillPointsToNextLevel: getMockSPForNextLevel('club', 3),
|
|
59
71
|
},
|
|
60
72
|
sword: {
|
|
61
73
|
type: SkillType.Combat,
|
|
62
74
|
level: 4,
|
|
63
75
|
skillPoints: 273,
|
|
64
|
-
skillPointsToNextLevel:
|
|
76
|
+
skillPointsToNextLevel: getMockSPForNextLevel('sword', 5),
|
|
65
77
|
},
|
|
66
78
|
dagger: {
|
|
67
79
|
type: SkillType.Combat,
|
|
68
80
|
level: 4,
|
|
69
81
|
skillPoints: 300,
|
|
70
|
-
skillPointsToNextLevel:
|
|
82
|
+
skillPointsToNextLevel: getMockSPForNextLevel('dagger', 5),
|
|
71
83
|
},
|
|
72
84
|
axe: {
|
|
73
85
|
type: SkillType.Combat,
|
|
74
86
|
level: 5,
|
|
75
87
|
skillPoints: 400,
|
|
76
|
-
skillPointsToNextLevel:
|
|
88
|
+
skillPointsToNextLevel: getMockSPForNextLevel('axe', 6),
|
|
77
89
|
},
|
|
78
90
|
distance: {
|
|
79
91
|
type: SkillType.Combat,
|
|
80
92
|
level: 4,
|
|
81
93
|
skillPoints: 76,
|
|
82
|
-
skillPointsToNextLevel:
|
|
94
|
+
skillPointsToNextLevel: getMockSPForNextLevel('distance', 5),
|
|
83
95
|
},
|
|
84
96
|
shielding: {
|
|
85
97
|
type: SkillType.Combat,
|
|
86
98
|
level: 3,
|
|
87
99
|
skillPoints: 120,
|
|
88
|
-
skillPointsToNextLevel:
|
|
100
|
+
skillPointsToNextLevel: getMockSPForNextLevel('shielding', 4),
|
|
89
101
|
},
|
|
90
102
|
fishing: {
|
|
91
103
|
type: SkillType.Gathering,
|