@rpg-engine/long-bow 0.8.145 → 0.8.146
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/Marketplace/BlueprintTable.d.ts +9 -0
- package/dist/long-bow.cjs.development.js +116 -72
- 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 +116 -72
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Marketplace/BlueprintSearchModal.tsx +14 -137
- package/src/components/Marketplace/BlueprintTable.tsx +158 -0
- package/src/components/Marketplace/BuyOrderDetailsModal.tsx +9 -10
- package/src/components/Marketplace/BuyOrderPanel.tsx +25 -7
- package/src/stories/Features/marketplace/BuyOrderPanel.stories.tsx +197 -81
- package/src/stories/Features/trading/Marketplace.stories.tsx +27 -4
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
+
IMarketplaceBlueprintSearchRequest,
|
|
2
3
|
IMarketplaceBlueprintSummary,
|
|
3
4
|
IMarketplaceBuyOrderItem,
|
|
4
5
|
MarketplaceBuyOrderStatus,
|
|
5
6
|
} from '@rpg-engine/shared';
|
|
6
7
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
7
8
|
import React, { useState } from 'react';
|
|
9
|
+
import { BlueprintSearchModal } from '../../../components/Marketplace/BlueprintSearchModal';
|
|
8
10
|
import { BuyOrderPanel } from '../../../components/Marketplace/BuyOrderPanel';
|
|
9
11
|
import { RPGUIRoot } from '../../../components/RPGUI/RPGUIRoot';
|
|
10
12
|
import atlasJSON from '../../../mocks/atlas/items/items.json';
|
|
@@ -44,6 +46,36 @@ const mockSelectedBlueprint: IMarketplaceBlueprintSummary = {
|
|
|
44
46
|
texturePath: 'swords/broad-sword.png',
|
|
45
47
|
};
|
|
46
48
|
|
|
49
|
+
const mockBlueprintSearchResults: IMarketplaceBlueprintSummary[] = [
|
|
50
|
+
{
|
|
51
|
+
key: 'items/broad-sword',
|
|
52
|
+
name: 'Broad Sword',
|
|
53
|
+
type: 'Weapon',
|
|
54
|
+
subType: 'Sword',
|
|
55
|
+
tier: 1,
|
|
56
|
+
textureAtlas: 'items',
|
|
57
|
+
texturePath: 'swords/broad-sword.png',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
key: 'items/angelic-sword',
|
|
61
|
+
name: 'Angelic Sword',
|
|
62
|
+
type: 'Weapon',
|
|
63
|
+
subType: 'Sword',
|
|
64
|
+
tier: 5,
|
|
65
|
+
textureAtlas: 'items',
|
|
66
|
+
texturePath: 'swords/angelic-sword.png',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
key: 'items/leather-armor',
|
|
70
|
+
name: 'Leather Armor',
|
|
71
|
+
type: 'Armor',
|
|
72
|
+
subType: 'Body',
|
|
73
|
+
tier: 1,
|
|
74
|
+
textureAtlas: 'items',
|
|
75
|
+
texturePath: 'armors/leather-armor.png',
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
|
|
47
79
|
const mockBuyOrders: IMarketplaceBuyOrderItem[] = [
|
|
48
80
|
{
|
|
49
81
|
_id: 'order-1',
|
|
@@ -84,113 +116,197 @@ const mockBuyOrders: IMarketplaceBuyOrderItem[] = [
|
|
|
84
116
|
|
|
85
117
|
const DefaultWrapper = () => {
|
|
86
118
|
const [selectedBlueprint, setSelectedBlueprint] = useState<IMarketplaceBlueprintSummary | undefined>();
|
|
119
|
+
const [isBlueprintSearchOpen, setIsBlueprintSearchOpen] = useState(false);
|
|
87
120
|
const [quantity, setQuantity] = useState(0);
|
|
88
121
|
const [maxPrice, setMaxPrice] = useState(0);
|
|
89
122
|
const [rarity, setRarity] = useState('');
|
|
90
123
|
const [yourOrders, setYourOrders] = useState<IMarketplaceBuyOrderItem[]>(mockBuyOrders);
|
|
91
124
|
|
|
125
|
+
const handleBlueprintSelect = (blueprint: IMarketplaceBlueprintSummary) => {
|
|
126
|
+
setIsBlueprintSearchOpen(false);
|
|
127
|
+
setSelectedBlueprint(blueprint);
|
|
128
|
+
};
|
|
129
|
+
|
|
92
130
|
return (
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
<>
|
|
132
|
+
<BuyOrderPanel
|
|
133
|
+
atlasJSON={atlasJSON}
|
|
134
|
+
atlasIMG={atlasIMG}
|
|
135
|
+
selectedBlueprint={selectedBlueprint}
|
|
136
|
+
onOpenBlueprintSearch={() => setIsBlueprintSearchOpen(true)}
|
|
137
|
+
onCloseDetails={() => {
|
|
138
|
+
setSelectedBlueprint(undefined);
|
|
139
|
+
setQuantity(0);
|
|
140
|
+
setMaxPrice(0);
|
|
141
|
+
setRarity('');
|
|
142
|
+
}}
|
|
143
|
+
onQuantityChange={setQuantity}
|
|
144
|
+
onMaxPriceChange={setMaxPrice}
|
|
145
|
+
onRarityChange={setRarity}
|
|
146
|
+
onPlaceBuyOrder={() => {
|
|
147
|
+
if (selectedBlueprint) {
|
|
148
|
+
const newOrder: IMarketplaceBuyOrderItem = {
|
|
149
|
+
_id: `order-${Date.now()}`,
|
|
150
|
+
owner: 'character-1',
|
|
151
|
+
itemBlueprintKey: selectedBlueprint.key,
|
|
152
|
+
itemRarity: rarity as any,
|
|
153
|
+
maxPrice,
|
|
154
|
+
escrowedGold: maxPrice,
|
|
155
|
+
fee: Math.floor(maxPrice * 0.05),
|
|
156
|
+
status: MarketplaceBuyOrderStatus.Active,
|
|
157
|
+
createdAt: new Date(),
|
|
158
|
+
updatedAt: new Date(),
|
|
159
|
+
};
|
|
160
|
+
setYourOrders(prev => [newOrder, ...prev]);
|
|
161
|
+
}
|
|
162
|
+
}}
|
|
163
|
+
currentQuantity={quantity}
|
|
164
|
+
currentMaxPrice={maxPrice}
|
|
165
|
+
selectedRarity={rarity}
|
|
166
|
+
yourBuyOrders={yourOrders}
|
|
167
|
+
yourBuyOrdersTotal={yourOrders.length}
|
|
168
|
+
yourBuyOrdersPage={1}
|
|
169
|
+
onYourBuyOrdersPageChange={(page) => console.log('Page:', page)}
|
|
170
|
+
onCancelBuyOrder={(id) => setYourOrders(prev => prev.filter(o => o._id !== id))}
|
|
171
|
+
/>
|
|
172
|
+
<BlueprintSearchModal
|
|
173
|
+
isOpen={isBlueprintSearchOpen}
|
|
174
|
+
onClose={() => setIsBlueprintSearchOpen(false)}
|
|
175
|
+
onSelect={handleBlueprintSelect}
|
|
176
|
+
onSearch={(req: IMarketplaceBlueprintSearchRequest) => console.log('search:', req)}
|
|
177
|
+
blueprints={mockBlueprintSearchResults}
|
|
178
|
+
totalCount={mockBlueprintSearchResults.length}
|
|
179
|
+
currentPage={1}
|
|
180
|
+
isLoading={false}
|
|
181
|
+
atlasJSON={atlasJSON}
|
|
182
|
+
atlasIMG={atlasIMG}
|
|
183
|
+
/>
|
|
184
|
+
</>
|
|
133
185
|
);
|
|
134
186
|
};
|
|
135
187
|
|
|
136
188
|
const WithBlueprintWrapper = () => {
|
|
137
189
|
const [selectedBlueprint, setSelectedBlueprint] = useState<IMarketplaceBlueprintSummary | undefined>(mockSelectedBlueprint);
|
|
190
|
+
const [isBlueprintSearchOpen, setIsBlueprintSearchOpen] = useState(false);
|
|
138
191
|
const [quantity, setQuantity] = useState(0);
|
|
139
192
|
const [maxPrice, setMaxPrice] = useState(0);
|
|
140
193
|
const [rarity, setRarity] = useState('');
|
|
141
194
|
const [yourOrders, setYourOrders] = useState<IMarketplaceBuyOrderItem[]>(mockBuyOrders);
|
|
142
195
|
|
|
196
|
+
const handleBlueprintSelect = (blueprint: IMarketplaceBlueprintSummary) => {
|
|
197
|
+
setIsBlueprintSearchOpen(false);
|
|
198
|
+
setSelectedBlueprint(blueprint);
|
|
199
|
+
};
|
|
200
|
+
|
|
143
201
|
return (
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
202
|
+
<>
|
|
203
|
+
<BuyOrderPanel
|
|
204
|
+
atlasJSON={atlasJSON}
|
|
205
|
+
atlasIMG={atlasIMG}
|
|
206
|
+
selectedBlueprint={selectedBlueprint}
|
|
207
|
+
onOpenBlueprintSearch={() => setIsBlueprintSearchOpen(true)}
|
|
208
|
+
onCloseDetails={() => {
|
|
209
|
+
setSelectedBlueprint(undefined);
|
|
210
|
+
setQuantity(0);
|
|
211
|
+
setMaxPrice(0);
|
|
212
|
+
setRarity('');
|
|
213
|
+
}}
|
|
214
|
+
onQuantityChange={setQuantity}
|
|
215
|
+
onMaxPriceChange={setMaxPrice}
|
|
216
|
+
onRarityChange={setRarity}
|
|
217
|
+
onPlaceBuyOrder={() => {
|
|
218
|
+
if (selectedBlueprint) {
|
|
219
|
+
const newOrder: IMarketplaceBuyOrderItem = {
|
|
220
|
+
_id: `order-${Date.now()}`,
|
|
221
|
+
owner: 'character-1',
|
|
222
|
+
itemBlueprintKey: selectedBlueprint.key,
|
|
223
|
+
itemRarity: rarity as any,
|
|
224
|
+
maxPrice,
|
|
225
|
+
escrowedGold: maxPrice,
|
|
226
|
+
fee: Math.floor(maxPrice * 0.05),
|
|
227
|
+
status: MarketplaceBuyOrderStatus.Active,
|
|
228
|
+
createdAt: new Date(),
|
|
229
|
+
updatedAt: new Date(),
|
|
230
|
+
};
|
|
231
|
+
setYourOrders(prev => [newOrder, ...prev]);
|
|
232
|
+
}
|
|
233
|
+
}}
|
|
234
|
+
currentQuantity={quantity}
|
|
235
|
+
currentMaxPrice={maxPrice}
|
|
236
|
+
selectedRarity={rarity}
|
|
237
|
+
yourBuyOrders={yourOrders}
|
|
238
|
+
yourBuyOrdersTotal={yourOrders.length}
|
|
239
|
+
yourBuyOrdersPage={1}
|
|
240
|
+
onYourBuyOrdersPageChange={(page) => console.log('Page:', page)}
|
|
241
|
+
onCancelBuyOrder={(id) => setYourOrders(prev => prev.filter(o => o._id !== id))}
|
|
242
|
+
/>
|
|
243
|
+
<BlueprintSearchModal
|
|
244
|
+
isOpen={isBlueprintSearchOpen}
|
|
245
|
+
onClose={() => setIsBlueprintSearchOpen(false)}
|
|
246
|
+
onSelect={handleBlueprintSelect}
|
|
247
|
+
onSearch={(req: IMarketplaceBlueprintSearchRequest) => console.log('search:', req)}
|
|
248
|
+
blueprints={mockBlueprintSearchResults}
|
|
249
|
+
totalCount={mockBlueprintSearchResults.length}
|
|
250
|
+
currentPage={1}
|
|
251
|
+
isLoading={false}
|
|
252
|
+
atlasJSON={atlasJSON}
|
|
253
|
+
atlasIMG={atlasIMG}
|
|
254
|
+
/>
|
|
255
|
+
</>
|
|
168
256
|
);
|
|
169
257
|
};
|
|
170
258
|
|
|
171
259
|
const EmptyWrapper = () => {
|
|
260
|
+
const [isBlueprintSearchOpen, setIsBlueprintSearchOpen] = useState(false);
|
|
261
|
+
const [selectedBlueprint, setSelectedBlueprint] = useState<IMarketplaceBlueprintSummary | undefined>();
|
|
172
262
|
const [quantity, setQuantity] = useState(0);
|
|
173
263
|
const [maxPrice, setMaxPrice] = useState(0);
|
|
174
264
|
const [rarity, setRarity] = useState('');
|
|
175
265
|
|
|
266
|
+
const handleBlueprintSelect = (blueprint: IMarketplaceBlueprintSummary) => {
|
|
267
|
+
setIsBlueprintSearchOpen(false);
|
|
268
|
+
setSelectedBlueprint(blueprint);
|
|
269
|
+
};
|
|
270
|
+
|
|
176
271
|
return (
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
272
|
+
<>
|
|
273
|
+
<BuyOrderPanel
|
|
274
|
+
atlasJSON={atlasJSON}
|
|
275
|
+
atlasIMG={atlasIMG}
|
|
276
|
+
selectedBlueprint={selectedBlueprint}
|
|
277
|
+
onOpenBlueprintSearch={() => setIsBlueprintSearchOpen(true)}
|
|
278
|
+
onCloseDetails={() => {
|
|
279
|
+
setSelectedBlueprint(undefined);
|
|
280
|
+
setQuantity(0);
|
|
281
|
+
setMaxPrice(0);
|
|
282
|
+
setRarity('');
|
|
283
|
+
}}
|
|
284
|
+
onQuantityChange={setQuantity}
|
|
285
|
+
onMaxPriceChange={setMaxPrice}
|
|
286
|
+
onRarityChange={setRarity}
|
|
287
|
+
onPlaceBuyOrder={() => console.log('place order')}
|
|
288
|
+
currentQuantity={quantity}
|
|
289
|
+
currentMaxPrice={maxPrice}
|
|
290
|
+
selectedRarity={rarity}
|
|
291
|
+
yourBuyOrders={[]}
|
|
292
|
+
yourBuyOrdersTotal={0}
|
|
293
|
+
yourBuyOrdersPage={1}
|
|
294
|
+
onYourBuyOrdersPageChange={(page) => console.log('Page:', page)}
|
|
295
|
+
onCancelBuyOrder={(id) => console.log('Cancel:', id)}
|
|
296
|
+
/>
|
|
297
|
+
<BlueprintSearchModal
|
|
298
|
+
isOpen={isBlueprintSearchOpen}
|
|
299
|
+
onClose={() => setIsBlueprintSearchOpen(false)}
|
|
300
|
+
onSelect={handleBlueprintSelect}
|
|
301
|
+
onSearch={(req: IMarketplaceBlueprintSearchRequest) => console.log('search:', req)}
|
|
302
|
+
blueprints={mockBlueprintSearchResults}
|
|
303
|
+
totalCount={mockBlueprintSearchResults.length}
|
|
304
|
+
currentPage={1}
|
|
305
|
+
isLoading={false}
|
|
306
|
+
atlasJSON={atlasJSON}
|
|
307
|
+
atlasIMG={atlasIMG}
|
|
308
|
+
/>
|
|
309
|
+
</>
|
|
194
310
|
);
|
|
195
311
|
};
|
|
196
312
|
|
|
@@ -69,6 +69,7 @@ const Template: Story = () => {
|
|
|
69
69
|
const [blueprintResults, setBlueprintResults] = React.useState<IMarketplaceBlueprintSummary[]>([]);
|
|
70
70
|
const [blueprintLoading, setBlueprintLoading] = React.useState(false);
|
|
71
71
|
const [historyType, setHistoryType] = React.useState('All');
|
|
72
|
+
const [yourBuyOrders, setYourBuyOrders] = React.useState<IMarketplaceBuyOrderItem[]>(mockYourBuyOrders);
|
|
72
73
|
|
|
73
74
|
const handleBlueprintSearch = (request: any) => {
|
|
74
75
|
console.log('blueprint search:', request);
|
|
@@ -132,12 +133,34 @@ const Template: Story = () => {
|
|
|
132
133
|
onBuyOrderQuantityChange={setQuantity}
|
|
133
134
|
onBuyOrderMaxPriceChange={setMaxPrice}
|
|
134
135
|
onBuyOrderRarityChange={setSelectedRarity}
|
|
135
|
-
onPlaceBuyOrder={() =>
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
onPlaceBuyOrder={() => {
|
|
137
|
+
if (selectedBlueprint) {
|
|
138
|
+
const newOrder: IMarketplaceBuyOrderItem = {
|
|
139
|
+
_id: `bo-${Date.now()}`,
|
|
140
|
+
owner: 'player-1',
|
|
141
|
+
itemBlueprintKey: selectedBlueprint.key,
|
|
142
|
+
itemRarity: selectedRarity as any,
|
|
143
|
+
maxPrice,
|
|
144
|
+
escrowedGold: maxPrice,
|
|
145
|
+
fee: Math.floor(maxPrice * 0.05),
|
|
146
|
+
status: MarketplaceBuyOrderStatus.Active,
|
|
147
|
+
createdAt: new Date(),
|
|
148
|
+
updatedAt: new Date(),
|
|
149
|
+
};
|
|
150
|
+
setYourBuyOrders(prev => [newOrder, ...prev]);
|
|
151
|
+
}
|
|
152
|
+
}}
|
|
153
|
+
onClearBuyOrderBlueprint={() => {
|
|
154
|
+
setSelectedBlueprint(undefined);
|
|
155
|
+
setQuantity(1);
|
|
156
|
+
setMaxPrice(0);
|
|
157
|
+
setSelectedRarity('');
|
|
158
|
+
}}
|
|
159
|
+
yourBuyOrders={yourBuyOrders}
|
|
160
|
+
yourBuyOrdersTotal={yourBuyOrders.length}
|
|
138
161
|
yourBuyOrdersPage={1}
|
|
139
162
|
onYourBuyOrdersPageChange={p => console.log('your orders page:', p)}
|
|
140
|
-
onCancelBuyOrder={id =>
|
|
163
|
+
onCancelBuyOrder={id => setYourBuyOrders(prev => prev.filter(o => o._id !== id))}
|
|
141
164
|
openBuyOrders={mockOpenBuyOrders}
|
|
142
165
|
openBuyOrdersTotal={mockOpenBuyOrders.length}
|
|
143
166
|
openBuyOrdersPage={1}
|