From c1a5cf449c23e44737ccbefc7bdcd5d1796e18ee Mon Sep 17 00:00:00 2001 From: Danial Date: Fri, 13 Dec 2019 14:07:45 +1300 Subject: [PATCH] Shop fixes (#284) * Update ShopAssistant.java * Fixup fish selling/buying * fixup * tidy up * fixup 0 stock items being removed --- .../rebotted/game/shops/ShopAssistant.java | 16 ++++++------ .../com/rebotted/game/shops/ShopHandler.java | 24 ++++++++++-------- .../rebotted/game/shops/ShopAssistant.class | Bin 13390 -> 13395 bytes .../com/rebotted/game/shops/ShopHandler.class | Bin 6313 -> 6360 bytes 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/2006Redone Server/src/com/rebotted/game/shops/ShopAssistant.java b/2006Redone Server/src/com/rebotted/game/shops/ShopAssistant.java index 64049f83..a0fa218e 100644 --- a/2006Redone Server/src/com/rebotted/game/shops/ShopAssistant.java +++ b/2006Redone Server/src/com/rebotted/game/shops/ShopAssistant.java @@ -276,32 +276,32 @@ public class ShopAssistant { String itemName = ItemAssistant.getItemName(unNotedItemID); for (int i : GameConstants.ITEM_SELLABLE) { if (unNotedItemID == i) { - player.getPacketSender().sendMessage("You can't sell " + ItemAssistant.getItemName(removeId).toLowerCase() + "."); + player.getPacketSender().sendMessage("You can't sell " + itemName + "."); return; } } - boolean IsIn = false; + boolean canSellItem = false; switch (ShopHandler.shopSModifier[player.shopId]) { // Only buys what is in stock case 2: for (int j = 0; j <= ShopHandler.shopItemsStandard[player.shopId]; j++) { if (unNotedItemID == (ShopHandler.shopItems[player.shopId][j] - 1)) { - IsIn = true; + canSellItem = true; break; } } break; // General store case 1: - IsIn = true; + canSellItem = true; break; // Player owns this store case 0: - IsIn = ShopHandler.playerOwnsStore(player.shopId, player); + canSellItem = ShopHandler.playerOwnsStore(player.shopId, player); break; } - if (IsIn == false) { + if (canSellItem == false) { player.getPacketSender().sendMessage("You can't sell " + ItemAssistant.getItemName(removeId).toLowerCase() + " to this store."); } else { int ShopValue = (int) Math.floor(getItemShopValue(unNotedItemID, 1, true)); @@ -468,7 +468,7 @@ public class ShopAssistant { private static int getUnNoted(int itemID){ String itemName = ItemAssistant.getItemName(itemID).toLowerCase(); String ItemNameUnNotedItem = ItemAssistant.getItemName(itemID - 1).toLowerCase(); - if (itemName.contains(ItemNameUnNotedItem)) { + if (itemName.equalsIgnoreCase(ItemNameUnNotedItem)) { itemID--; //Replace the noted item by it's un-noted version. } return itemID; @@ -477,7 +477,7 @@ public class ShopAssistant { private static int getNoted(int itemID){ String itemName = ItemAssistant.getItemName(itemID).toLowerCase(); String ItemNameUnNotedItem = ItemAssistant.getItemName(itemID + 1).toLowerCase(); - if (itemName.contains(ItemNameUnNotedItem)) { + if (itemName.equalsIgnoreCase(ItemNameUnNotedItem)) { itemID++; //Replace the item by it's noted version. } return itemID; diff --git a/2006Redone Server/src/com/rebotted/game/shops/ShopHandler.java b/2006Redone Server/src/com/rebotted/game/shops/ShopHandler.java index a985a49c..27eb5524 100644 --- a/2006Redone Server/src/com/rebotted/game/shops/ShopHandler.java +++ b/2006Redone Server/src/com/rebotted/game/shops/ShopHandler.java @@ -16,9 +16,9 @@ public class ShopHandler { public static int MAX_SHOP_ITEMS = 40; - public static int SHOW_DELAY = 2; + public static int SHOW_DELAY = 1; // Restock 1 item every tick - public static int SPECIAL_DELAY = 60; + public static int SPECIAL_DELAY = 60; // Remove overstocked items after 60 ticks public static int totalshops = 0; @@ -106,11 +106,13 @@ public class ShopHandler { shopItemsN[shopID][ArrayID] -= 1; if (shopItemsN[shopID][ArrayID] <= 0) { shopItemsN[shopID][ArrayID] = 0; - ResetItem(shopID, ArrayID); + if (shopItemsStandard[shopID] <= ArrayID) + ResetItem(shopID, ArrayID); } } private static void ResetItem(int shopID, int ArrayID) { + if (shopItemsStandard[shopID] > ArrayID) return; shopItems[shopID][ArrayID] = 0; shopItemsN[shopID][ArrayID] = 0; shopItemsDelay[shopID][ArrayID] = 0; @@ -143,19 +145,19 @@ public class ShopHandler { token = line.substring(0, spot); token = token.trim(); token2 = line.substring(spot + 1); - token2 = token2.trim(); - token2_2 = token2.replaceAll("\t+", "\t"); - token3 = token2_2.split("\t"); + token3 = token2.trim().split("\t+"); if (token.equals("shop")) { int shopID = Integer.parseInt(token3[0]); shopName[shopID] = token3[1].replaceAll("_", " "); shopSModifier[shopID] = Integer.parseInt(token3[2]); shopBModifier[shopID] = Integer.parseInt(token3[3]); for (int i = 0; i < ((token3.length - 4) / 2); i++) { - if (token3[(4 + (i * 2))] != null) { - shopItems[shopID][i] = (Integer.parseInt(token3[(4 + (i * 2))]) + 1); - shopItemsN[shopID][i] = Integer.parseInt(token3[(5 + (i * 2))]); - shopItemsSN[shopID][i] = Integer.parseInt(token3[(5 + (i * 2))]); + int itemID = Integer.parseInt(token3[(4 + (i * 2))]); + int itemAmount = Integer.parseInt(token3[(5 + (i * 2))]); + if (itemID > 0) { + shopItems[shopID][i] = itemID + 1; + shopItemsN[shopID][i] = itemAmount; + shopItemsSN[shopID][i] = itemAmount; shopItemsStandard[shopID]++; } else { break; @@ -164,7 +166,7 @@ public class ShopHandler { totalshops++; } } else { - if (line.equals("[ENDOFshopLIST]")) { + if (line.equalsIgnoreCase("[ENDOFSHOPLIST]")) { try { characterfile.close(); } catch (IOException ioexception) { diff --git a/CompiledServer/production/2006rebotted/com/rebotted/game/shops/ShopAssistant.class b/CompiledServer/production/2006rebotted/com/rebotted/game/shops/ShopAssistant.class index 58be24cd94c8178bf51c5cead9e93e8d9aed9277..d923d3cebffef59e6bb9ae8bf4055056e6f1e6c4 100644 GIT binary patch delta 684 zcmYjOOH5Ni6g}s?erY8@QX*ENRa>jpzJgj%B=S+Dp@Ft6s)U7An*x@Cd_-4ZG%k#v z$TO+#*cbwSf;>_nx=}%cF(w8#CNA6>w=C3PbXqq~a?hMIcg|#T?uYKR?%4qrndmiR zo%;#|_zI|~A@0r;|0BVPd`4g62G~h79OCT2U)=Y zeXM4fHH`5PM_9}2Ji>dd<0_BxJL{zY8>A!~rCV&0mUv8B;qfu)C!1vhPsoSaA~!Q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