@rpg-engine/long-bow 0.2.43 → 0.2.45

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.
Files changed (30) hide show
  1. package/dist/components/DayNightPeriod/DayNightPeriod.d.ts +11 -0
  2. package/dist/components/Item/Inventory/itemContainerHelper.d.ts +2 -2
  3. package/dist/components/StaticBook/StaticBook.d.ts +10 -0
  4. package/dist/components/TradingMenu/TradingItemRow.d.ts +2 -1
  5. package/dist/components/TradingMenu/TradingMenu.d.ts +1 -1
  6. package/dist/long-bow.cjs.development.js +67 -45
  7. package/dist/long-bow.cjs.development.js.map +1 -1
  8. package/dist/long-bow.cjs.production.min.js +1 -1
  9. package/dist/long-bow.cjs.production.min.js.map +1 -1
  10. package/dist/long-bow.esm.js +67 -45
  11. package/dist/long-bow.esm.js.map +1 -1
  12. package/dist/stories/DayNightPeriod.stories.d.ts +5 -0
  13. package/dist/stories/ItemTradingComponent.stories.d.ts +2 -2
  14. package/dist/stories/StaticBook.stories.d.ts +5 -0
  15. package/package.json +1 -1
  16. package/src/components/DayNightPeriod/DayNightPeriod.tsx +36 -0
  17. package/src/components/DayNightPeriod/Gif/Afternoon.gif +0 -0
  18. package/src/components/DayNightPeriod/Gif/Morning.gif +0 -0
  19. package/src/components/DayNightPeriod/Gif/Night.gif +0 -0
  20. package/src/components/Item/Inventory/ItemSlot.tsx +2 -2
  21. package/src/components/Item/Inventory/itemContainerHelper.ts +11 -5
  22. package/src/components/StaticBook/StaticBook.tsx +96 -0
  23. package/src/components/StaticBook/img/0.png +0 -0
  24. package/src/components/TradingMenu/TradingItemRow.tsx +15 -26
  25. package/src/components/TradingMenu/TradingMenu.tsx +47 -14
  26. package/src/mocks/itemContainer.mocks.ts +2 -2
  27. package/src/stories/DayNightPeriod.stories.tsx +20 -0
  28. package/src/stories/ItemTradingComponent.stories.tsx +20 -24
  29. package/src/stories/StaticBook.stories.tsx +39 -0
  30. package/src/stories/TradingMenu.stories.tsx +7 -0
@@ -27920,10 +27920,10 @@ var generateContextMenuListOptions = function generateContextMenuListOptions(act
27920
27920
  });
27921
27921
  return contextMenu;
27922
27922
  };
27923
- var generateContextMenu = function generateContextMenu(itemType, itemContainerType) {
27923
+ var generateContextMenu = function generateContextMenu(item, itemContainerType) {
27924
27924
  var contextActionMenu = [];
27925
27925
  if (itemContainerType === ItemContainerType.Inventory) {
27926
- switch (itemType) {
27926
+ switch (item.type) {
27927
27927
  case ItemType.Weapon:
27928
27928
  case ItemType.Armor:
27929
27929
  case ItemType.Accessory:
@@ -27948,7 +27948,7 @@ var generateContextMenu = function generateContextMenu(itemType, itemContainerTy
27948
27948
  }
27949
27949
  }
27950
27950
  if (itemContainerType === ItemContainerType.Equipment) {
27951
- switch (itemType) {
27951
+ switch (item.type) {
27952
27952
  case ItemType.Container:
27953
27953
  contextActionMenu = generateContextMenuListOptions(ActionsForEquipmentSet.Container);
27954
27954
  break;
@@ -27957,7 +27957,7 @@ var generateContextMenu = function generateContextMenu(itemType, itemContainerTy
27957
27957
  }
27958
27958
  }
27959
27959
  if (itemContainerType === ItemContainerType.Loot) {
27960
- switch (itemType) {
27960
+ switch (item.type) {
27961
27961
  case ItemType.Weapon:
27962
27962
  case ItemType.Armor:
27963
27963
  case ItemType.Accessory:
@@ -27979,7 +27979,7 @@ var generateContextMenu = function generateContextMenu(itemType, itemContainerTy
27979
27979
  }
27980
27980
  }
27981
27981
  if (itemContainerType === ItemContainerType.MapContainer) {
27982
- switch (itemType) {
27982
+ switch (item.type) {
27983
27983
  case ItemType.Weapon:
27984
27984
  case ItemType.Armor:
27985
27985
  case ItemType.Accessory:
@@ -28000,6 +28000,12 @@ var generateContextMenu = function generateContextMenu(itemType, itemContainerTy
28000
28000
  break;
28001
28001
  }
28002
28002
  }
28003
+ if (item.hasUseWith) {
28004
+ contextActionMenu.push({
28005
+ id: 'use-with',
28006
+ text: 'Use With...'
28007
+ });
28008
+ }
28003
28009
  return contextActionMenu;
28004
28010
  };
28005
28011
 
@@ -28037,7 +28043,7 @@ var ItemSlot = /*#__PURE__*/observer(function (_ref) {
28037
28043
  setContextActions = _useState3[1];
28038
28044
  useEffect(function () {
28039
28045
  if (item) {
28040
- setContextActions(generateContextMenu(item.type, containerType));
28046
+ setContextActions(generateContextMenu(item, containerType));
28041
28047
  }
28042
28048
  }, [item]);
28043
28049
  var getLeftPositionValue = function getLeftPositionValue(quantity) {
@@ -29355,35 +29361,20 @@ var TextArea = function TextArea(_ref) {
29355
29361
  var TradingItemRow = function TradingItemRow(_ref) {
29356
29362
  var atlasIMG = _ref.atlasIMG,
29357
29363
  atlasJSON = _ref.atlasJSON,
29358
- updateChartTotals = _ref.updateChartTotals,
29359
- traderItem = _ref.traderItem;
29360
- var _useState = useState(0),
29361
- itemQuantity = _useState[0],
29362
- setItemQuantity = _useState[1];
29364
+ onQuantityChange = _ref.onQuantityChange,
29365
+ traderItem = _ref.traderItem,
29366
+ selectedQty = _ref.selectedQty;
29363
29367
  var onLeftClick = function onLeftClick() {
29364
- if (itemQuantity > 0) {
29365
- var newQuantity = itemQuantity - 1;
29366
- setItemQuantity(newQuantity);
29367
- updateChartTotals({
29368
- key: traderItem.key,
29369
- qty: newQuantity,
29370
- price: traderItem.price,
29371
- texturePath: traderItem.texturePath,
29372
- name: traderItem.name
29373
- });
29368
+ if (selectedQty > 0) {
29369
+ var newQuantity = selectedQty - 1;
29370
+ onQuantityChange(traderItem, newQuantity);
29374
29371
  }
29375
29372
  };
29376
29373
  var onRightClick = function onRightClick() {
29377
- if (itemQuantity < 999) {
29378
- var newQuantity = itemQuantity + 1;
29379
- setItemQuantity(newQuantity);
29380
- updateChartTotals({
29381
- key: traderItem.key,
29382
- qty: newQuantity,
29383
- price: traderItem.price,
29384
- texturePath: traderItem.texturePath,
29385
- name: traderItem.name
29386
- });
29374
+ var _traderItem$qty;
29375
+ if (selectedQty < ((_traderItem$qty = traderItem.qty) != null ? _traderItem$qty : 999)) {
29376
+ var newQuantity = selectedQty + 1;
29377
+ onQuantityChange(traderItem, newQuantity);
29387
29378
  }
29388
29379
  };
29389
29380
  return React.createElement(ItemWrapper, null, React.createElement(ItemIconContainer, null, React.createElement(SpriteContainer$1, null, React.createElement(SpriteFromAtlas, {
@@ -29400,7 +29391,7 @@ var TradingItemRow = function TradingItemRow(_ref) {
29400
29391
  direction: "left",
29401
29392
  onClick: onLeftClick,
29402
29393
  onTouchStart: onLeftClick
29403
- }), React.createElement(QuantityDisplay, null, React.createElement(TextOverlay$2, null, React.createElement(Item$1, null, itemQuantity))), React.createElement(SelectArrow, {
29394
+ }), React.createElement(QuantityDisplay, null, React.createElement(TextOverlay$2, null, React.createElement(Item$1, null, selectedQty))), React.createElement(SelectArrow, {
29404
29395
  size: 32,
29405
29396
  className: "arrow-selector",
29406
29397
  direction: "right",
@@ -29456,20 +29447,49 @@ var TradingMenu = function TradingMenu(_ref) {
29456
29447
  var _useState = useState(0),
29457
29448
  sum = _useState[0],
29458
29449
  setSum = _useState[1];
29459
- var newSumArray = 0;
29460
- var updateChartTotals = function updateChartTotals(item) {
29461
- var itemIndex = traderItems.findIndex(function (itemArray) {
29462
- return itemArray.key === item.key;
29463
- });
29464
- traderItems[itemIndex] = item;
29450
+ var _useState2 = useState(new Map()),
29451
+ qtyMap = _useState2[0],
29452
+ setQtyMap = _useState2[1];
29453
+ var onQuantityChange = function onQuantityChange(item, selectedQty) {
29454
+ setQtyMap(new Map(qtyMap.set(item.key, selectedQty)));
29455
+ var newSum = 0;
29465
29456
  traderItems.forEach(function (item) {
29466
- if (item.qty) newSumArray += item.qty * item.price;
29467
- setSum(newSumArray);
29457
+ var qty = qtyMap.get(item.key);
29458
+ if (qty) newSum += qty * item.price;
29459
+ setSum(newSum);
29468
29460
  });
29469
29461
  };
29462
+ var isBuy = function isBuy() {
29463
+ return type == 'buy';
29464
+ };
29465
+ var hasGoldForSale = function hasGoldForSale() {
29466
+ if (isBuy()) {
29467
+ return !(sum > characterAvailableGold);
29468
+ }
29469
+ return true;
29470
+ };
29471
+ var getFinalGold = function getFinalGold() {
29472
+ if (isBuy()) {
29473
+ return characterAvailableGold - sum;
29474
+ } else {
29475
+ return characterAvailableGold + sum;
29476
+ }
29477
+ };
29470
29478
  var Capitalize = function Capitalize(word) {
29471
29479
  return word[0].toUpperCase() + word.substring(1);
29472
29480
  };
29481
+ var onConfirmClick = function onConfirmClick() {
29482
+ var items = [];
29483
+ traderItems.forEach(function (item) {
29484
+ var qty = qtyMap.get(item.key);
29485
+ if (qty) {
29486
+ items.push(Object.assign({}, item, {
29487
+ qty: qty
29488
+ }));
29489
+ }
29490
+ });
29491
+ onConfirm(items);
29492
+ };
29473
29493
  return React.createElement(DraggableContainer, {
29474
29494
  type: RPGUIContainerTypes.Framed,
29475
29495
  onCloseButton: function onCloseButton() {
@@ -29484,19 +29504,21 @@ var TradingMenu = function TradingMenu(_ref) {
29484
29504
  }, React.createElement(Title$3, null, Capitalize(type), " Menu"), React.createElement("hr", {
29485
29505
  className: "golden"
29486
29506
  })), React.createElement(TradingComponentScrollWrapper, null, traderItems.map(function (tradeItem, index) {
29507
+ var _qtyMap$get;
29487
29508
  return React.createElement(ItemWrapper$1, {
29488
29509
  key: tradeItem.key + "_" + index
29489
29510
  }, React.createElement(TradingItemRow, {
29490
29511
  atlasIMG: atlasIMG,
29491
29512
  atlasJSON: atlasJSON,
29492
- updateChartTotals: updateChartTotals,
29493
- traderItem: tradeItem
29513
+ onQuantityChange: onQuantityChange,
29514
+ traderItem: tradeItem,
29515
+ selectedQty: (_qtyMap$get = qtyMap.get(tradeItem.key)) != null ? _qtyMap$get : 0
29494
29516
  }));
29495
- })), React.createElement(GoldWrapper, null, React.createElement("p", null, "Available Gold:"), React.createElement("p", null, "$", characterAvailableGold)), React.createElement(TotalWrapper, null, React.createElement("p", null, "Total:"), React.createElement("p", null, "$", sum)), sum > characterAvailableGold ? React.createElement(AlertWrapper, null, React.createElement("p", null, " Sorry, not enough money.")) : React.createElement(GoldWrapper, null, React.createElement("p", null, "Final Gold:"), React.createElement("p", null, "$", characterAvailableGold - sum)), React.createElement(ButtonWrapper, null, React.createElement(Button, {
29517
+ })), React.createElement(GoldWrapper, null, React.createElement("p", null, "Available Gold:"), React.createElement("p", null, "$", characterAvailableGold)), React.createElement(TotalWrapper, null, React.createElement("p", null, "Total:"), React.createElement("p", null, "$", sum)), !hasGoldForSale() ? React.createElement(AlertWrapper, null, React.createElement("p", null, " Sorry, not enough money.")) : React.createElement(GoldWrapper, null, React.createElement("p", null, "Final Gold:"), React.createElement("p", null, "$", getFinalGold())), React.createElement(ButtonWrapper, null, React.createElement(Button, {
29496
29518
  buttonType: ButtonTypes.RPGUIButton,
29497
- disabled: sum > characterAvailableGold,
29519
+ disabled: !hasGoldForSale(),
29498
29520
  onClick: function onClick() {
29499
- return onConfirm();
29521
+ return onConfirmClick();
29500
29522
  }
29501
29523
  }, "Confirm"), React.createElement(Button, {
29502
29524
  buttonType: ButtonTypes.RPGUIButton,