diff --git a/2006Redone Server/src/redone/game/bots/Bot.java b/2006Redone Server/src/redone/game/bots/Bot.java index 068fad70..f43e2b24 100644 --- a/2006Redone Server/src/redone/game/bots/Bot.java +++ b/2006Redone Server/src/redone/game/bots/Bot.java @@ -66,8 +66,8 @@ public class Bot { } int item_id = Misc.randomArrayListItem(items); String item_name = ItemAssistant.getItemName(item_id); - int value = botClient.getShopAssistant().getItemShopValue(item_id); - botClient.forcedChat("Selling " + item_name + " " + GameLogger.formatCurrency(value) + "ea"); + int value = Math.max(1, botClient.getShopAssistant().getItemShopValue(item_id, 0, false)); + botClient.forcedChat("Selling " + item_name + " " + formatSellPrice(value) + " ea"); /* Real chat - Disabled for now, can't get it to function correctly @@ -80,4 +80,16 @@ public class Bot { botClient.setChatTextUpdateRequired(true); */ } + + private String formatSellPrice(int price) { + if (price > 1e9) { + return (Math.floor(price / 1e8) / 10) + "B"; + } else if (price > 1e6) { + return (Math.floor(price / 1e8) / 10) + "M"; + } else if (price > 1e3) { + return (Math.floor(price / 100) / 10) + "K"; + } else { + return "" + price; + } + } } diff --git a/2006Redone Server/src/redone/game/bots/BotHandler.java b/2006Redone Server/src/redone/game/bots/BotHandler.java index b8f0c0c8..9e7d6bea 100644 --- a/2006Redone Server/src/redone/game/bots/BotHandler.java +++ b/2006Redone Server/src/redone/game/bots/BotHandler.java @@ -66,12 +66,24 @@ public class BotHandler return null; } - public static void addTobank(int shop, int item, int itemN){ + public static void addTobank(int shop_id, int item_id, int amount){ for(Bot bot : botList) { if(bot != null && bot.getBotClient() != null) { Client botClient = bot.getBotClient(); - if(botClient.myShopId == shop) { - botClient.getItemAssistant().addItemToBank(item, itemN); + if(botClient.myShopId == shop_id) { + botClient.getItemAssistant().addItemToBank(item_id, amount); + return; + } + } + } + } + + public static void removeFrombank(int shop_id, int item_id, int amount){ + for(Bot bot : botList) { + if(bot != null && bot.getBotClient() != null) { + Client botClient = bot.getBotClient(); + if(botClient.myShopId == shop_id) { + botClient.getItemAssistant().removeitemFromBank(item_id, amount); return; } } diff --git a/2006Redone Server/src/redone/game/items/ItemAssistant.java b/2006Redone Server/src/redone/game/items/ItemAssistant.java index 9eae7446..f136c80e 100644 --- a/2006Redone Server/src/redone/game/items/ItemAssistant.java +++ b/2006Redone Server/src/redone/game/items/ItemAssistant.java @@ -227,9 +227,10 @@ public class ItemAssistant { } public void addItemToBank(int itemId, int amount) { + itemId++; for (int i = 0; i < Constants.BANK_SIZE; i++) { - if (c.bankItems[i] <= 0 || c.bankItems[i] == itemId + 1 && c.bankItemsN[i] + amount < Integer.MAX_VALUE) { - c.bankItems[i] = itemId + 1; + if (c.bankItems[i] <= 0 || c.bankItems[i] == itemId && c.bankItemsN[i] + amount < Integer.MAX_VALUE) { + c.bankItems[i] = itemId; c.bankItemsN[i] += amount; resetBank(); return; @@ -237,6 +238,22 @@ public class ItemAssistant { } } + public void removeitemFromBank(int itemId, int amount) { + itemId++; + for (int i = 0; i < Constants.BANK_SIZE; i++) { + if (c.bankItems[i] == itemId) { + c.bankItemsN[i] -= amount; + if (c.bankItemsN[i] <= 0) { + c.bankItems[i] = 0; + c.bankItemsN[i] = 0; + } + resetBank(); + rearrangeBank(); + return; + } + } + } + public void resetItems(int WriteFrame) { // synchronized(c) { if (c.getOutStream() != null && c != null) { diff --git a/2006Redone Server/src/redone/game/shops/ShopAssistant.java b/2006Redone Server/src/redone/game/shops/ShopAssistant.java index 2905faed..577e1001 100644 --- a/2006Redone Server/src/redone/game/shops/ShopAssistant.java +++ b/2006Redone Server/src/redone/game/shops/ShopAssistant.java @@ -103,26 +103,22 @@ public class ShopAssistant { double ShopValue = 1; double TotPrice = 0; double sellingRatio = isSelling ? 0.85 : 1; - for (int i = 0; i < Constants.ITEM_LIMIT; i++) { - if (ItemDefinitions.getDef()[i] != null) { - ShopValue = ItemDefinitions.getDef()[ItemID].highAlch/3.0 *5.0 * sellingRatio; - } + if (ItemDefinitions.getDef()[ItemID] != null) { + ShopValue = ItemDefinitions.getDef()[ItemID].highAlch / 3.0 * 5.0 * sellingRatio; } TotPrice = ShopValue; - // General store + // General store pays less for items if (isSelling && ShopHandler.ShopBModifier[player.myShopId] == 1) { TotPrice *= 0.90; - } else if (Type == 1) { - TotPrice *= 1; } // Minimum value of 1 return (int) Math.max(1, Math.floor(TotPrice)); } public int getItemShopValue(int itemId) { - return (int) ItemDefinitions.getDef()[itemId].highAlch/3 *5; + return getItemShopValue(itemId, 0, false); } @@ -533,7 +529,9 @@ public class ShopAssistant { player.getItemAssistant().deleteItem2(currency, totalValue); player.getItemAssistant().addItem(itemID, amount); ShopHandler.buyItem(shopID, itemID, amount); - ShopHandler.refreshShop(shopID); + if (ShopHandler.ShopBModifier[shopID] == 0){ + BotHandler.removeFrombank(shopID, itemID, amount); + } player.getActionSender().sendMessage("You bought " + amount + " " + ItemAssistant.getItemName(itemID).toLowerCase() + " for " + totalValue + " " + ItemAssistant.getItemName(currency).toLowerCase() + "." ); String itemName = ItemAssistant.getItemName(itemID).toLowerCase(); diff --git a/CompiledServer/production/2006rebotted/redone/game/bots/Bot.class b/CompiledServer/production/2006rebotted/redone/game/bots/Bot.class index c1c1b555..83693049 100644 Binary files a/CompiledServer/production/2006rebotted/redone/game/bots/Bot.class and b/CompiledServer/production/2006rebotted/redone/game/bots/Bot.class differ diff --git a/CompiledServer/production/2006rebotted/redone/game/bots/BotHandler.class b/CompiledServer/production/2006rebotted/redone/game/bots/BotHandler.class index 7ad1607a..1698d044 100644 Binary files a/CompiledServer/production/2006rebotted/redone/game/bots/BotHandler.class and b/CompiledServer/production/2006rebotted/redone/game/bots/BotHandler.class differ diff --git a/CompiledServer/production/2006rebotted/redone/game/items/ItemAssistant.class b/CompiledServer/production/2006rebotted/redone/game/items/ItemAssistant.class index 11343921..e11b29ca 100644 Binary files a/CompiledServer/production/2006rebotted/redone/game/items/ItemAssistant.class and b/CompiledServer/production/2006rebotted/redone/game/items/ItemAssistant.class differ diff --git a/CompiledServer/production/2006rebotted/redone/game/shops/ShopAssistant.class b/CompiledServer/production/2006rebotted/redone/game/shops/ShopAssistant.class index 3a3a471e..0a43f5f3 100644 Binary files a/CompiledServer/production/2006rebotted/redone/game/shops/ShopAssistant.class and b/CompiledServer/production/2006rebotted/redone/game/shops/ShopAssistant.class differ