Non-spammy player shops (#407)

* Add check that players are over total level 50, but shop items check is broken

* Bots now only appear when they meet reqs! Woot!
This commit is contained in:
Daniel Ginovker
2020-08-03 13:28:43 -04:00
committed by GitHub
parent 707783552f
commit 1a911f1ad0
5 changed files with 28 additions and 3 deletions
@@ -10,7 +10,7 @@ public class GameConstants {
public final static int ITEM_LIMIT = 15000, MAXITEM_AMOUNT = Integer.MAX_VALUE, CLIENT_VERSION = 999999,
WORLD = 1, IPS_ALLOWED = 250, CONNECTION_DELAY = 100,
MESSAGE_DELAY = 6000, MAX_PLAYERS = 100, REQ_AMOUNT = 150;
MESSAGE_DELAY = 6000, MAX_PLAYERS = 200, REQ_AMOUNT = 150;
public final static boolean SOUND = true,
GUILDS = true, WORLD_LIST_FIX = false,
@@ -35,7 +35,12 @@ public class Bot {
loadPlayerInfo(botClient, username, "bot_password", false);
System.out.println("x is " + x);
if (x == null) {
System.out.println("Bot should be at " + botClient.getX() + ", " + botClient.getY());
}
if (x != null) {
System.out.println("Moving player to " + x + "," + y + "," + z);
botClient.getPlayerAssistant().movePlayer(x, y, z);
}
new TradeChat().run();
@@ -3,6 +3,7 @@ package com.rebotted.game.bots;
import java.io.File;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
@@ -13,6 +14,8 @@ import com.rebotted.game.players.PlayerHandler;
import com.rebotted.game.shops.ShopHandler;
import com.rebotted.util.Misc;
import static com.rebotted.game.players.PlayerSave.loadPlayerInfo;
public class BotHandler {
static final List<Bot> botList = new ArrayList<>(BotConstants.MAX_BOTS);
@@ -39,7 +42,18 @@ public class BotHandler {
if (child.getName().startsWith("")) {
String playerName = child.getName().split("")[1];
playerName = playerName.substring(0, playerName.length() - 4);
System.out.println("Loading " + playerName + " shop");
Client determineIfLoad = new Client(null);
determineIfLoad.playerName = getShopName(playerName);
loadPlayerInfo(determineIfLoad, getShopName(playerName), "bot_password", false);
System.out.println(Arrays.toString(determineIfLoad.bankItemsN));
System.out.println("Bot [" + playerName + "] has totalLevel, bankItems[0]" + determineIfLoad.getPlayerAssistant().getTotalLevel() + ", " + determineIfLoad.bankItemsN[0]);
if (determineIfLoad.getPlayerAssistant().getTotalLevel() < 50 || determineIfLoad.bankItemsN[0] == 0) {
continue;
}
System.out.println("Loading bot " + playerName);
String shopName = getShopName(playerName);
Bot bot = connectBot(shopName, null, null, null);
Client playerShop = bot.getBotClient();
@@ -56,6 +70,7 @@ public class BotHandler {
}
player.getPacketSender().sendMessage("Shop commands- ::shop, ::withdrawshop, ::closeshop");
player.getPacketSender().sendMessage("Your shop will permanently stay if you're total level > 50!");
Client playerShop = getPlayerShop(player.playerName);
@@ -81,9 +96,11 @@ public class BotHandler {
i++;
}
// Set bot to same level as player
playerShop.combatLevel = player.combatLevel;
i = 0;
for (int level : player.playerLevel) {
playerShop.playerLevel[i] = level;
playerShop.playerXP[i] = playerShop.getPlayerAssistant().getXPForLevel(level);
playerShop.getPlayerAssistant().refreshSkill(i);
i++;
}
@@ -27,6 +27,9 @@ public class PlayerSave {
BufferedReader characterfile = null;
boolean File1 = false;
if (player.playerName == null) {
System.out.println("WARNING: called loadPlayerInfo with a Client who does not have a .playerName");
}
try {
characterfile = new BufferedReader(new FileReader(System.getProperty("user.dir") + "/data/characters/" + player.playerName + ".txt"));
File1 = true;
@@ -202,7 +202,7 @@ public class ShopHandler {
private static int getEmptyshop(){
for (int i = 0; i < MAX_SHOPS; i++) {
if (shopName[i] == "") return i;
if (shopName[i].equals("")) return i;
}
return -1;
}