mirror of
https://github.com/2006-Scape/2006Scape.git
synced 2026-07-03 00:31:51 +00:00
Shop fixes (#284)
* Update ShopAssistant.java * Fixup fish selling/buying * fixup * tidy up * fixup 0 stock items being removed
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user