@rpg-engine/long-bow 0.6.0 → 0.6.2
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/Item/Inventory/ItemGem.d.ts +8 -0
- package/dist/long-bow.cjs.development.js +67 -6
- 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 +67 -6
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/components/Item/Inventory/ItemGem.tsx +80 -0
- package/src/components/Item/Inventory/ItemSlotRenderer.tsx +15 -1
- package/src/mocks/itemContainer.mocks.ts +58 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rpg-engine/long-bow",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
85
|
"@rollup/plugin-image": "^2.1.1",
|
|
86
|
-
"@rpg-engine/shared": "^0.9.
|
|
86
|
+
"@rpg-engine/shared": "^0.9.52",
|
|
87
87
|
"dayjs": "^1.11.2",
|
|
88
88
|
"font-awesome": "^4.7.0",
|
|
89
89
|
"fs-extra": "^10.1.0",
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { IItem } from '@rpg-engine/shared';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
|
|
5
|
+
interface IProps {
|
|
6
|
+
item: IItem;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const gemColors: { [key: string]: string } = {
|
|
10
|
+
'emerald-gem': '#50C878', // Emerald green
|
|
11
|
+
'topaz-radiance': '#FFC87C', // Topaz yellow
|
|
12
|
+
'sapphire-gem': '#0F52BA', // Sapphire blue
|
|
13
|
+
'ruby-gem': '#E0115F', // Ruby red
|
|
14
|
+
'misty-quartz-gem': '#D9D9F3', // Misty Quartz purple
|
|
15
|
+
'coral-reef-gem': '#FF7F50', // Coral reef orange
|
|
16
|
+
'jasper-gem': '#D73B3E', // Jasper red
|
|
17
|
+
'earthstone-gem': '#8B4513', // Earthstone brown
|
|
18
|
+
'obsidian-gem': '#0B0C0E', // Obsidian black
|
|
19
|
+
'amethyst-gem': '#9966CC', // Amethyst purple
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const defaultColor = '#FFFFFF'; // Default color (white)
|
|
23
|
+
|
|
24
|
+
export const onRenderGems = (item: IItem) => {
|
|
25
|
+
const gemQty = item.attachedGems?.length || 0;
|
|
26
|
+
|
|
27
|
+
if (gemQty > 0) {
|
|
28
|
+
return <ItemSlotQty item={item} />;
|
|
29
|
+
}
|
|
30
|
+
return undefined;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const ItemSlotQty = ({ item }: IProps): JSX.Element => {
|
|
34
|
+
console.log(item.attachedGems);
|
|
35
|
+
|
|
36
|
+
const itemId = item._id;
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<ItemQtyContainer key={`qty-${itemId}`} className="item-slot-qty">
|
|
40
|
+
{item.attachedGems?.map((gem, index) => (
|
|
41
|
+
<Gem
|
|
42
|
+
key={`${itemId}-gem-${index}`}
|
|
43
|
+
color={gemColors[gem.key] || defaultColor}
|
|
44
|
+
/>
|
|
45
|
+
))}
|
|
46
|
+
</ItemQtyContainer>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const ItemQtyContainer = styled.div`
|
|
51
|
+
position: relative;
|
|
52
|
+
width: 85%;
|
|
53
|
+
height: 16px;
|
|
54
|
+
top: 26px;
|
|
55
|
+
left: -2px;
|
|
56
|
+
pointer-events: none;
|
|
57
|
+
transform: scale(0.8);
|
|
58
|
+
display: flex;
|
|
59
|
+
align-items: center;
|
|
60
|
+
justify-content: center;
|
|
61
|
+
opacity: 0.8;
|
|
62
|
+
`;
|
|
63
|
+
|
|
64
|
+
const Gem = styled.div<{ color: string }>`
|
|
65
|
+
width: 8px;
|
|
66
|
+
height: 8px;
|
|
67
|
+
background-color: ${({ color }) => color};
|
|
68
|
+
border: 1px solid black;
|
|
69
|
+
transform: rotate(45deg);
|
|
70
|
+
margin: 0 2px;
|
|
71
|
+
box-shadow: 0 0 5px ${({ color }) => color}; /* Glow effect */
|
|
72
|
+
transition: transform 0.2s, box-shadow 0.2s; /* Smooth transition for hover effect */
|
|
73
|
+
|
|
74
|
+
&:hover {
|
|
75
|
+
transform: rotate(45deg) scale(1.2);
|
|
76
|
+
box-shadow: 0 0 10px ${({ color }) => color}; /* Enhanced glow on hover */
|
|
77
|
+
}
|
|
78
|
+
`;
|
|
79
|
+
|
|
80
|
+
export default ItemSlotQty;
|
|
@@ -8,6 +8,7 @@ import React from 'react';
|
|
|
8
8
|
import { v4 as uuidv4 } from 'uuid';
|
|
9
9
|
import { SpriteFromAtlas } from '../../shared/SpriteFromAtlas';
|
|
10
10
|
import { ErrorBoundary } from './ErrorBoundary';
|
|
11
|
+
import { onRenderGems } from './ItemGem';
|
|
11
12
|
import { EquipmentSlotSpriteByType } from './ItemSlot';
|
|
12
13
|
import { onRenderStackInfo } from './ItemSlotQty/ItemSlotQty';
|
|
13
14
|
|
|
@@ -26,6 +27,18 @@ export const ItemSlotRenderer: React.FC<IProps> = ({
|
|
|
26
27
|
slotSpriteMask,
|
|
27
28
|
item,
|
|
28
29
|
}) => {
|
|
30
|
+
const renderStackInfo = (item: IItem) => {
|
|
31
|
+
return (
|
|
32
|
+
item.stackQty &&
|
|
33
|
+
item.stackQty > 1 &&
|
|
34
|
+
onRenderStackInfo(item._id, item.stackQty)
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const renderGems = (item: IItem) => {
|
|
39
|
+
return item.attachedGems && onRenderGems(item);
|
|
40
|
+
};
|
|
41
|
+
|
|
29
42
|
const renderItem = (item: IItem | null) => {
|
|
30
43
|
if (!item?.texturePath) {
|
|
31
44
|
return null;
|
|
@@ -48,7 +61,8 @@ export const ItemSlotRenderer: React.FC<IProps> = ({
|
|
|
48
61
|
imgScale={3}
|
|
49
62
|
imgClassname="sprite-from-atlas-img--item"
|
|
50
63
|
/>
|
|
51
|
-
{
|
|
64
|
+
{renderStackInfo(item)}
|
|
65
|
+
{renderGems(item)}
|
|
52
66
|
</ErrorBoundary>
|
|
53
67
|
);
|
|
54
68
|
};
|
|
@@ -54,6 +54,44 @@ export const items: IItem[] = [
|
|
|
54
54
|
level: 5,
|
|
55
55
|
},
|
|
56
56
|
},
|
|
57
|
+
attachedGems: [
|
|
58
|
+
{
|
|
59
|
+
gemEntityEffectsAdd: ['poison'],
|
|
60
|
+
key: 'ruby-gem',
|
|
61
|
+
name: 'Ruby Gem',
|
|
62
|
+
gemStatBuff: {
|
|
63
|
+
attack: 5,
|
|
64
|
+
defense: 4,
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
gemEntityEffectsAdd: ['poison'],
|
|
69
|
+
key: 'misty-quartz-gem',
|
|
70
|
+
name: 'Misty Quartz Gem',
|
|
71
|
+
gemStatBuff: {
|
|
72
|
+
attack: 5,
|
|
73
|
+
defense: 4,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
gemEntityEffectsAdd: ['poison'],
|
|
78
|
+
key: 'coral-reef-gem',
|
|
79
|
+
name: 'Coral Reef Gem',
|
|
80
|
+
gemStatBuff: {
|
|
81
|
+
attack: 5,
|
|
82
|
+
defense: 4,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
gemEntityEffectsAdd: ['poison'],
|
|
87
|
+
key: 'emerald-gem',
|
|
88
|
+
name: 'Emerald Gem',
|
|
89
|
+
gemStatBuff: {
|
|
90
|
+
attack: 5,
|
|
91
|
+
defense: 4,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
],
|
|
57
95
|
equippedBuffDescription: 'Character speed +10%',
|
|
58
96
|
entityEffectChance: 50,
|
|
59
97
|
entityEffects: ['freezing'],
|
|
@@ -91,6 +129,26 @@ export const items: IItem[] = [
|
|
|
91
129
|
createdAt: '2022-06-04T03:18:09.335Z',
|
|
92
130
|
updatedAt: '2022-06-04T18:16:49.056Z',
|
|
93
131
|
rarity: ItemRarities.Epic,
|
|
132
|
+
attachedGems: [
|
|
133
|
+
{
|
|
134
|
+
gemEntityEffectsAdd: ['poison'],
|
|
135
|
+
key: 'emerald-gem',
|
|
136
|
+
name: 'Emerald Gem',
|
|
137
|
+
gemStatBuff: {
|
|
138
|
+
attack: 5,
|
|
139
|
+
defense: 4,
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
gemEntityEffectsAdd: ['poison'],
|
|
144
|
+
key: 'emerald-gem',
|
|
145
|
+
name: 'Emerald Gem',
|
|
146
|
+
gemStatBuff: {
|
|
147
|
+
attack: 5,
|
|
148
|
+
defense: 4,
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
],
|
|
94
152
|
},
|
|
95
153
|
{
|
|
96
154
|
_id: '629acef1c7c8e8002ff60723',
|