@rpg-engine/long-bow 0.8.168 → 0.8.169

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.169",
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 { 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);
@@ -191,18 +193,25 @@ export const ManagmentPanel: React.FC<IManagmentPanelProps> = ({
191
193
  </OptionsWrapper>
192
194
 
193
195
  <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
- ))}
196
+ {items?.map(({ item, price, _id, acceptedCurrency: itemCurrency }: IMarketplaceItem, index: number) => {
197
+ const currency = itemCurrency || MarketplaceAcceptedCurrency.GoldOrDc;
198
+ const isDcOnly = currency === MarketplaceAcceptedCurrency.Dc;
199
+ const showDcPrice = isDcOnly || (dcToGoldSwapRate > 0 && currency !== MarketplaceAcceptedCurrency.Gold);
200
+
201
+ return (
202
+ <MarketplaceRows
203
+ key={`${item.key}_${index}`}
204
+ atlasIMG={atlasIMG}
205
+ atlasJSON={atlasJSON}
206
+ item={item}
207
+ itemPrice={price}
208
+ dcEquivalentPrice={showDcPrice ? goldToDC(price) : undefined}
209
+ acceptedCurrency={currency}
210
+ equipmentSet={equipmentSet}
211
+ onMarketPlaceItemRemove={setRemovingItemId.bind(null, _id)}
212
+ />
213
+ );
214
+ })}
206
215
  </ItemComponentScrollWrapper>
207
216
  </>
208
217
  );
@@ -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
  ]}