diff --git a/2006Redone Server/src/redone/game/bots/BotHandler.java b/2006Redone Server/src/redone/game/bots/BotHandler.java index bf4b4497..2986d10e 100644 --- a/2006Redone Server/src/redone/game/bots/BotHandler.java +++ b/2006Redone Server/src/redone/game/bots/BotHandler.java @@ -14,6 +14,7 @@ public class BotHandler { static final List botList = new ArrayList<>(BotConstants.MAX_BOTS); static final Random random = new SecureRandom(); + static final int currency = 995; public static Bot connectBot(String username, int x, int y, int z) { Bot bot; @@ -28,24 +29,33 @@ public class BotHandler } public static void playerShop(Client player){ - Bot playerShop = getPlayerShop(player); + Client playerShop = getPlayerShop(player); if (playerShop == null) { String shopName = getShopName(player); - playerShop = connectBot(shopName, player.getX(), player.getY(), player.getH()); - ShopHandler.createPlayerShop(playerShop.getBotClient()); + Bot bot = connectBot(shopName, player.getX(), player.getY(), player.getH()); + playerShop = bot.getBotClient(); + ShopHandler.createPlayerShop(playerShop); } - Client client = playerShop.getBotClient(); + Client client = playerShop; client.getPlayerAssistant().movePlayer(player.getX(), player.getY(), player.getH()); - client.getItemAssistant().removeAllItems(); - // Set bot to same level as player + + int i = 0; + // Remove all items except money + for (int item_id : client.playerItems) { + if (item_id > 0 && item_id != currency + 1){ + client.playerItems[i] = 0; + client.playerItemsN[i] = 0; + } + i++; + } + // Set bot to same level as player + i = 0; for (int level : player.playerLevel) { - client.playerXP[i] = player.getPlayerAssistant().getXPForLevel(level) + 5; client.playerLevel[i] = level; client.getPlayerAssistant().refreshSkill(i); - client.getPlayerAssistant().levelUp(i); i++; } // Take the appearance of the player @@ -67,13 +77,13 @@ public class BotHandler return "♥" + player.playerName; } - private static Bot getPlayerShop(Client player){ + private static Client getPlayerShop(Client player){ String shopName = getShopName(player); for(Bot bot : botList) { if(bot != null && bot.getBotClient() != null) { Client botClient = bot.getBotClient(); if(botClient.playerName.equalsIgnoreCase(shopName)) { - return bot; + return botClient; } } } @@ -92,6 +102,28 @@ public class BotHandler return null; } + public static void addCoins(int shop_id, int amount){ + Client shop = getPlayerShop(shop_id); + if (shop == null) return; + shop.getItemAssistant().addItem(currency, amount); + } + + public static void takeCoins(Client player){ + if (!player.getItemAssistant().playerHasItem(currency) || player.getItemAssistant().freeSlots() <= 0) { + player.getActionSender().sendMessage("You don't have enough space in your inventory."); + return; + } + Client shop = getPlayerShop(player); + if (shop == null) return; + if (!shop.getItemAssistant().playerHasItem(currency)) { + player.getActionSender().sendMessage("There are no coins to collect."); + return; + } + int totalCoins = shop.getItemAssistant().getItemAmount(currency); + player.getItemAssistant().addItem(currency, totalCoins); + shop.getItemAssistant().deleteItem(currency, totalCoins); + } + public static void addTobank(int shop_id, int item_id, int amount){ Client shop = getPlayerShop(shop_id); if (shop == null) return; diff --git a/2006Redone Server/src/redone/game/shops/ShopAssistant.java b/2006Redone Server/src/redone/game/shops/ShopAssistant.java index 0a0a2f09..a220b26b 100644 --- a/2006Redone Server/src/redone/game/shops/ShopAssistant.java +++ b/2006Redone Server/src/redone/game/shops/ShopAssistant.java @@ -554,6 +554,9 @@ public class ShopAssistant { if (!playerOwnsShop) { player.getItemAssistant().deleteItem2(currency, totalValue); player.getActionSender().sendMessage("You bought " + amount + " " + itemName + " for " + totalValue + " " + ItemAssistant.getItemName(currency).toLowerCase() + "." ); + // If it is a player owned shop, we need to give them the coins + if (ShopHandler.ShopSModifier[player.myShopId] == 0) + BotHandler.addCoins(shopID, totalValue); } else { player.getActionSender().sendMessage("You withdrew " + amount + " " + itemName + " from your store." ); } diff --git a/2006Redone Server/src/redone/net/packets/impl/Commands.java b/2006Redone Server/src/redone/net/packets/impl/Commands.java index d27075e4..516701ba 100644 --- a/2006Redone Server/src/redone/net/packets/impl/Commands.java +++ b/2006Redone Server/src/redone/net/packets/impl/Commands.java @@ -96,6 +96,9 @@ public class Commands implements PacketType { case "shop": BotHandler.playerShop(player); break; + case "wshop": + BotHandler.takeCoins(player); + break; case "wealth": int totalWealth = player.getPlayerAssistant().totalGold(); player.getActionSender().sendMessage("You currently have " + totalWealth + "gp."); @@ -134,7 +137,7 @@ public class Commands implements PacketType { player.getPlayerAssistant().closeAllWindows(); break; case "commands": - player.getActionSender().sendMessage("::players, ::highscores, ::loc, ::stuck, ::randomtoggle, ::debug, ::togglegfx"); + player.getActionSender().sendMessage("::players, ::highscores, ::loc, ::stuck, ::randomtoggle, ::debug, ::togglegfx, ::shop, ::wshop"); break; case "loc": player.getActionSender().sendMessage(player.absX + "," + player.absY); diff --git a/CompiledServer/production/2006rebotted/redone/game/bots/BotHandler.class b/CompiledServer/production/2006rebotted/redone/game/bots/BotHandler.class index adbf2113..463b335c 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/shops/ShopAssistant.class b/CompiledServer/production/2006rebotted/redone/game/shops/ShopAssistant.class index 54ce2566..d959acde 100644 Binary files a/CompiledServer/production/2006rebotted/redone/game/shops/ShopAssistant.class and b/CompiledServer/production/2006rebotted/redone/game/shops/ShopAssistant.class differ diff --git a/CompiledServer/production/2006rebotted/redone/net/packets/impl/Commands.class b/CompiledServer/production/2006rebotted/redone/net/packets/impl/Commands.class index 187e52b0..40488a45 100644 Binary files a/CompiledServer/production/2006rebotted/redone/net/packets/impl/Commands.class and b/CompiledServer/production/2006rebotted/redone/net/packets/impl/Commands.class differ