@rpg-engine/long-bow 0.6.55 → 0.6.56
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/Tooltip/Tooltip.d.ts +1 -0
- package/dist/long-bow.cjs.development.js +13 -11
- 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 +14 -12
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/SkillProgressBar.tsx +13 -10
- package/src/components/SkillsContainer.tsx +4 -7
- package/src/components/Tooltip/Tooltip.tsx +19 -0
- package/src/mocks/skills.mocks.ts +2 -2
package/package.json
CHANGED
|
@@ -3,8 +3,9 @@ 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';
|
|
6
|
-
import { SimpleProgressBar } from './SimpleProgressBar';
|
|
7
6
|
import { SpriteFromAtlas } from './shared/SpriteFromAtlas';
|
|
7
|
+
import { SimpleProgressBar } from './SimpleProgressBar';
|
|
8
|
+
import { Tooltip } from './Tooltip/Tooltip';
|
|
8
9
|
|
|
9
10
|
export interface ISkillProgressBarProps {
|
|
10
11
|
skillName: string;
|
|
@@ -32,10 +33,7 @@ export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
|
|
|
32
33
|
buffAndDebuff,
|
|
33
34
|
}) => {
|
|
34
35
|
// Base skill points for the previous level (0 for level 1)
|
|
35
|
-
const baseSkillPointsPrevLevel = level
|
|
36
|
-
|
|
37
|
-
// Total skill points needed for the next level
|
|
38
|
-
const nextLevelSkillPoints = skillPointsToNextLevel;
|
|
36
|
+
const baseSkillPointsPrevLevel = level === 1 ? 0 : getSPForLevel(level);
|
|
39
37
|
|
|
40
38
|
// Calculate excess skill points above the previous level
|
|
41
39
|
const excessSkillPoints = Math.max(
|
|
@@ -46,7 +44,7 @@ export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
|
|
|
46
44
|
// Calculate progress percentage towards the next level
|
|
47
45
|
const progress = Math.min(
|
|
48
46
|
100,
|
|
49
|
-
Math.max(0, (excessSkillPoints /
|
|
47
|
+
Math.max(0, (excessSkillPoints / skillPointsToNextLevel) * 100)
|
|
50
48
|
);
|
|
51
49
|
|
|
52
50
|
const skillsBuffsCalc = (level: number, buffAndDebuff: number): string => {
|
|
@@ -117,9 +115,10 @@ export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
|
|
|
117
115
|
)}
|
|
118
116
|
</ProgressIconContainer>
|
|
119
117
|
|
|
120
|
-
<
|
|
118
|
+
<ProgressBarWrapper>
|
|
121
119
|
<SimpleProgressBar value={progress} bgColor={bgColor} />
|
|
122
|
-
|
|
120
|
+
<Tooltip>SP: {currentSkillPoints}</Tooltip>
|
|
121
|
+
</ProgressBarWrapper>
|
|
123
122
|
</ProgressBody>
|
|
124
123
|
{showSkillPoints && (
|
|
125
124
|
<SkillDisplayContainer>
|
|
@@ -130,11 +129,15 @@ export const SkillProgressBar: React.FC<ISkillProgressBarProps> = ({
|
|
|
130
129
|
);
|
|
131
130
|
};
|
|
132
131
|
|
|
133
|
-
const
|
|
132
|
+
const ProgressBarWrapper = styled.div`
|
|
134
133
|
position: relative;
|
|
135
|
-
|
|
134
|
+
|
|
135
|
+
&:hover ${Tooltip}, &:active ${Tooltip} {
|
|
136
|
+
visibility: visible;
|
|
137
|
+
}
|
|
136
138
|
width: 100%;
|
|
137
139
|
height: auto;
|
|
140
|
+
top: 8px;
|
|
138
141
|
`;
|
|
139
142
|
|
|
140
143
|
const SpriteContainer = styled.div`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ISkill,
|
|
3
3
|
ISkillDetails,
|
|
4
|
-
|
|
4
|
+
getSPForLevel,
|
|
5
5
|
getXPForLevel,
|
|
6
6
|
} from '@rpg-engine/shared';
|
|
7
7
|
import React from 'react';
|
|
@@ -110,11 +110,6 @@ export const SkillsContainer: React.FC<ISkillContainerProps> = ({
|
|
|
110
110
|
continue;
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
const skillPointsToNextLevel = calculateSPToNextLevel(
|
|
114
|
-
skillDetails.skillPoints,
|
|
115
|
-
skillDetails.level
|
|
116
|
-
);
|
|
117
|
-
|
|
118
113
|
output.push(
|
|
119
114
|
<SkillProgressBar
|
|
120
115
|
key={key}
|
|
@@ -122,7 +117,9 @@ export const SkillsContainer: React.FC<ISkillContainerProps> = ({
|
|
|
122
117
|
bgColor={skillCategoryColor}
|
|
123
118
|
level={skillDetails.level || 0}
|
|
124
119
|
skillPoints={Math.round(skillDetails.skillPoints) || 0}
|
|
125
|
-
skillPointsToNextLevel={
|
|
120
|
+
skillPointsToNextLevel={
|
|
121
|
+
Math.round(getSPForLevel(skillDetails.level + 1)) || 0
|
|
122
|
+
}
|
|
126
123
|
texturePath={value}
|
|
127
124
|
atlasIMG={atlasIMG}
|
|
128
125
|
atlasJSON={atlasJSON}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
export const Tooltip = styled.div`
|
|
4
|
+
visibility: hidden;
|
|
5
|
+
position: absolute;
|
|
6
|
+
background-color: black;
|
|
7
|
+
color: white;
|
|
8
|
+
text-align: center;
|
|
9
|
+
border-radius: 4px;
|
|
10
|
+
padding: 5px;
|
|
11
|
+
z-index: 1;
|
|
12
|
+
font-size: 0.5rem;
|
|
13
|
+
white-space: nowrap;
|
|
14
|
+
|
|
15
|
+
/* Positioning */
|
|
16
|
+
top: -20px; /* Adjust based on where you want the tooltip to appear */
|
|
17
|
+
left: 50%;
|
|
18
|
+
transform: translateX(-50%);
|
|
19
|
+
`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ISkill, SkillType, getSPForLevel } from '@rpg-engine/shared';
|
|
2
2
|
|
|
3
|
-
for (let level =
|
|
3
|
+
for (let level = 2; level <= 20; level++) {
|
|
4
4
|
console.log(`SP for level ${level}: ${getSPForLevel(level)}`);
|
|
5
5
|
}
|
|
6
6
|
|
|
@@ -9,7 +9,7 @@ export const skillMock = {
|
|
|
9
9
|
stamina: {
|
|
10
10
|
type: SkillType.BasicAttributes,
|
|
11
11
|
level: 1,
|
|
12
|
-
skillPoints:
|
|
12
|
+
skillPoints: 10,
|
|
13
13
|
skillPointsToNextLevel: getSPForLevel(2),
|
|
14
14
|
},
|
|
15
15
|
magic: {
|