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);
|
String itemName = ItemAssistant.getItemName(unNotedItemID);
|
||||||
for (int i : GameConstants.ITEM_SELLABLE) {
|
for (int i : GameConstants.ITEM_SELLABLE) {
|
||||||
if (unNotedItemID == i) {
|
if (unNotedItemID == i) {
|
||||||
player.getPacketSender().sendMessage("You can't sell " + ItemAssistant.getItemName(removeId).toLowerCase() + ".");
|
player.getPacketSender().sendMessage("You can't sell " + itemName + ".");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
boolean IsIn = false;
|
boolean canSellItem = false;
|
||||||
switch (ShopHandler.shopSModifier[player.shopId]) {
|
switch (ShopHandler.shopSModifier[player.shopId]) {
|
||||||
// Only buys what is in stock
|
// Only buys what is in stock
|
||||||
case 2:
|
case 2:
|
||||||
for (int j = 0; j <= ShopHandler.shopItemsStandard[player.shopId]; j++) {
|
for (int j = 0; j <= ShopHandler.shopItemsStandard[player.shopId]; j++) {
|
||||||
if (unNotedItemID == (ShopHandler.shopItems[player.shopId][j] - 1)) {
|
if (unNotedItemID == (ShopHandler.shopItems[player.shopId][j] - 1)) {
|
||||||
IsIn = true;
|
canSellItem = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// General store
|
// General store
|
||||||
case 1:
|
case 1:
|
||||||
IsIn = true;
|
canSellItem = true;
|
||||||
break;
|
break;
|
||||||
// Player owns this store
|
// Player owns this store
|
||||||
case 0:
|
case 0:
|
||||||
IsIn = ShopHandler.playerOwnsStore(player.shopId, player);
|
canSellItem = ShopHandler.playerOwnsStore(player.shopId, player);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsIn == false) {
|
if (canSellItem == false) {
|
||||||
player.getPacketSender().sendMessage("You can't sell " + ItemAssistant.getItemName(removeId).toLowerCase() + " to this store.");
|
player.getPacketSender().sendMessage("You can't sell " + ItemAssistant.getItemName(removeId).toLowerCase() + " to this store.");
|
||||||
} else {
|
} else {
|
||||||
int ShopValue = (int) Math.floor(getItemShopValue(unNotedItemID, 1, true));
|
int ShopValue = (int) Math.floor(getItemShopValue(unNotedItemID, 1, true));
|
||||||
@@ -468,7 +468,7 @@ public class ShopAssistant {
|
|||||||
private static int getUnNoted(int itemID){
|
private static int getUnNoted(int itemID){
|
||||||
String itemName = ItemAssistant.getItemName(itemID).toLowerCase();
|
String itemName = ItemAssistant.getItemName(itemID).toLowerCase();
|
||||||
String ItemNameUnNotedItem = ItemAssistant.getItemName(itemID - 1).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.
|
itemID--; //Replace the noted item by it's un-noted version.
|
||||||
}
|
}
|
||||||
return itemID;
|
return itemID;
|
||||||
@@ -477,7 +477,7 @@ public class ShopAssistant {
|
|||||||
private static int getNoted(int itemID){
|
private static int getNoted(int itemID){
|
||||||
String itemName = ItemAssistant.getItemName(itemID).toLowerCase();
|
String itemName = ItemAssistant.getItemName(itemID).toLowerCase();
|
||||||
String ItemNameUnNotedItem = ItemAssistant.getItemName(itemID + 1).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.
|
itemID++; //Replace the item by it's noted version.
|
||||||
}
|
}
|
||||||
return itemID;
|
return itemID;
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ public class ShopHandler {
|
|||||||
|
|
||||||
public static int MAX_SHOP_ITEMS = 40;
|
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;
|
public static int totalshops = 0;
|
||||||
|
|
||||||
@@ -106,11 +106,13 @@ public class ShopHandler {
|
|||||||
shopItemsN[shopID][ArrayID] -= 1;
|
shopItemsN[shopID][ArrayID] -= 1;
|
||||||
if (shopItemsN[shopID][ArrayID] <= 0) {
|
if (shopItemsN[shopID][ArrayID] <= 0) {
|
||||||
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) {
|
private static void ResetItem(int shopID, int ArrayID) {
|
||||||
|
if (shopItemsStandard[shopID] > ArrayID) return;
|
||||||
shopItems[shopID][ArrayID] = 0;
|
shopItems[shopID][ArrayID] = 0;
|
||||||
shopItemsN[shopID][ArrayID] = 0;
|
shopItemsN[shopID][ArrayID] = 0;
|
||||||
shopItemsDelay[shopID][ArrayID] = 0;
|
shopItemsDelay[shopID][ArrayID] = 0;
|
||||||
@@ -143,19 +145,19 @@ public class ShopHandler {
|
|||||||
token = line.substring(0, spot);
|
token = line.substring(0, spot);
|
||||||
token = token.trim();
|
token = token.trim();
|
||||||
token2 = line.substring(spot + 1);
|
token2 = line.substring(spot + 1);
|
||||||
token2 = token2.trim();
|
token3 = token2.trim().split("\t+");
|
||||||
token2_2 = token2.replaceAll("\t+", "\t");
|
|
||||||
token3 = token2_2.split("\t");
|
|
||||||
if (token.equals("shop")) {
|
if (token.equals("shop")) {
|
||||||
int shopID = Integer.parseInt(token3[0]);
|
int shopID = Integer.parseInt(token3[0]);
|
||||||
shopName[shopID] = token3[1].replaceAll("_", " ");
|
shopName[shopID] = token3[1].replaceAll("_", " ");
|
||||||
shopSModifier[shopID] = Integer.parseInt(token3[2]);
|
shopSModifier[shopID] = Integer.parseInt(token3[2]);
|
||||||
shopBModifier[shopID] = Integer.parseInt(token3[3]);
|
shopBModifier[shopID] = Integer.parseInt(token3[3]);
|
||||||
for (int i = 0; i < ((token3.length - 4) / 2); i++) {
|
for (int i = 0; i < ((token3.length - 4) / 2); i++) {
|
||||||
if (token3[(4 + (i * 2))] != null) {
|
int itemID = Integer.parseInt(token3[(4 + (i * 2))]);
|
||||||
shopItems[shopID][i] = (Integer.parseInt(token3[(4 + (i * 2))]) + 1);
|
int itemAmount = Integer.parseInt(token3[(5 + (i * 2))]);
|
||||||
shopItemsN[shopID][i] = Integer.parseInt(token3[(5 + (i * 2))]);
|
if (itemID > 0) {
|
||||||
shopItemsSN[shopID][i] = Integer.parseInt(token3[(5 + (i * 2))]);
|
shopItems[shopID][i] = itemID + 1;
|
||||||
|
shopItemsN[shopID][i] = itemAmount;
|
||||||
|
shopItemsSN[shopID][i] = itemAmount;
|
||||||
shopItemsStandard[shopID]++;
|
shopItemsStandard[shopID]++;
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
@@ -164,7 +166,7 @@ public class ShopHandler {
|
|||||||
totalshops++;
|
totalshops++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (line.equals("[ENDOFshopLIST]")) {
|
if (line.equalsIgnoreCase("[ENDOFSHOPLIST]")) {
|
||||||
try {
|
try {
|
||||||
characterfile.close();
|
characterfile.close();
|
||||||
} catch (IOException ioexception) {
|
} catch (IOException ioexception) {
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user