@rpg-engine/long-bow 0.8.168 → 0.8.170

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpg-engine/long-bow",
3
- "version": "0.8.168",
3
+ "version": "0.8.170",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -1,4 +1,4 @@
1
- import { IEquipmentSet, IItem, IMarketplaceItem, MarketplaceAcceptedCurrency } from '@rpg-engine/shared';
1
+ import { formatDCAmount, goldToDC, IEquipmentSet, IItem, IMarketplaceItem, MarketplaceAcceptedCurrency } from '@rpg-engine/shared';
2
2
  import { Coins } from 'pixelarticons/react/Coins';
3
3
  import { ShoppingBag } from 'pixelarticons/react/ShoppingBag';
4
4
  import React, { useEffect, useRef, useState } from 'react';
@@ -27,6 +27,7 @@ export interface IManagmentPanelProps {
27
27
  disableHotkeys?: () => void;
28
28
  onMoneyWithdraw: () => void;
29
29
  currentPage: number;
30
+ dcToGoldSwapRate?: number;
30
31
  }
31
32
 
32
33
  const LISTING_CURRENCY_OPTIONS: { value: MarketplaceAcceptedCurrency; label: string }[] = [
@@ -51,6 +52,7 @@ export const ManagmentPanel: React.FC<IManagmentPanelProps> = ({
51
52
  disableHotkeys,
52
53
  onMoneyWithdraw,
53
54
  currentPage,
55
+ dcToGoldSwapRate = 0,
54
56
  }) => {
55
57
  const [price, setPrice] = useState('');
56
58
  const [isCreatingOffer, setIsCreatingOffer] = useState(false);
@@ -145,6 +147,9 @@ export const ManagmentPanel: React.FC<IManagmentPanelProps> = ({
145
147
  {opt.label}
146
148
  </CurrencyToggleButton>
147
149
  ))}
150
+ {listingCurrency !== MarketplaceAcceptedCurrency.Gold && price && Number(price) > 0 && (
151
+ <DCPreview>{formatDCAmount(goldToDC(Number(price)))} DC</DCPreview>
152
+ )}
148
153
  </CurrencyToggleRow>
149
154
  </PriceInputWrapper>
150
155
  </Flex>
@@ -191,18 +196,25 @@ export const ManagmentPanel: React.FC<IManagmentPanelProps> = ({
191
196
  </OptionsWrapper>
192
197
 
193
198
  <ItemComponentScrollWrapper id="MarketContainer" ref={itemsContainer}>
194
- {items?.map(({ item, price, _id, acceptedCurrency: listingCurrency }: IMarketplaceItem, index: number) => (
195
- <MarketplaceRows
196
- key={`${item.key}_${index}`}
197
- atlasIMG={atlasIMG}
198
- atlasJSON={atlasJSON}
199
- item={item}
200
- itemPrice={price}
201
- acceptedCurrency={listingCurrency}
202
- equipmentSet={equipmentSet}
203
- onMarketPlaceItemRemove={setRemovingItemId.bind(null, _id)}
204
- />
205
- ))}
199
+ {items?.map(({ item, price, _id, acceptedCurrency: itemCurrency }: IMarketplaceItem, index: number) => {
200
+ const currency = itemCurrency || MarketplaceAcceptedCurrency.GoldOrDc;
201
+ const isDcOnly = currency === MarketplaceAcceptedCurrency.Dc;
202
+ const showDcPrice = isDcOnly || (dcToGoldSwapRate > 0 && currency !== MarketplaceAcceptedCurrency.Gold);
203
+
204
+ return (
205
+ <MarketplaceRows
206
+ key={`${item.key}_${index}`}
207
+ atlasIMG={atlasIMG}
208
+ atlasJSON={atlasJSON}
209
+ item={item}
210
+ itemPrice={price}
211
+ dcEquivalentPrice={showDcPrice ? goldToDC(price) : undefined}
212
+ acceptedCurrency={currency}
213
+ equipmentSet={equipmentSet}
214
+ onMarketPlaceItemRemove={setRemovingItemId.bind(null, _id)}
215
+ />
216
+ );
217
+ })}
206
218
  </ItemComponentScrollWrapper>
207
219
  </>
208
220
  );
@@ -386,3 +398,11 @@ const CurrencyToggleButton = styled.button<{ $active: boolean }>`
386
398
  color: ${({ $active }) => ($active ? '#f59e0b' : '#ddd')} !important;
387
399
  }
388
400
  `;
401
+
402
+ const DCPreview = styled.span`
403
+ font-family: 'Press Start 2P', cursive !important;
404
+ font-size: 0.4rem !important;
405
+ color: rgba(167, 139, 250, 0.8) !important;
406
+ white-space: nowrap;
407
+ margin-left: auto;
408
+ `;
@@ -96,12 +96,6 @@ export const MarketplaceRows: React.FC<IMarketPlaceRowsPropos> = ({
96
96
  <Ellipsis maxLines={1} maxWidth="200px" fontSize="10px">
97
97
  {item.name}
98
98
  </Ellipsis>
99
- {acceptedCurrency === MarketplaceAcceptedCurrency.Dc && (
100
- <CurrencyBadge $color="#a78bfa">DC only</CurrencyBadge>
101
- )}
102
- {acceptedCurrency === MarketplaceAcceptedCurrency.Gold && (
103
- <CurrencyBadge $color="#fef08a">Gold only</CurrencyBadge>
104
- )}
105
99
  </ItemName>
106
100
  <PriceRow>
107
101
  {acceptedCurrency !== MarketplaceAcceptedCurrency.Dc && (
@@ -321,21 +315,6 @@ const GemContainer = styled.p`
321
315
  font-size: ${uiFonts.size.xsmall} !important;
322
316
  `;
323
317
 
324
- const CurrencyBadge = styled.span<{ $color: string }>`
325
- display: inline-block;
326
- margin-left: 6px;
327
- padding: 1px 4px;
328
- font-family: 'Press Start 2P', cursive;
329
- font-size: 0.38rem;
330
- color: ${({ $color }) => $color};
331
- border: 1px solid ${({ $color }) => $color};
332
- border-radius: 3px;
333
- opacity: 0.85;
334
- vertical-align: middle;
335
- text-transform: uppercase;
336
- letter-spacing: 0.5px;
337
- `;
338
-
339
318
  const RarityContainer = styled.div<{ item: IItem }>`
340
319
  border-color: ${({ item }) => rarityColor(item)};
341
320
  box-shadow: ${({ item }) => `0 0 5px 8px ${rarityColor(item)}`} inset,
@@ -82,6 +82,13 @@ const mockTransactions: IMarketplaceTransaction[] = [
82
82
  { owner: 'player-1', type: MarketplaceTransactionType.BuyOrderCancelled, goldAmount: 300, itemKey: 'items/leather-armor', itemName: 'Leather Armor', createdAt: daysAgo(10), updatedAt: daysAgo(10) },
83
83
  ];
84
84
 
85
+ const currencyForIndex = (i: number): MarketplaceAcceptedCurrency | undefined => {
86
+ if (i === 1) return MarketplaceAcceptedCurrency.Dc;
87
+ if (i === 3) return MarketplaceAcceptedCurrency.Gold;
88
+ if (i === 5) return MarketplaceAcceptedCurrency.Dc;
89
+ return undefined; // defaults to GoldOrDc
90
+ };
91
+
85
92
  const dcOnlyItem: IMarketplaceItem = {
86
93
  _id: 'dc-only-listing-1',
87
94
  owner: 'player-99',
@@ -146,11 +153,12 @@ const Template: Story = () => {
146
153
  atlasJSON={atlasJSON}
147
154
  onClose={() => console.log('close')}
148
155
  items={[
149
- ...items.map(item => ({
156
+ ...items.map((item, i) => ({
150
157
  item,
151
158
  price: Math.round(Math.random() * 1000),
152
159
  _id: Math.random().toString(),
153
160
  owner: Math.random().toString(),
161
+ ...(currencyForIndex(i) && { acceptedCurrency: currencyForIndex(i) }),
154
162
  })),
155
163
  dcOnlyItem,
156
164
  ]}