├── .gitignore ├── README.md ├── build.xml ├── lib ├── CopyLibs │ └── org-netbeans-modules-java-j2seproject-copylibstask.jar ├── Discord4J-2.4.7-Javadoc.jar ├── Discord4J-2.4.7-Sources.jar ├── Discord4J-2.4.7.jar ├── PircBot2.jar ├── commons-logging-1.2.jar ├── httpclient-4.4.1.jar ├── httpcore-4.4.1.jar ├── nblibraries.properties ├── slf4j-api-1.7.19.jar └── slf4j-simple-1.7.19.jar ├── manifest.mf └── src └── TPPDekuBot ├── Ability.java ├── Battle.java ├── BattleBot.java ├── BattleBotMusic.java ├── BattleTester.java ├── ExpLevel.java ├── Gender.java ├── GymBadge.java ├── GymLeader.java ├── Item.java ├── Move.java ├── MoveCategory.java ├── MoveEffect.java ├── MoveImporter.java ├── MultiplayerBattle.java ├── PWTBattle.java ├── PWTRound.java ├── PWTType.java ├── PWTournament.java ├── Pokeball.java ├── Pokemon.java ├── PokemonBaseStat.java ├── PokemonBattle.java ├── Region.java ├── SafariBattle.java ├── Stats.java ├── Status.java ├── Trainer.java ├── Type.java └── Weather.java /.gitignore: -------------------------------------------------------------------------------- 1 | /src/TPPDekuBot/BattleBotRunner.java 2 | /build/ 3 | /src/TPPDekuBot/Test.java 4 | *.wdu 5 | /src/TPPDekuBot/PokemonImporter.java 6 | nbproject/private/private.xml 7 | /nbproject/ 8 | nbproject/ 9 | nbproject/project.properties 10 | nbproject/private/private.properties 11 | nbproject/genfiles.properties 12 | nbproject/build-impl.xml 13 | /src/TPPDekuBot/MoveExporter.java 14 | /dist/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WowBattleBot 2 | An IRC Bot that can play Pokemon 3 | 4 | # Why am I here? 5 | Welcome to Battle Dungeon! Chances are you were invited by an automated script ran by someone else. Me and my bot did not invite you (unless you were challenged to a Battle, then you were invited by the bot) 6 | 7 | # Music 8 | To listen to the music feature, go here https://discord.gg/0uMaFWa51QM5My1E and join the Voice Channel. 9 | 10 | # Commands 11 | Command parameters with `<>` are required, parameters with `[]` are optional. Commands seperated by a `|` do the same thing. Only one battle can be going on at any given time. 12 | 13 | | Command | Purpose | 14 | | ------------- | ------------- | 15 | | `!battle` | Puts you in a battle with a Random Pokemon and gives you a Random Pokemon to fight. | 16 | | `!randbat <@username> [num]` | Challenges `username` to a battle. Change `num` to a number between 1 and 6 for a Multi-Pokemon battle. | 17 | | `!safari` | Puts you in a Safari battle with a Random pokemon. Gives you a rock, bait, and Pokeballs to catch the random Pokemon. | 18 | | `!pwt` | Starts a Pokemon World Tournament. In the future, there will be more options for this, but for right now this defaults to a `Random` `8-player` Pokemon World Tournament.| 19 | | `!join` | Joins a Pokemon World Tournament during the joining phase. Only the first four people who join as of right now will get in. | 20 | | `!changeclass | !switchclass `| Changes your Trainer Class. Cannot be "Gym Leader", "Champion", "Elite Four" or any other protected class. 21 | | `!list` | Gets a list of your current Pokemon in battles with more than 1 Pokemon per team. Only works in Battle. | 22 | | `!switch` | Switches your Pokemon to the `number` specified. `number` is gotten from the `!list` command. | 23 | | `!check` | Checks the Pokemon `number` specified. `number` is gotten from the `!list` command. | 24 | | `!move` | Uses the Move from your Pokemon against your opponent. | 25 | | `!run` | Forefeits the current battle. If in a Wild Pokemon battle, if the Wild Pokemon outspeeds your Pokemon, the Wild Pokemon will attack before you run.| 26 | # Capturing Pokemon 27 | 28 | As of right now, it's not possible to capture Pokemon during battle. In Safari battles, you can capture Pokemon, however, any Pokemon caught are not saved. This will change in the future. 29 | 30 | 31 | # Authors and Contributors 32 | 33 | Original Program created by the_chef1337. frumpy4 has contributed significanty. 34 | 35 | Feel free to add/modify/fix the code above. 36 | 37 | # Bots 38 | 39 | If you would like, you can code a bot that can respond to matches through the `!randbat` command. If you have a favorite language, even if it is not Java, go ahead and code a bot and get in contact with the_chef1337 on Twitch. 40 | 41 | 42 | These bots can be challenged with the `!randbat` command: 43 | 44 | 45 | | Bot Name | Trainer Class | Creator | 46 | | ------------- | ------------- | ------------- | 47 | | frunky5 | Gym Leader | walle303 | 48 | | 23forces | Elite Four | frumpy4 | 49 | | groudonger | Gym Leader | chfoo | 50 | 51 | If you defeat any of these bots with the Gym Leader trainer class, in the future you will receive a Gym Badge. These are currently not implemented just yet, but will be in the future. 52 | -------------------------------------------------------------------------------- /build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Builds, tests, and runs the project WowBattleBot. 12 | 13 | 73 | 74 | -------------------------------------------------------------------------------- /lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheChef1337/WowBattleBot/fd2beb55a02a0102935844bff3f9be353039c7d9/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar -------------------------------------------------------------------------------- /lib/Discord4J-2.4.7-Javadoc.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheChef1337/WowBattleBot/fd2beb55a02a0102935844bff3f9be353039c7d9/lib/Discord4J-2.4.7-Javadoc.jar -------------------------------------------------------------------------------- /lib/Discord4J-2.4.7-Sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheChef1337/WowBattleBot/fd2beb55a02a0102935844bff3f9be353039c7d9/lib/Discord4J-2.4.7-Sources.jar -------------------------------------------------------------------------------- /lib/Discord4J-2.4.7.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheChef1337/WowBattleBot/fd2beb55a02a0102935844bff3f9be353039c7d9/lib/Discord4J-2.4.7.jar -------------------------------------------------------------------------------- /lib/PircBot2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheChef1337/WowBattleBot/fd2beb55a02a0102935844bff3f9be353039c7d9/lib/PircBot2.jar -------------------------------------------------------------------------------- /lib/commons-logging-1.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheChef1337/WowBattleBot/fd2beb55a02a0102935844bff3f9be353039c7d9/lib/commons-logging-1.2.jar -------------------------------------------------------------------------------- /lib/httpclient-4.4.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheChef1337/WowBattleBot/fd2beb55a02a0102935844bff3f9be353039c7d9/lib/httpclient-4.4.1.jar -------------------------------------------------------------------------------- /lib/httpcore-4.4.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheChef1337/WowBattleBot/fd2beb55a02a0102935844bff3f9be353039c7d9/lib/httpcore-4.4.1.jar -------------------------------------------------------------------------------- /lib/nblibraries.properties: -------------------------------------------------------------------------------- 1 | libs.CopyLibs.classpath=\ 2 | ${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar 3 | libs.CopyLibs.displayName=CopyLibs Task 4 | libs.CopyLibs.prop-version=2.0 5 | -------------------------------------------------------------------------------- /lib/slf4j-api-1.7.19.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheChef1337/WowBattleBot/fd2beb55a02a0102935844bff3f9be353039c7d9/lib/slf4j-api-1.7.19.jar -------------------------------------------------------------------------------- /lib/slf4j-simple-1.7.19.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheChef1337/WowBattleBot/fd2beb55a02a0102935844bff3f9be353039c7d9/lib/slf4j-simple-1.7.19.jar -------------------------------------------------------------------------------- /manifest.mf: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | X-COMMENT: Main-Class will be added automatically by build 3 | 4 | -------------------------------------------------------------------------------- /src/TPPDekuBot/Ability.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package TPPDekuBot; 7 | 8 | /** 9 | * 10 | * @author Michael 11 | */ 12 | enum ABILITY{ 13 | 14 | } 15 | public abstract class Ability { 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/TPPDekuBot/Battle.java: -------------------------------------------------------------------------------- 1 | package TPPDekuBot; 2 | 3 | public abstract class Battle { 4 | 5 | private Move lastMoveTeam1; 6 | private Move lastMoveTeam2; 7 | private Move delayedMove; 8 | private Weather weather = Weather.NORMAL; 9 | public BattleBot b; 10 | 11 | Battle(BattleBot b) { 12 | this.b = b; 13 | } 14 | 15 | public Move getLastMoveTeam1() { 16 | return lastMoveTeam1; 17 | } 18 | 19 | public Move getLastMoveTeam2() { 20 | return lastMoveTeam2; 21 | } 22 | 23 | public Weather getWeather() { 24 | return weather; 25 | } 26 | 27 | public void setWeather(Weather weather) { 28 | this.weather = weather; 29 | } 30 | 31 | public void setLastMoveTeam1(Move lastMoveTeam1) { 32 | this.lastMoveTeam1 = lastMoveTeam1; 33 | } 34 | 35 | public void setLastMoveTeam2(Move lastMoveTeam2) { 36 | this.lastMoveTeam2 = lastMoveTeam2; 37 | } 38 | 39 | public Move getDelayedMove() { 40 | return delayedMove; 41 | } 42 | 43 | public void setDelayedMove(Move delayedMove) { 44 | this.delayedMove = delayedMove; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/TPPDekuBot/BattleBotMusic.java: -------------------------------------------------------------------------------- 1 | package TPPDekuBot; 2 | 3 | import java.io.File; 4 | import sx.blah.discord.api.*; 5 | import sx.blah.discord.handle.impl.events.ReadyEvent; 6 | import sx.blah.discord.handle.obj.*; 7 | import sx.blah.discord.util.DiscordException; 8 | import sx.blah.discord.util.MessageBuilder; 9 | 10 | public class BattleBotMusic { 11 | 12 | private IDiscordClient client; 13 | private boolean isVoiceReady = false; 14 | private IVoiceChannel voice; 15 | private IChannel channel; 16 | public IUser CHEF; 17 | private String nowPlaying = ""; 18 | private BattleBot b; 19 | 20 | public BattleBotMusic(String email, String password, BattleBot b) throws DiscordException { 21 | ClientBuilder clientBuilder = new ClientBuilder(); 22 | clientBuilder.withLogin(email, password); 23 | this.client = clientBuilder.login(); 24 | this.b = b; 25 | EventDispatcher dispatcher = client.getDispatcher(); 26 | dispatcher.registerListener(this); 27 | } 28 | 29 | @EventSubscriber 30 | public void onReady(ReadyEvent event) { 31 | IGuild guild = client.getGuildByID("162752501131640832"); 32 | channel = client.getChannelByID("162752501131640832"); 33 | voice = guild.getVoiceChannelByID("162752501131640833"); 34 | voice.join(); 35 | try { 36 | voice.getAudioChannel().setVolume(0.25F); 37 | } catch (Exception ex) { 38 | } 39 | isVoiceReady = true; 40 | CHEF = client.getGuildByID("162752501131640832").getUserByID("94696943652966400"); 41 | } 42 | 43 | public void play(File file) { 44 | if (file == null) { 45 | System.err.println("File null"); 46 | return; 47 | } 48 | if (file.exists()) { 49 | try { 50 | if (b.playingVictoryPWT) { 51 | b.playingVictoryPWT = false; 52 | voice.getAudioChannel().clearQueue(); 53 | } 54 | voice.getAudioChannel().queueFile(file); 55 | nowPlaying = file.getName(); 56 | } catch (Exception ex) { 57 | 58 | } 59 | } else { 60 | System.err.println("File not found: " + file.getAbsolutePath()); 61 | } 62 | } 63 | 64 | public void skip() { 65 | try { 66 | voice.getAudioChannel().skip(); 67 | } catch (Exception ex) { 68 | 69 | } 70 | } 71 | 72 | public void clear() { 73 | try { 74 | voice.getAudioChannel().clearQueue(); 75 | nowPlaying = ""; 76 | } catch (Exception ex) { 77 | } 78 | } 79 | 80 | public String getNowPlaying() { 81 | return nowPlaying; 82 | } 83 | 84 | public void sendMessage(IChannel channel, String message) { 85 | try { 86 | new MessageBuilder(client).withChannel(channel).withContent(message).build(); 87 | System.out.println(System.currentTimeMillis() + " >>>DISCORD to " + channel.getName() + " :" + message); 88 | } catch (Exception e) { 89 | e.printStackTrace(); 90 | } 91 | } 92 | 93 | public IChannel getChannel() { 94 | return channel; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/TPPDekuBot/BattleTester.java: -------------------------------------------------------------------------------- 1 | package TPPDekuBot; 2 | 3 | import java.io.FileInputStream; 4 | import java.io.ObjectInputStream; 5 | import java.util.*; 6 | 7 | public class BattleTester { 8 | 9 | public static void main(String[] args) { 10 | BattleBot.BASE_PATH = "D:\\a\\Wow_Deku\\"; 11 | Pokemon user = new Pokemon(384, 79); 12 | Pokemon computer = new Pokemon(594, 38); 13 | int levelBefore = computer.getLevel(); 14 | int exp = Pokemon.calculateExperience(true, computer, user); 15 | computer.addExperience(exp); 16 | int levelAfter = computer.getLevel(); 17 | //b.sendMessage(channel, pokemon1.getName() + " fainted! " + pokemon2.getName() + " gained " + exp + " Exp. Points!"); 18 | if (levelBefore < levelAfter) { 19 | //b.sendMessage(channel, pokemon2.getName() + " grew to Level " + levelAfter + "! PogChamp"); 20 | } 21 | //b.sendMessage(channel, "What Pokemon will " + player1.getTrainerName() + " switch to?"); 22 | 23 | // // ArrayList possibleMoves = Pokemon.getCompatableMoves(665); 24 | // // System.out.println("User moves = "+possibleMoves); 25 | // // possibleMoves = Pokemon.getCompatableMoves(420); 26 | // // System.out.println("Computer moves = "+possibleMoves); 27 | // user.assignMoves(); 28 | // computer.assignMoves(); 29 | // System.err.println("User = " + user.getMove1().getName() + ", " + user.getMove2().getName() + ", " + user.getMove3().getName() + ", " + user.getMove4().getName() + "\nComputer = " + computer.getMove1().getName() + ", " + computer.getMove2().getName() + ", " + computer.getMove3().getName() + ", " + computer.getMove4().getName()); 30 | // System.out.println("A wild " + computer.getName() + " (level " + computer.getLevel() + ") appeared! Go " + user.getName() + "! (Level " + user.getLevel() + ")"); 31 | // while (!user.isFainted() && !computer.isFainted()) { 32 | // if (user.getStat(Stats.SPEED) > computer.getStat(Stats.SPEED)) { 33 | // System.out.println(user.attack(computer, Move.selectBestMove(user, computer)) + "\n---"); 34 | // if (!computer.isFainted()) { 35 | // System.out.println(computer.attack(user, Move.selectBestMove(computer, user)) + "\n---"); 36 | // } 37 | // } else if (user.getStat(Stats.SPEED) < computer.getStat(Stats.SPEED)) { 38 | // System.out.println(computer.attack(user, Move.selectBestMove(computer, user)) + "\n---"); 39 | // if (!user.isFainted()) { 40 | // System.out.println(user.attack(computer, Move.selectBestMove(user, computer)) + "\n---"); 41 | // } 42 | // } else { 43 | // System.out.println(user.attack(computer, Move.selectBestMove(user, computer)) + "\n---"); 44 | // if (!computer.isFainted()) { 45 | // System.out.println(computer.attack(user, Move.selectBestMove(user, computer)) + "\n---"); 46 | // } 47 | // } 48 | // } 49 | // if (user.isFainted()) { 50 | // System.out.println("You lose!"); 51 | // } else { 52 | // System.out.println("You win!"); 53 | // } 54 | } 55 | 56 | private static HashMap> reloadPokemonMoveList() { 57 | try (FileInputStream fileIn = new FileInputStream(BattleBot.BASE_PATH + "/pokemonMovesList.dat"); ObjectInputStream in = new ObjectInputStream(fileIn)) { 58 | HashMap> pokemon = (HashMap>) in.readObject(); 59 | return pokemon; 60 | } catch (Exception ex) { 61 | System.err.println("[WARNING] Failed to read the Pokemon Moves list!! " + ex); 62 | return null; 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/TPPDekuBot/ExpLevel.java: -------------------------------------------------------------------------------- 1 | package TPPDekuBot; 2 | 3 | import java.io.*; 4 | import java.util.HashMap; 5 | 6 | public enum ExpLevel { 7 | 8 | SLOW, MEDIUM_SLOW, MEDIUM_FAST, FAST, ERRATIC, FLUCTUATING; 9 | 10 | public static int getLevel(int exp/*,ExpLevel explevel*/) { 11 | return (int) Math.cbrt(exp); 12 | } 13 | 14 | public static int getExp(int level) { 15 | return level * level * level; //topkek 16 | } 17 | 18 | public static int getBaseExp(String pokemon) throws Exception { 19 | HashMap baseExp = null; 20 | try (FileInputStream f = new FileInputStream(BattleBot.BASE_PATH + "/pokemonbaseexp.wdu"); ObjectInputStream o = new ObjectInputStream(f)) { 21 | baseExp = (HashMap) o.readObject(); 22 | } catch (Exception ex) { 23 | System.err.println("[ERROR] Error reading file!! " + ex); 24 | throw ex; 25 | } 26 | return baseExp.get(pokemon); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/TPPDekuBot/Gender.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package TPPDekuBot; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * 12 | * @author Michael 13 | */ 14 | public enum Gender implements Serializable{ 15 | MALE,FEMALE,NONE; 16 | } 17 | -------------------------------------------------------------------------------- /src/TPPDekuBot/GymBadge.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package TPPDekuBot; 7 | 8 | /** 9 | * 10 | * @author Michael 11 | */ 12 | public class GymBadge { 13 | 14 | private String givenBy; 15 | private GymBadge.Type type; 16 | 17 | public enum Type { 18 | 19 | BOULDER, CASCADE, THUNDER, RAINBOW, SOUL, MARSH, VOLCANO, EARTH, ZEPHYR, HIVE, PLAIN, FOG, STORM, MINERAL, GLACIER, RISING, STONE, KNUCKLE, DYNAMO, HEAT, BALANCE, FEATHER, MIND, RAIN, COAL, FOREST, COBBLE, FEN, RELIC, MINE, ICICLE, BEACON, TRIO, FREEZE, BASIC, TOXIC, INSECT, BOLT, QUAKE, JET, LEGEND, WAVE, BUG, CLIFF, RUMBLE, PLANT, VOLTAGE, FAIRY, PSYCHIC, ICEBERG; 20 | 21 | @Override 22 | public String toString() { 23 | return this.name().charAt(0) + "" + this.name().substring(1).toLowerCase() + " Badge"; 24 | } 25 | } 26 | 27 | public GymBadge(String givenBy, Type type) { 28 | this.givenBy = givenBy; 29 | this.type = type; 30 | } 31 | 32 | public String getGivenBy() { 33 | return givenBy; 34 | } 35 | 36 | public Type getType() { 37 | return type; 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return type.toString(); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/TPPDekuBot/GymLeader.java: -------------------------------------------------------------------------------- 1 | package TPPDekuBot; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class GymLeader extends Trainer { 6 | 7 | private int prizeMoney; 8 | private GymBadge badge; 9 | private int number; 10 | private boolean isEliteFour; 11 | private boolean isChampion; 12 | 13 | public GymLeader(String name, ArrayList pokemon, ArrayList items, int prizeMoney, GymBadge badge, int number, boolean eliteFour, boolean champion) { 14 | super(name, pokemon, items); 15 | this.prizeMoney = prizeMoney; 16 | this.badge = badge; 17 | this.number = number; 18 | this.isEliteFour = eliteFour; 19 | this.isChampion = champion; 20 | if(isEliteFour){ 21 | this.trnClass = "Elite Four"; 22 | } 23 | if(isChampion){ 24 | this.trnClass = "Champion"; 25 | } 26 | } 27 | 28 | public boolean canChallenge(int numberOfBadges, int eliteFourNumber) { 29 | if (isEliteFour) { 30 | return eliteFourNumber == (number - 1); 31 | } else if (isChampion) { 32 | return (numberOfBadges == 8) && (eliteFourNumber == 4); 33 | } else { 34 | return numberOfBadges == (number - 1); 35 | } 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/TPPDekuBot/Item.java: -------------------------------------------------------------------------------- 1 | package TPPDekuBot; 2 | 3 | public class Item implements Cloneable { 4 | 5 | private ItemType type; 6 | private String name; 7 | 8 | public Item(String name, ItemType type) { 9 | this.name = name; 10 | this.type = type; 11 | } 12 | 13 | @Override 14 | protected Object clone() throws CloneNotSupportedException { 15 | return super.clone(); 16 | } 17 | 18 | } 19 | 20 | enum ItemType { 21 | 22 | BALL, HP, STAT, MAIL, KEY, OTHER; 23 | } 24 | -------------------------------------------------------------------------------- /src/TPPDekuBot/Move.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package TPPDekuBot; 7 | 8 | import java.io.Serializable; 9 | import java.util.HashMap; 10 | import java.util.Objects; 11 | 12 | /** 13 | * 14 | * @author Michael 15 | */ 16 | public /*abstract*/ class Move implements Serializable { 17 | 18 | private String name; 19 | private MoveCategory category; 20 | private Type type; 21 | private MoveEffect effect; 22 | private int power; 23 | private int accuracy; 24 | private int pp; 25 | private int effectChance; 26 | private static final long serialVersionUID = 8484288705595459692L; 27 | 28 | public Move(String name, Type type, MoveCategory category, int power, int accuracy, int pp, MoveEffect effect, int effectChance) { 29 | // Set effect to null for moves without effects 30 | this.name = name; 31 | this.type = type; 32 | this.category = category; 33 | this.power = power; 34 | this.accuracy = accuracy; 35 | this.pp = pp; 36 | this.effect = effect; 37 | this.effectChance = effectChance; 38 | } 39 | 40 | public static boolean isValidMove(String input) { 41 | try { 42 | input = input.toLowerCase(); 43 | input = input.substring(0, 6); 44 | } catch (Exception ex) { 45 | return false; 46 | } 47 | return (input.startsWith("!run") || input.equalsIgnoreCase("!move1") || input.equalsIgnoreCase("!move2") || input.equalsIgnoreCase("!move3") || input.equalsIgnoreCase("!move4")); 48 | } 49 | 50 | public String getName() { 51 | if (name.equalsIgnoreCase("Hidden-Power")) { 52 | return name + " (" + type + ")"; 53 | } 54 | return name; 55 | } 56 | 57 | public int getPP() { 58 | return pp; 59 | } 60 | 61 | public void setPP(int pp) { 62 | this.pp = pp; 63 | } 64 | 65 | public MoveCategory getCategory() { 66 | return category; 67 | } 68 | 69 | public Type getType() { 70 | return type; 71 | } 72 | 73 | public int getPower() { 74 | return power; 75 | } 76 | 77 | public int getAccuracy() { 78 | return accuracy; 79 | } 80 | 81 | public int getEffectChance() { 82 | return effectChance; 83 | } 84 | 85 | public MoveEffect getEffect() { 86 | return effect; 87 | } 88 | 89 | public static Move getMove(Pokemon pokemon, int id) { 90 | Move toReturn = null; 91 | switch (id) { 92 | case 1: 93 | toReturn = pokemon.getMove1(); 94 | break; 95 | case 2: 96 | toReturn = pokemon.getMove2(); 97 | break; 98 | case 3: 99 | toReturn = pokemon.getMove3(); 100 | break; 101 | case 4: 102 | toReturn = pokemon.getMove4(); 103 | break; 104 | } 105 | return toReturn; 106 | 107 | } 108 | 109 | public boolean hasMoveEffect() { 110 | return effect != null; 111 | } 112 | 113 | public static Move selectBestMove(Pokemon user, Pokemon opponent) { 114 | HashMap movesSet = new HashMap<>(); 115 | movesSet.put(1, Pokemon.effectiveness(user.getMove1().getType(), opponent.getType1())); 116 | movesSet.put(2, Pokemon.effectiveness(user.getMove2().getType(), opponent.getType1())); 117 | movesSet.put(3, Pokemon.effectiveness(user.getMove3().getType(), opponent.getType1())); 118 | movesSet.put(4, Pokemon.effectiveness(user.getMove4().getType(), opponent.getType1())); 119 | if (opponent.getType2() != Type.NONE) { 120 | int eff1 = movesSet.get(1), eff2 = movesSet.get(2), eff3 = movesSet.get(3), eff4 = movesSet.get(4); 121 | if (eff1 != 0) { 122 | eff1 += Pokemon.effectiveness(user.getMove1().getType(), opponent.getType2()); 123 | movesSet.replace(1, eff1); 124 | } 125 | if (eff2 != 0) { 126 | eff2 += Pokemon.effectiveness(user.getMove2().getType(), opponent.getType2()); 127 | movesSet.replace(2, eff2); 128 | } 129 | if (eff3 != 0) { 130 | eff3 += Pokemon.effectiveness(user.getMove3().getType(), opponent.getType2()); 131 | movesSet.replace(3, eff3); 132 | } 133 | if (eff4 != 0) { 134 | eff4 += Pokemon.effectiveness(user.getMove4().getType(), opponent.getType2()); 135 | movesSet.replace(4, eff4); 136 | } 137 | } 138 | if (movesSet.get(1) == 0) { 139 | movesSet.remove(1); 140 | } 141 | if (movesSet.get(2) == 0) { 142 | movesSet.remove(2); 143 | } 144 | if (movesSet.get(3) == 0) { 145 | movesSet.remove(3); 146 | } 147 | if (movesSet.get(4) == 0) { 148 | movesSet.remove(4); 149 | } 150 | int mostPowerful = -7; 151 | int power = -7; 152 | for (int el : movesSet.keySet()) { 153 | int movePower = Move.getMove(user, el).getPower() * movesSet.get(el); 154 | if (movePower > power) { 155 | mostPowerful = el; 156 | power = movePower; 157 | } 158 | } 159 | return Move.getMove(user, mostPowerful); 160 | } 161 | 162 | @Override 163 | public int hashCode() { 164 | int hash = 3; 165 | hash = 71 * hash + Objects.hashCode(this.name); 166 | hash = 71 * hash + Objects.hashCode(this.category); 167 | hash = 71 * hash + Objects.hashCode(this.type); 168 | hash = 71 * hash + Objects.hashCode(this.effect); 169 | hash = 71 * hash + this.power; 170 | hash = 71 * hash + this.accuracy; 171 | hash = 71 * hash + this.pp; 172 | hash = 71 * hash + this.effectChance; 173 | return hash; 174 | } 175 | 176 | @Override 177 | public boolean equals(Object obj) { 178 | if (this == obj) { 179 | return true; 180 | } 181 | if (obj == null) { 182 | return false; 183 | } 184 | if (getClass() != obj.getClass()) { 185 | return false; 186 | } 187 | final Move other = (Move) obj; 188 | if (this.power != other.power) { 189 | return false; 190 | } 191 | if (this.accuracy != other.accuracy) { 192 | return false; 193 | } 194 | if (this.pp != other.pp) { 195 | return false; 196 | } 197 | if (this.effectChance != other.effectChance) { 198 | return false; 199 | } 200 | if (!Objects.equals(this.name, other.name)) { 201 | return false; 202 | } 203 | if (this.category != other.category) { 204 | return false; 205 | } 206 | if (this.type != other.type) { 207 | return false; 208 | } 209 | return Objects.equals(this.effect, other.effect); 210 | } 211 | 212 | } 213 | -------------------------------------------------------------------------------- /src/TPPDekuBot/MoveCategory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package TPPDekuBot; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * 12 | * @author Michael 13 | */ 14 | public enum MoveCategory implements Serializable{ 15 | 16 | PHYSICAL, SPECIAL, STATUS; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/TPPDekuBot/MoveEffect.java: -------------------------------------------------------------------------------- 1 | package TPPDekuBot; 2 | 3 | import java.io.Serializable; 4 | import java.security.SecureRandom; 5 | 6 | public interface MoveEffect extends Serializable { 7 | 8 | /** 9 | * Defines a Move Effect for a particular move. 10 | * 11 | * @param user User who used the move. 12 | * @param opponent Opponent who received the move. 13 | * @param damage Damage done to the opponent in terms of HP lost. 14 | * @param move Move used. 15 | * @param battle Battle Object (for getting Weather, user teams, etc) 16 | * @return Text for the BattleBot to return to the user. 17 | */ 18 | String run(Pokemon user, Pokemon opponent, int damage, Move move, Battle battle); 19 | } 20 | 21 | class MoveEffects { 22 | 23 | /** 24 | * Calculates and returns the amount of damage for a specific move. 25 | * 26 | * @param user User Pokemon who is using the move. 27 | * @param opponent Pokemon who is receiving the move. 28 | * @param move Move the User is using. 29 | * @param power Power of the move. Specify this in case of moves that vary 30 | * with power due to certain conditions. 31 | * @param category Move category. 32 | * @param crit Critical Hit or not 33 | * @return Damage move will do. 34 | */ 35 | private static int calcDamage(Pokemon user, Pokemon opponent, Move move, int power, MoveCategory category, boolean crit) { 36 | if (category == MoveCategory.STATUS) { 37 | return 0; 38 | } 39 | SecureRandom rand = new SecureRandom(); 40 | double effectiveness = getEffectiveness(move, opponent); 41 | double stab = 1.0; 42 | if (user.getType1() == move.getType() || user.getType2() == move.getType()) { 43 | stab = 1.5; 44 | } 45 | double critical = crit ? 1.5 : 1; 46 | rand = new SecureRandom(); 47 | double randModifier = 0.85 + (1.0 - 0.85) * rand.nextDouble(); 48 | double modifier = stab * effectiveness * critical * randModifier; 49 | double damageBuf = 0.0; 50 | damageBuf = (2.0 * (double) user.getLevel() + 10.0) / 250.0; 51 | damageBuf = damageBuf * ((double) user.getStat((category == MoveCategory.PHYSICAL) ? Stats.ATTACK : Stats.SP_ATTACK) / (double) user.getStat((category == MoveCategory.PHYSICAL) ? Stats.DEFENSE : Stats.SP_DEFENSE)); 52 | damageBuf = damageBuf * (double) power + 2.0; 53 | damageBuf = (damageBuf * modifier); 54 | int damage = (int) damageBuf; 55 | int damageBuffer = damage; 56 | if (damageBuffer > opponent.getStat(Stats.HP)) { 57 | damageBuffer = opponent.getStat(Stats.HP); 58 | } 59 | return damage; 60 | } 61 | 62 | /** 63 | * Gets the effectiveness of the move against the opponent. 64 | * 65 | * @param move Move being used 66 | * @param opponent Pokemon to apply the move to 67 | * @return >=2 is Super Effective, >0 and <1 is Not Very Effective, 0 is 68 | * No effect, 1 is normal effectiveness. 69 | */ 70 | private static double getEffectiveness(Move move, Pokemon opponent) { 71 | int effective1 = Pokemon.effectiveness(move.getType(), opponent.getType1()); 72 | int effective2 = Pokemon.effectiveness(move.getType(), opponent.getType2()); 73 | double effectiveness = 1.0; 74 | if (effective2 == -5) { 75 | switch (effective1) { 76 | case 0: 77 | effectiveness = 0.0; 78 | break; 79 | case -1: 80 | effectiveness = 0.5; 81 | break; 82 | case 1: 83 | effectiveness = 1.0; 84 | break; 85 | case 2: 86 | effectiveness = 2.0; 87 | break; 88 | default: 89 | effectiveness = 1.0; 90 | break; 91 | } 92 | } else { 93 | switch (effective1) { 94 | case 0: 95 | effectiveness = 0.0; 96 | break; 97 | case -1: 98 | switch (effective2) { 99 | case 0: 100 | effectiveness = 0.0; 101 | break; 102 | case -1: 103 | effectiveness = 0.25; 104 | break; 105 | case 1: 106 | effectiveness = 0.5; 107 | break; 108 | case 2: 109 | effectiveness = 1.0; 110 | break; 111 | } 112 | break; 113 | case 1: 114 | switch (effective2) { 115 | case 0: 116 | effectiveness = 0.0; 117 | break; 118 | case -1: 119 | effectiveness = 0.5; 120 | break; 121 | case 1: 122 | effectiveness = 1.0; 123 | break; 124 | case 2: 125 | effectiveness = 2.0; 126 | break; 127 | } 128 | break; 129 | case 2: 130 | switch (effective2) { 131 | case 0: 132 | effectiveness = 0.0; 133 | break; 134 | case -1: 135 | effectiveness = 1.0; 136 | break; 137 | case 1: 138 | effectiveness = 2.0; 139 | break; 140 | case 2: 141 | effectiveness = 4.0; 142 | break; 143 | } 144 | break; 145 | } 146 | } 147 | return effectiveness; 148 | } 149 | 150 | private static String getEffectivenessText(double effectiveness) { 151 | if (effectiveness >= 2.0) { 152 | return "\nIt's Super Effective!"; 153 | } 154 | if (effectiveness > 0 && effectiveness < 1) { 155 | return "\nIt's not very effective..."; 156 | } 157 | if (effectiveness == 0) { 158 | return "\nIt doesn't affect the opponent!"; 159 | } 160 | return ""; 161 | } 162 | public static MoveEffect FLINCH = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 163 | opponent.setFlinch(true); 164 | return ""; 165 | }; 166 | 167 | public static MoveEffect HEAL_HALF = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 168 | int amt = damage / 2; 169 | if (amt > user.getMaxHP() || (user.getStat(Stats.HP) + amt) > user.getMaxHP()) { 170 | amt = (user.getMaxHP() - user.getStat(Stats.HP)); 171 | user.setHP(user.getMaxHP()); 172 | } else { 173 | user.setHP(user.getStat(Stats.HP) + amt); 174 | } 175 | return amt == 0 ? user.getName() + "'s HP is already full!" : (user.getName() + " gained " + amt + " HP!"); 176 | }; 177 | public static MoveEffect EXPLOSION = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 178 | user.setHP(0); 179 | return (user.getName() + " fainted! KAPOW "); 180 | }; 181 | public static MoveEffect RECOIL_25 = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 182 | int amt = damage / 4; 183 | if (amt > user.getStat(Stats.HP)) { 184 | amt = user.getStat(Stats.HP); 185 | } 186 | user.damage(amt); 187 | return user.getName() + " lost " + amt + "hp due to Recoil!"; 188 | }; 189 | public static MoveEffect RECOIL_33 = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 190 | int amt = damage / 3; 191 | if (amt > user.getStat(Stats.HP)) { 192 | amt = user.getStat(Stats.HP); 193 | } 194 | user.damage(amt); 195 | return user.getName() + " lost " + amt + "hp due to Recoil!"; 196 | }; 197 | public static MoveEffect RECOIL_50 = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 198 | int amt = damage / 2; 199 | if (amt > user.getStat(Stats.HP)) { 200 | amt = user.getStat(Stats.HP); 201 | } 202 | user.damage(amt); 203 | return user.getName() + " lost " + amt + "hp due to Recoil!"; 204 | }; 205 | public static MoveEffect STRUGGLE = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 206 | int amt = user.getMaxHP() / 4; 207 | if (amt > user.getStat(Stats.HP)) { 208 | amt = user.getStat(Stats.HP); 209 | } 210 | user.damage(amt); 211 | return user.getName() + " lost " + amt + "hp due to Recoil!"; 212 | }; 213 | public static MoveEffect RECHARGE = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 214 | user.setMoveStatus(Status.NO_MOVE_THIS_TURN); 215 | return ""; 216 | }; 217 | public static MoveEffect SLEEP = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 218 | if (opponent.getStatus() == Status.SLEEP) { 219 | return opponent.getName() + " is already asleep!"; 220 | } 221 | if (opponent.getStatus() == Status.NORMAL) { 222 | opponent.goToSleep(); 223 | return opponent.getName() + " fell asleep!"; 224 | } 225 | return "But it failed!"; 226 | }; 227 | public static MoveEffect TOXIC = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 228 | if (opponent.getType1() == Type.STEEL || opponent.getType2() == Type.STEEL || opponent.getType1() == Type.POISON || opponent.getType2() == Type.POISON) { 229 | return "But it failed!"; 230 | } 231 | if (opponent.getStatus() == Status.NORMAL) { 232 | opponent.setStatus(Status.TOXIC); 233 | return opponent.getName() + " was badly poisioned!"; 234 | } else { 235 | return "But it failed!"; 236 | } 237 | }; 238 | public static MoveEffect BURN = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 239 | if (opponent.getStatus() == Status.NORMAL && (opponent.getType1() != Type.FIRE || opponent.getType2() != Type.FIRE) && !opponent.isFainted()) { 240 | opponent.setStatus(Status.BURN); 241 | return opponent.getName() + " was burned!"; 242 | } else if (move.getCategory() == MoveCategory.STATUS) { 243 | return "But it failed!"; 244 | } else { 245 | return ""; 246 | } 247 | }; 248 | public static MoveEffect PARALYZE = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 249 | if (opponent.getStatus() == Status.NORMAL && (opponent.getType1() != Type.ELECTRIC || opponent.getType2() != Type.ELECTRIC) && !opponent.isFainted()) { 250 | opponent.setStatus(Status.PARALYSIS); 251 | return opponent.getName() + " was paralyzed!"; 252 | } else if (move.getCategory() == MoveCategory.STATUS) { 253 | return "But it failed!"; 254 | } else { 255 | return ""; 256 | } 257 | }; 258 | public static MoveEffect FREEZE = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 259 | if (opponent.getStatus() == Status.NORMAL && (opponent.getType1() != Type.ICE || opponent.getType2() != Type.ICE) && !opponent.isFainted()) { 260 | opponent.setStatus(Status.FREEZE); 261 | return opponent.getName() + " was frozen solid!"; 262 | } else if (move.getCategory() == MoveCategory.STATUS) { 263 | return "But it failed!"; 264 | } else { 265 | return ""; 266 | } 267 | }; 268 | public static MoveEffect CONFUSE_TARGET = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 269 | if (opponent.isConfused()) { 270 | return opponent.getName() + " is already confused!"; 271 | } else { 272 | opponent.setConfused(true); 273 | return opponent.getName() + " was confused!"; 274 | } 275 | }; 276 | public static MoveEffect POISON = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 277 | if (opponent.getType1() == Type.STEEL || opponent.getType2() == Type.STEEL || opponent.getType1() == Type.POISON || opponent.getType2() == Type.POISON) { 278 | if (move.getCategory() == MoveCategory.STATUS) { 279 | return "But it failed!"; 280 | } else { 281 | return ""; 282 | } 283 | } 284 | if (opponent.getStatus() != Status.NORMAL && !opponent.isFainted()) { 285 | opponent.setStatus(Status.POISON); 286 | return opponent.getName() + " was poisioned!"; 287 | } else if (move.getCategory() == MoveCategory.STATUS) { 288 | return "But it failed!"; 289 | } else { 290 | return ""; 291 | } 292 | }; 293 | public static MoveEffect TRI_ATTACK = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 294 | if (opponent.getStatus() != Status.NORMAL) { 295 | int rand = new SecureRandom().nextInt(2); 296 | Status status = null; 297 | switch (opponent.getType1()) { 298 | case FIRE: 299 | switch (opponent.getType2()) { 300 | case ICE: //interesting combo, regardless: 301 | status = Status.PARALYSIS; 302 | break; 303 | case ELECTRIC: 304 | status = Status.FREEZE; 305 | break; 306 | default: 307 | rand = new SecureRandom().nextInt(1); 308 | switch (rand) { 309 | case 0: 310 | status = Status.PARALYSIS; 311 | break; 312 | case 1: 313 | status = Status.FREEZE; 314 | break; 315 | } 316 | break; 317 | } 318 | break; 319 | case ICE: 320 | switch (opponent.getType2()) { 321 | case FIRE: //interesting combo, regardless: 322 | status = Status.PARALYSIS; 323 | break; 324 | case ELECTRIC: 325 | status = Status.BURN; 326 | break; 327 | default: 328 | rand = new SecureRandom().nextInt(1); 329 | switch (rand) { 330 | case 0: 331 | status = Status.PARALYSIS; 332 | break; 333 | case 1: 334 | status = Status.BURN; 335 | break; 336 | } 337 | break; 338 | } 339 | break; 340 | case ELECTRIC: 341 | switch (opponent.getType2()) { 342 | case FIRE: 343 | status = Status.FREEZE; 344 | break; 345 | case ICE: 346 | status = Status.BURN; 347 | break; 348 | default: 349 | rand = new SecureRandom().nextInt(1); 350 | switch (rand) { 351 | case 0: 352 | status = Status.BURN; 353 | break; 354 | case 1: 355 | status = Status.FREEZE; 356 | break; 357 | } 358 | break; 359 | } 360 | break; 361 | default: 362 | switch (rand) { 363 | case 0: 364 | status = Status.BURN; 365 | break; 366 | case 1: 367 | status = Status.FREEZE; 368 | break; 369 | case 2: 370 | status = Status.PARALYSIS; 371 | break; 372 | } 373 | break; 374 | } 375 | opponent.setStatus(status); 376 | String toReturn = ""; 377 | //fuck the null pointer warnings I have money 378 | switch (status) { 379 | case BURN: 380 | toReturn = " was burned!"; 381 | break; 382 | case FREEZE: 383 | toReturn = " was frozen solid!"; 384 | break; 385 | case PARALYSIS: 386 | toReturn = " was paralyzed!"; 387 | break; 388 | } 389 | return opponent.getName() + toReturn; 390 | } else { 391 | return ""; 392 | } 393 | }; 394 | public static MoveEffect OHKO = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 395 | if (opponent.getLevel() <= user.getLevel()) { 396 | int diff = user.getLevel() - opponent.getLevel(); 397 | diff = diff + 30; 398 | if (diff > 100) { 399 | diff = 100; 400 | } 401 | int hit = new SecureRandom().nextInt(100) + 1; 402 | if (diff == 100 || hit > diff) { 403 | opponent.setHP(0); 404 | return "PogChamp IT'S A ONE HIT KO!! PogChamp " + opponent.getName() + " has 0hp left!"; 405 | } else { 406 | return "The attack missed!"; 407 | } 408 | } else { 409 | return "But it failed!"; 410 | } 411 | }; 412 | public static MoveEffect SPLASH = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 413 | return "ThunBeast But nothing happened..."; 414 | }; 415 | public static MoveEffect HURRICANE = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 416 | String toReturn = ""; 417 | int hitChance = new SecureRandom().nextInt(100); 418 | int target = 0; 419 | switch (battle.getWeather()) { 420 | case NORMAL: 421 | default: 422 | target = 70; 423 | break; 424 | case RAIN: 425 | case RAIN_HEAVY: 426 | target = -1; 427 | break; 428 | case SUN_EXTREME: 429 | target = 50; 430 | break; 431 | } 432 | if (hitChance >= target && target != -1) { 433 | return "The attack missed!"; 434 | } 435 | int power = 110; 436 | if (opponent.getMoveStatus() == Status.ATTACK_NEXT_TURN) { 437 | power = 220; 438 | } 439 | SecureRandom rand = new SecureRandom(); 440 | double effectiveness = getEffectiveness(move, opponent); 441 | toReturn += getEffectivenessText(effectiveness); 442 | int randomNum = rand.nextInt((16 - 1) + 1) + 1; 443 | boolean crit = false; 444 | if (randomNum == 1) { 445 | crit = true; 446 | toReturn += "\nCritical Hit!!"; 447 | } 448 | damage = calcDamage(user, opponent, move, power, MoveCategory.SPECIAL, crit); 449 | opponent.damage(damage); 450 | toReturn += " " + opponent.getName() + " lost " + damage + "hp! "; 451 | toReturn += opponent.getName() + " has " + opponent.getStat(Stats.HP) + "hp left!"; 452 | if (!opponent.isConfused()) { 453 | int confChance = new SecureRandom().nextInt(100); 454 | if (confChance <= 30) { 455 | opponent.setConfused(true); 456 | toReturn += opponent.getName() + " was confused! "; 457 | } 458 | } 459 | return toReturn; 460 | }; 461 | public static MoveEffect MH_15P_85A = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 462 | int power = 15; 463 | int amt = new SecureRandom().nextInt(3) + 2; 464 | int accuracy = 85; 465 | int hit = new SecureRandom().nextInt(100) + 1; 466 | if (hit >= accuracy) { 467 | return "The attack missed!"; 468 | } 469 | return multiHit(user, opponent, move, power, amt); 470 | }; 471 | public static MoveEffect MH_15P_100A = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 472 | int power = 15; 473 | int amt = new SecureRandom().nextInt(3) + 2; 474 | return multiHit(user, opponent, move, power, amt); 475 | }; 476 | public static MoveEffect MH_25P_90A = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 477 | int power = 25; 478 | int amt = new SecureRandom().nextInt(3) + 2; 479 | int accuracy = 90; 480 | int hit = new SecureRandom().nextInt(100) + 1; 481 | if (hit >= accuracy) { 482 | return "The attack missed!"; 483 | } 484 | return multiHit(user, opponent, move, power, amt); 485 | }; 486 | public static MoveEffect MH_25P_100A = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 487 | int power = 15; 488 | int amt = new SecureRandom().nextInt(3) + 2; 489 | return multiHit(user, opponent, move, power, amt); 490 | }; 491 | public static MoveEffect MH_18P_85A = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 492 | int power = 18; 493 | int amt = new SecureRandom().nextInt(3) + 2; 494 | int accuracy = 85; 495 | int hit = new SecureRandom().nextInt(100) + 1; 496 | if (hit >= accuracy) { 497 | return "The attack missed!"; 498 | } 499 | return multiHit(user, opponent, move, power, amt); 500 | }; 501 | public static MoveEffect MH_18P_80A = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 502 | int power = 15; 503 | int amt = new SecureRandom().nextInt(3) + 2; 504 | int accuracy = 80; 505 | int hit = new SecureRandom().nextInt(100) + 1; 506 | if (hit >= accuracy) { 507 | return "The attack missed!"; 508 | } 509 | return multiHit(user, opponent, move, power, amt); 510 | }; 511 | public static MoveEffect MH_25P_95A = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 512 | int power = 25; 513 | int amt = new SecureRandom().nextInt(3) + 2; 514 | int accuracy = 95; 515 | int hit = new SecureRandom().nextInt(100) + 1; 516 | if (hit >= accuracy) { 517 | return "The attack missed!"; 518 | } 519 | return multiHit(user, opponent, move, power, amt); 520 | }; 521 | public static MoveEffect MH_20P_100A = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 522 | int power = 20; 523 | int amt = new SecureRandom().nextInt(3) + 2; 524 | return multiHit(user, opponent, move, power, amt); 525 | }; 526 | public static MoveEffect MH_25P_85A = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 527 | int power = 25; 528 | int amt = new SecureRandom().nextInt(3) + 2; 529 | int accuracy = 85; 530 | int hit = new SecureRandom().nextInt(100) + 1; 531 | if (hit >= accuracy) { 532 | return "The attack missed!"; 533 | } 534 | return multiHit(user, opponent, move, power, amt); 535 | }; 536 | public static MoveEffect BOOMERANG = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 537 | int power = 50; 538 | int amt = 2; 539 | int accuracy = 90; 540 | int hit = new SecureRandom().nextInt(100) + 1; 541 | if (hit >= accuracy) { 542 | return "The attack missed!"; 543 | } 544 | return multiHit(user, opponent, move, power, amt); 545 | }; 546 | public static MoveEffect DOUBLE_HIT = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 547 | int power = 35; 548 | int amt = 2; 549 | int accuracy = 90; 550 | int hit = new SecureRandom().nextInt(100) + 1; 551 | if (hit >= accuracy) { 552 | return "The attack missed!"; 553 | } 554 | return multiHit(user, opponent, move, power, amt); 555 | }; 556 | public static MoveEffect DOUBLE_KICK = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 557 | int power = 30; 558 | int amt = 2; 559 | return multiHit(user, opponent, move, power, amt); 560 | }; 561 | public static MoveEffect DUAL_CHOP = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 562 | int power = 40; 563 | int amt = 2; 564 | int accuracy = 90; 565 | int hit = new SecureRandom().nextInt(100) + 1; 566 | if (hit >= accuracy) { 567 | return "The attack missed!"; 568 | } 569 | return multiHit(user, opponent, move, power, amt); 570 | }; 571 | public static MoveEffect GEAR_GRIND = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 572 | int power = 50; 573 | int amt = 2; 574 | int accuracy = 85; 575 | int hit = new SecureRandom().nextInt(100) + 1; 576 | if (hit >= accuracy) { 577 | return "The attack missed!"; 578 | } 579 | return multiHit(user, opponent, move, power, amt); 580 | }; 581 | public static MoveEffect TWINEEDLE = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 582 | int power = 25; 583 | int amt = 2; 584 | int chance = 20; 585 | int hit = new SecureRandom().nextInt(100) + 1; 586 | String toReturn = multiHit(user, opponent, move, power, amt); 587 | if (hit < chance) { 588 | if (opponent.getType1() == Type.STEEL || opponent.getType2() == Type.STEEL || opponent.getType1() == Type.POISON || opponent.getType2() == Type.POISON) { 589 | } else if (opponent.getStatus() == Status.NORMAL && !opponent.isFainted()) { 590 | opponent.setStatus(Status.POISON); 591 | toReturn += " " + opponent.getName() + " was poisioned!"; 592 | } 593 | } 594 | return toReturn; 595 | }; 596 | public static MoveEffect TRIPLE_KICK = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 597 | int power = 10; 598 | int amt = 3; 599 | int accuracy = 90; 600 | int i = amt; 601 | amt = 0; 602 | String toReturn = ""; 603 | double effect = getEffectiveness(move, opponent); 604 | if (effect == 0) { 605 | return "It doesn't affect the opponent!"; 606 | } 607 | String effectiveness = getEffectivenessText(effect); 608 | while (i > 0) { 609 | int hit = new SecureRandom().nextInt(100) + 1; 610 | if (hit >= accuracy) { 611 | toReturn += "The attack missed!"; 612 | amt++; 613 | break; 614 | } 615 | boolean crit = new SecureRandom().nextBoolean(); 616 | if (crit) { 617 | toReturn += " Critical Hit!! "; 618 | } 619 | damage = calcDamage(user, opponent, move, power, move.getCategory(), crit); 620 | opponent.damage(damage); 621 | power += 10; 622 | toReturn += opponent.getName() + " lost " + damage + "hp! "; 623 | i--; 624 | amt++; 625 | } 626 | toReturn += effectiveness + " Hit " + amt + " time" + (amt == 1 ? "! " : "s! ") + opponent.getName() + " has " + opponent.getStat(Stats.HP) + "hp left!"; 627 | return toReturn; 628 | }; 629 | 630 | public static MoveEffect PAIN_SPLIT = (Pokemon user, Pokemon opponent, int damage, Move move, Battle battle) -> { 631 | if (opponent.getMoveStatus() == Status.ATTACK_NEXT_TURN) { 632 | return "The attack missed!"; 633 | } 634 | int totalHP = (user.getStat(Stats.HP) + opponent.getStat(Stats.HP)) / 2; 635 | if (user.getMaxHP() < (totalHP)) { 636 | user.setStat(Stats.HP, user.getMaxHP()); 637 | } else { 638 | user.setStat(Stats.HP, totalHP); 639 | } 640 | if (opponent.getMaxHP() < (totalHP)) { 641 | opponent.setStat(Stats.HP, opponent.getMaxHP()); 642 | } else { 643 | opponent.setStat(Stats.HP, totalHP); 644 | } 645 | return "The battlers shared their pain! " + user.getName() + " now has " + user.getStat(Stats.HP) + "hp! " + opponent.getName() + " now has " + opponent.getStat(Stats.HP) + "hp!"; 646 | }; 647 | 648 | private static String multiHit(Pokemon user, Pokemon opponent, Move move, int power, int amt) { 649 | StringBuilder toReturn = new StringBuilder(""); 650 | int i = amt; 651 | double effect = getEffectiveness(move, opponent); 652 | if (effect == 0) { 653 | return "It doesn't affect the opponent!"; 654 | } 655 | String effectiveness = getEffectivenessText(effect); 656 | while (i > 0) { 657 | boolean crit = new SecureRandom().nextBoolean(); 658 | int damage = calcDamage(user, opponent, move, power, move.getCategory(), crit); 659 | opponent.damage(damage); 660 | toReturn.append(crit ? " Critical Hit!! " : " ").append(opponent.getName()).append(" lost ").append(damage).append("hp! "); 661 | i--; 662 | } 663 | toReturn.append(effectiveness).append(" Hit ").append(amt).append(" time").append(amt > 1 ? "s! " : "! ").append(opponent.getName()).append(" has ").append(opponent.getStat(Stats.HP)).append("hp left!"); 664 | return toReturn.toString(); 665 | } 666 | } 667 | -------------------------------------------------------------------------------- /src/TPPDekuBot/MultiplayerBattle.java: -------------------------------------------------------------------------------- 1 | package TPPDekuBot; 2 | 3 | import java.io.File; 4 | import java.io.PrintWriter; 5 | import java.io.StringWriter; 6 | import java.security.SecureRandom; 7 | import java.util.concurrent.LinkedBlockingQueue; 8 | import java.util.concurrent.TimeUnit; 9 | 10 | public class MultiplayerBattle extends Battle { 11 | 12 | public Trainer player1; 13 | public Trainer player2; 14 | private Pokemon pokemon1; 15 | private Pokemon pokemon2; 16 | public LinkedBlockingQueue p1msg = new LinkedBlockingQueue<>(); 17 | public LinkedBlockingQueue p2msg = new LinkedBlockingQueue<>(); 18 | private boolean p1switch = false; 19 | private boolean p2switch = false; 20 | private boolean endBattle = false; 21 | private int numberOfMon = 1; 22 | private boolean randomBattle; 23 | private boolean musicChanged = false; 24 | private BattleBot b; 25 | 26 | public final boolean isBannedPokemon(int poke) { 27 | int[] banned = {0, 132, 202, 235, 292, 360, 665}; 28 | for (int el : banned) { 29 | if (poke == el) { 30 | return true; 31 | } 32 | } 33 | if (poke > 720 || poke < 0) { 34 | return true; 35 | } 36 | return false; 37 | } 38 | 39 | public MultiplayerBattle(BattleBot b, String player1, String player2, int level, int pokemonNumber) { 40 | super(b); 41 | this.b = b; 42 | this.player1 = new Trainer(player1, pokemonNumber, level); 43 | this.player2 = new Trainer(player2, pokemonNumber, level); 44 | this.pokemon1 = this.player1.getPokemon(0); 45 | this.pokemon2 = this.player2.getPokemon(0); 46 | this.player1.removePokemon(0); 47 | this.player2.removePokemon(0); 48 | this.numberOfMon = pokemonNumber; 49 | randomBattle = true; 50 | } 51 | 52 | public MultiplayerBattle(BattleBot b, String player1, String player2, int level) { 53 | super(b); 54 | this.b = b; 55 | this.player1 = new Trainer(player1, 1, level); 56 | this.player2 = new Trainer(player2, 1, level); 57 | this.pokemon1 = this.player1.getPokemon(0); 58 | this.pokemon2 = this.player2.getPokemon(0); 59 | this.player1.removePokemon(0); 60 | this.player2.removePokemon(0); 61 | randomBattle = true; 62 | } 63 | 64 | public MultiplayerBattle(BattleBot b, Trainer player1, Trainer player2) { 65 | super(b); 66 | this.b = b; 67 | randomBattle = false; 68 | this.player1 = player1; 69 | this.player2 = player2; 70 | this.pokemon1 = this.player1.getPokemon(0); 71 | this.pokemon2 = this.player2.getPokemon(0); 72 | this.player1.removePokemon(0); 73 | this.player2.removePokemon(0); 74 | numberOfMon = (this.player1.getPokemon().size() >= this.player2.getPokemon().size()) ? this.player1.getPokemon().size() : this.player2.getPokemon().size(); 75 | } 76 | 77 | public String getPlayer1() { 78 | return player1.getTrainerName(); 79 | } 80 | 81 | public String getPlayer2() { 82 | return player2.getTrainerName(); 83 | } 84 | 85 | private void doMove(String channel, String move, Pokemon user, Pokemon opponent) { 86 | int m = Integer.parseInt(move); 87 | b.sendMessage(channel, user.attack(opponent, user.getMoveByNumber(m), this).replace("\n", " ")); 88 | } 89 | 90 | private void switchPlayer1(String channel) { 91 | if (pokemon2.getLevel() == 100) { 92 | b.sendMessage(channel, pokemon1.getName() + " fainted! What Pokemon will " + player1.getTrainerName() + " switch to?"); 93 | } else { 94 | int levelBefore = pokemon2.getLevel(); 95 | int exp = Pokemon.calculateExperience(true, pokemon2, pokemon1); 96 | pokemon2.addExperience(exp); 97 | int levelAfter = pokemon2.getLevel(); 98 | b.sendMessage(channel, pokemon1.getName() + " fainted! " + pokemon2.getName() + " gained " + exp + " Exp. Points!"); 99 | if (levelBefore < levelAfter) { 100 | b.sendMessage(channel, pokemon2.getName() + " grew to Level " + levelAfter + "! PogChamp"); 101 | } 102 | b.sendMessage(channel, "What Pokemon will " + player1.getTrainerName() + " switch to?"); 103 | } 104 | b.sendWhisper(player1.getTrainerName(), "Type !list to get a list of your Pokemon. Type !switch to switch to that Pokemon (for example, the if you want to switch to the first Pokemon, type !switch0 )"); 105 | String p1move = ""; 106 | int p1switchto = -1; 107 | try { 108 | p1move = p1msg.poll(60, TimeUnit.SECONDS); 109 | if (p1move == null) { 110 | b.sendMessage(channel, player1.getTrainerName() + " did not select a new Pokemon in time. " + player2.getTrainerName() + " wins!"); 111 | endBattle = true; 112 | return; 113 | } 114 | if (p1move.startsWith("!switch") && p1move.length() >= 8) { 115 | if (!Character.isDigit(p1move.charAt(7))) { 116 | p1move = ""; 117 | b.sendMessage(channel, "/w " + player1.getTrainerName() + " Invalid Pokemon Position FUNgineer"); 118 | } else { 119 | p1switchto = Integer.parseInt(p1move.charAt(7) + ""); 120 | try { 121 | if (player1.getPokemon(p1switchto).isFainted()) { 122 | b.sendMessage(channel, "/w " + player1.getTrainerName() + " You cannot switch to a fainted Pokemon FUNgineer"); 123 | p1move = ""; 124 | } 125 | } catch (Exception ex) { 126 | b.sendMessage(channel, "/w " + player1.getTrainerName() + " Invalid Pokemon Position FUNgineer"); 127 | p1move = ""; 128 | } 129 | } 130 | } else { 131 | p1move = ""; 132 | } 133 | while (!p1move.startsWith("!switch")) { 134 | p1move = p1msg.take(); 135 | if (p1move.startsWith("!switch") && p1move.length() >= 8) { 136 | if (!Character.isDigit(p1move.charAt(7))) { 137 | p1move = ""; 138 | b.sendMessage(channel, "/w " + player1.getTrainerName() + " Invalid Pokemon Position FUNgineer"); 139 | continue; 140 | } 141 | p1switchto = Integer.parseInt(p1move.charAt(7) + ""); 142 | try { 143 | if (player1.getPokemon(p1switchto).isFainted()) { 144 | b.sendMessage(channel, "/w " + player1.getTrainerName() + " You cannot switch to a fainted Pokemon FUNgineer"); 145 | p1move = ""; 146 | continue; 147 | } 148 | } catch (Exception ex) { 149 | b.sendMessage(channel, "/w " + player1.getTrainerName() + " Invalid Pokemon Position FUNgineer"); 150 | p1move = ""; 151 | continue; 152 | } 153 | } else { 154 | p1move = ""; 155 | } 156 | } 157 | p1msg = new LinkedBlockingQueue<>(); 158 | this.pokemon1 = player1.getPokemon(p1switchto); 159 | player1.removePokemon(p1switchto); 160 | b.sendMessage(channel, this.player1 + " sends out " + this.pokemon1.getName() + " (level " + this.pokemon1.getLevel() + ")!"); 161 | 162 | } catch (Exception ex) { 163 | System.err.println("[WARNING] Failed to Switch pokemon! " + ex); 164 | StringWriter sw = new StringWriter(); 165 | PrintWriter pw = new PrintWriter(sw); 166 | ex.printStackTrace(pw); 167 | b.music.sendMessage(b.music.getChannel(), b.music.CHEF.mention() + " ```" + sw.toString() + "\n```"); 168 | endBattle = true; 169 | } 170 | } 171 | 172 | private void switchPlayer2(String channel) { 173 | if (pokemon1.getLevel() == 100) { 174 | b.sendMessage(channel, pokemon2.getName() + " fainted! What Pokemon will " + player2.getTrainerName() + " switch to?"); 175 | } else { 176 | int levelBefore = pokemon1.getLevel(); 177 | int exp = Pokemon.calculateExperience(true, pokemon1, pokemon2); 178 | pokemon1.addExperience(exp); 179 | int levelAfter = pokemon1.getLevel(); 180 | b.sendMessage(channel, pokemon2.getName() + " fainted! " + pokemon1.getName() + " gained " + exp + " Exp. Points!"); 181 | if (levelBefore < levelAfter) { 182 | b.sendMessage(channel, pokemon1.getName() + " grew to Level " + levelAfter + "! PogChamp"); 183 | } 184 | b.sendMessage(channel, "What Pokemon will " + player2.getTrainerName() + " switch to?"); 185 | } 186 | b.sendWhisper(player2.getTrainerName(), "Type !list to get a list of your Pokemon. Type !switch to switch to that Pokemon (for example, the if you want to switch to the first Pokemon, type !switch0 )"); 187 | String p2move = ""; 188 | int p2switchto = -1; 189 | try { 190 | p2move = p2msg.poll(60, TimeUnit.SECONDS); 191 | if (p2move == null) { 192 | b.sendMessage(channel, player2.getTrainerName() + " did not select a new Pokemon in time. " + player1.getTrainerName() + " wins!"); 193 | endBattle = true; 194 | return; 195 | } 196 | if (p2move.startsWith("!switch") && p2move.length() >= 8) { 197 | if (!Character.isDigit(p2move.charAt(7))) { 198 | p2move = ""; 199 | b.sendMessage(channel, "/w " + player2.getTrainerName() + " Invalid Pokemon Position FUNgineer"); 200 | } else { 201 | p2switchto = Integer.parseInt(p2move.charAt(7) + ""); 202 | try { 203 | if (player2.getPokemon(p2switchto).isFainted()) { 204 | b.sendMessage(channel, "/w " + player2.getTrainerName() + " You cannot switch to a fainted Pokemon FUNgineer"); 205 | p2move = ""; 206 | } 207 | } catch (Exception ex) { 208 | b.sendMessage(channel, "/w " + player2.getTrainerName() + " Invalid Pokemon Position FUNgineer"); 209 | p2move = ""; 210 | } 211 | } 212 | } else { 213 | p2move = ""; 214 | } 215 | while (!p2move.startsWith("!switch")) { 216 | p2move = p2msg.take(); 217 | if (p2move.startsWith("!switch") && p2move.length() >= 8) { 218 | if (!Character.isDigit(p2move.charAt(7))) { 219 | p2move = ""; 220 | b.sendMessage(channel, "/w " + player2.getTrainerName() + " Invalid Pokemon Position FUNgineer"); 221 | continue; 222 | } 223 | p2switchto = Integer.parseInt(p2move.charAt(7) + ""); 224 | try { 225 | if (player2.getPokemon(p2switchto).isFainted()) { 226 | b.sendMessage(channel, "/w " + player2.getTrainerName() + " You cannot switch to a fainted Pokemon FUNgineer"); 227 | p2move = ""; 228 | continue; 229 | } 230 | } catch (Exception ex) { 231 | b.sendMessage(channel, "/w " + player2.getTrainerName() + " Invalid Pokemon Position FUNgineer"); 232 | p2move = ""; 233 | continue; 234 | } 235 | } else { 236 | p2move = ""; 237 | } 238 | } 239 | p2msg = new LinkedBlockingQueue<>(); 240 | this.pokemon2 = player2.getPokemon(p2switchto); 241 | player2.removePokemon(p2switchto); 242 | b.sendMessage(channel, this.player2 + " sends out " + this.pokemon2.getName() + " (level " + this.pokemon2.getLevel() + ")!"); 243 | } catch (Exception ex) { 244 | System.err.println("[WARNING] Failed to Switch pokemon! " + ex); 245 | endBattle = true; 246 | StringWriter sw = new StringWriter(); 247 | PrintWriter pw = new PrintWriter(sw); 248 | ex.printStackTrace(pw); 249 | b.music.sendMessage(b.music.getChannel(), b.music.CHEF.mention() + " ```" + sw.toString() + "```"); 250 | } 251 | 252 | } 253 | 254 | public void doBattle(String channel) { 255 | boolean hasSent = false; 256 | b.music.play(b.determineMusic(player1.getTrnClass(), player2.getTrnClass(), player1.getTrainerName(), player2.getTrainerName())); 257 | b.sendMessage(channel, player1 + " is issuing a challenge against " + player2 + "!"); 258 | b.sendMessage(channel, player1.getTrainerName() + " sends out " + pokemon1.getName() + " (Level " + pokemon1.getLevel() + ")! " + player2.getTrainerName() + " sends out " + pokemon2.getName() + " (Level " + pokemon2.getLevel() + ")!"); 259 | do { 260 | singlebattle: 261 | while (!pokemon1.isFainted() && !pokemon2.isFainted()) { 262 | if (player1.getPokemon().isEmpty() && player2.getPokemon().isEmpty() && !hasSent && numberOfMon > 1) { 263 | hasSent = true; 264 | String toSend = (new SecureRandom().nextBoolean()) ? "PRChase The battle has reached it's final stage! And the tension is peaking ThunBeast" : "PRChase The Last Pokemon from Each Team takes the field. Will the Outcome of the battle be decided in the next turn? ThunBeast"; 265 | b.sendMessage(channel, toSend); 266 | } 267 | if (numberOfMon > 1) { 268 | if (!musicChanged) { 269 | if ((player1.getTrnClass().equalsIgnoreCase("Gym Leader") && player1.getPokemon().isEmpty()) || (player2.getTrnClass().equalsIgnoreCase("Gym Leader") && player2.getPokemon().isEmpty())) { 270 | String nowPlaying = b.music.getNowPlaying(); 271 | if (nowPlaying.contains("gen5-bw-gym")) { 272 | b.music.clear(); 273 | b.music.play(new File(b.ROOT_PATH + "gen5-bw-gym-final.mp3")); 274 | musicChanged = true; 275 | } 276 | if (nowPlaying.contains("gen5-b2w2-gym")) { 277 | b.music.clear(); 278 | b.music.play(new File(b.ROOT_PATH + "gen5-b2w2-gym-final.mp3")); 279 | musicChanged = true; 280 | } 281 | } 282 | } 283 | } 284 | b.sendMessage(channel, "Waiting on communication..."); 285 | b.sendWhisper(player1.getTrainerName(), "What will " + pokemon1.getName() + " do? (!move1)" + pokemon1.getMove1().getName() + ", (!move2)" + pokemon1.getMove2().getName() + ", (!move3)" + pokemon1.getMove3().getName() + ", (!move4)" + pokemon1.getMove4().getName() + " (!help)Additional Commands (reply in Battle Dungeon)"); 286 | b.sendWhisper(player2.getTrainerName(), "What will " + pokemon2.getName() + " do? (!move1)" + pokemon2.getMove1().getName() + ", (!move2)" + pokemon2.getMove2().getName() + ", (!move3)" + pokemon2.getMove3().getName() + ", (!move4)" + pokemon2.getMove4().getName() + " (!help)Additional Commands (reply in Battle Dungeon)"); 287 | pokemon1.setFlinch(false); 288 | pokemon2.setFlinch(false); 289 | p1switch = false; 290 | p2switch = false; 291 | String p1move = "", p2move = ""; 292 | int p1switchto = -1; 293 | int p2switchto = -1; 294 | try { 295 | p1move = p1msg.poll(60, TimeUnit.SECONDS); 296 | if (p1move == null) { 297 | b.sendMessage(channel, player1.getTrainerName() + " did not select a move in time. " + player2.getTrainerName() + " wins!"); 298 | return; 299 | } 300 | if (p1move.startsWith("!switch") && p1move.length() >= 8) { 301 | if (!Character.isDigit(p1move.charAt(7))) { 302 | p1move = ""; 303 | b.sendMessage(channel, "/w " + player1.getTrainerName() + " Invalid Pokemon Position FUNgineer"); 304 | } else { 305 | p1switchto = Integer.parseInt(p1move.charAt(7) + ""); 306 | try { 307 | if (player1.getPokemon(p1switchto).isFainted()) { 308 | b.sendMessage(channel, "/w " + player1.getTrainerName() + " You cannot switch to a fainted Pokemon FUNgineer"); 309 | p1move = ""; 310 | } 311 | } catch (Exception ex) { 312 | b.sendMessage(channel, "/w " + player1.getTrainerName() + " Invalid Pokemon Position FUNgineer"); 313 | p1move = ""; 314 | } 315 | p1switch = true; 316 | } 317 | } 318 | while (!p1move.startsWith("!run") && !p1move.startsWith("!move") && !p1move.startsWith("!switch")) { 319 | p1move = p1msg.take(); 320 | if (p1move.startsWith("!switch") && p1move.length() >= 8) { 321 | if (!Character.isDigit(p1move.charAt(7))) { 322 | b.sendMessage(channel, "/w " + player1.getTrainerName() + " Invalid Pokemon Position FUNgineer"); 323 | p1move = ""; 324 | } else { 325 | p1switchto = Integer.parseInt(p1move.charAt(7) + ""); 326 | try { 327 | if (player1.getPokemon(p1switchto).isFainted()) { 328 | b.sendMessage(channel, "/w " + player1.getTrainerName() + " You cannot switch to a fainted Pokemon FUNgineer"); 329 | p1move = ""; 330 | continue; 331 | } 332 | } catch (Exception ex) { 333 | b.sendMessage(channel, "/w " + player1.getTrainerName() + " Invalid Pokemon Position FUNgineer"); 334 | p1move = ""; 335 | continue; 336 | } 337 | p1switch = true; 338 | break; 339 | } 340 | } else if (!p1move.startsWith("!move") && !p1move.startsWith("!run")) { 341 | p1move = ""; 342 | } 343 | } 344 | p1msg = new LinkedBlockingQueue<>(); 345 | p2move = p2msg.poll(60, TimeUnit.SECONDS); 346 | if (p2move == null) { 347 | b.sendMessage(channel, player2.getTrainerName() + " did not select a move in time. " + player1.getTrainerName() + " wins!"); 348 | return; 349 | } 350 | if (p2move.startsWith("!switch") && p2move.length() >= 8) { 351 | if (!Character.isDigit(p2move.charAt(7))) { 352 | b.sendMessage(channel, "/w " + player2.getTrainerName() + " Invalid Pokemon Position FUNgineer"); 353 | p2move = ""; 354 | } else { 355 | p2switchto = Integer.parseInt(p2move.charAt(7) + ""); 356 | try { 357 | if (player2.getPokemon(p2switchto).isFainted()) { 358 | b.sendMessage(channel, "/w " + player2.getTrainerName() + " You cannot switch to a fainted Pokemon FUNgineer"); 359 | p2move = ""; 360 | } 361 | } catch (Exception ex) { 362 | b.sendMessage(channel, "/w " + player2.getTrainerName() + " Invalid Pokemon Position FUNgineer"); 363 | p2move = ""; 364 | } 365 | p2switch = true; 366 | } 367 | } 368 | while (!p2move.equalsIgnoreCase("!run") && !p2move.startsWith("!move") && !p2move.startsWith("!switch")) { 369 | p2move = p2msg.take(); 370 | if (p2move.startsWith("!switch") && p2move.length() >= 8) { 371 | if (!Character.isDigit(p2move.charAt(7))) { 372 | b.sendMessage(channel, "/w " + player2.getTrainerName() + " Invalid Pokemon Position FUNgineer"); 373 | p2move = ""; 374 | } else { 375 | p2switchto = Integer.parseInt(p2move.charAt(7) + ""); 376 | try { 377 | if (player2.getPokemon(p2switchto).isFainted()) { 378 | b.sendMessage(channel, "/w " + player2.getTrainerName() + " You cannot switch to a fainted Pokemon FUNgineer"); 379 | p2move = ""; 380 | continue; 381 | } 382 | } catch (Exception ex) { 383 | b.sendMessage(channel, "/w " + player2.getTrainerName() + " Invalid Pokemon Position FUNgineer"); 384 | p2move = ""; 385 | continue; 386 | } 387 | p2switch = true; 388 | break; 389 | } 390 | } else if (!p2move.startsWith("!move") && !p2move.startsWith("!run")) { 391 | p2move = ""; 392 | continue; 393 | } 394 | } 395 | p2msg = new LinkedBlockingQueue<>(); 396 | } catch (Exception ex) { 397 | StringWriter sw = new StringWriter(); 398 | PrintWriter pw = new PrintWriter(sw); 399 | ex.printStackTrace(pw); 400 | b.music.sendMessage(b.music.getChannel(), b.music.CHEF.mention() + " ```" + sw.toString() + "```"); 401 | } 402 | if (p1move.startsWith("!run") && !p2move.startsWith("!run")) { 403 | b.sendMessage(channel, player1.getTrainerName() + " forfeits! " + player2.getTrainerName() + " wins!"); 404 | return; 405 | } 406 | if (p2move.startsWith("!run") && !p1move.startsWith("!run")) { 407 | b.sendMessage(channel, player2.getTrainerName() + " forfeits! " + player1.getTrainerName() + " wins!"); 408 | return; 409 | } 410 | if (p1move.startsWith("!run") && p2move.startsWith("!run")) { 411 | b.sendMessage(channel, player1.getTrainerName() + " forfeits! " + player2.getTrainerName() + " forfeits as well! The result of the Battle is a Draw! PipeHype"); 412 | return; 413 | } 414 | if (Character.isDigit(p1move.charAt(5))) { 415 | p1move = "" + p1move.charAt(5); 416 | } 417 | if (Character.isDigit(p2move.charAt(5))) { 418 | p2move = "" + p2move.charAt(5); 419 | } 420 | if (p1switch && !p2switch) { 421 | String oldName = pokemon1.getName(); 422 | String newName = ""; 423 | player1.addPokemon(pokemon1); 424 | pokemon1 = player1.getPokemon(p1switchto); 425 | player1.removePokemon(p1switchto); 426 | newName = pokemon1.getName(); 427 | b.sendMessage(channel, player1.getTrainerName() + " calls back " + oldName + " and sent out " + newName + "!"); 428 | doMove(channel, p2move, pokemon2, pokemon1); 429 | if (pokemon1.isFainted()) { 430 | break singlebattle; 431 | } 432 | continue; 433 | } 434 | if (p2switch && !p1switch) { 435 | String oldName = pokemon2.getName(); 436 | String newName = ""; 437 | player2.addPokemon(pokemon2); 438 | pokemon2 = player2.getPokemon(p2switchto); 439 | player2.removePokemon(p2switchto); 440 | newName = pokemon2.getName(); 441 | b.sendMessage(channel, player2.getTrainerName() + " calls back " + oldName + " and sent out " + newName + "!"); 442 | doMove(channel, p1move, pokemon1, pokemon2); 443 | if (pokemon2.isFainted()) { 444 | break singlebattle; 445 | } 446 | continue; 447 | } 448 | if (p1switch && p2switch) { 449 | String oldName = pokemon1.getName(); 450 | String newName = ""; 451 | player1.addPokemon(pokemon1); 452 | pokemon1 = player1.getPokemon(p1switchto); 453 | player1.removePokemon(p1switchto); 454 | newName = pokemon1.getName(); 455 | b.sendMessage(channel, player1.getTrainerName() + " calls back " + oldName + " and sent out " + newName + "!"); 456 | oldName = pokemon2.getName(); 457 | newName = ""; 458 | player2.addPokemon(pokemon2); 459 | pokemon2 = player2.getPokemon(p2switchto); 460 | player2.removePokemon(p2switchto); 461 | newName = pokemon2.getName(); 462 | b.sendMessage(channel, player2.getTrainerName() + " calls back " + oldName + " and sent out " + newName + "!"); 463 | continue; 464 | } 465 | //main battle 466 | Pokemon first, second; 467 | String m1, m2; 468 | int p1speed = pokemon1.getStat(Stats.SPEED); 469 | int p2speed = pokemon2.getStat(Stats.SPEED); 470 | if (pokemon1.getStatus() == Status.PARALYSIS) { 471 | p1speed = p1speed / 2; 472 | } 473 | if (pokemon2.getStatus() == Status.PARALYSIS) { 474 | p2speed = p2speed / 2; 475 | } 476 | if (p1speed > p2speed) { 477 | first = pokemon1; 478 | m1 = p1move; 479 | second = pokemon2; 480 | m2 = p2move; 481 | } else if (p1speed < p2speed) { 482 | first = pokemon2; 483 | m1 = p2move; 484 | second = pokemon1; 485 | m2 = p1move; 486 | } else if (new SecureRandom().nextBoolean()) { 487 | first = pokemon1; 488 | m1 = p1move; 489 | second = pokemon2; 490 | m2 = p2move; 491 | } else { 492 | first = pokemon2; 493 | m1 = p2move; 494 | second = pokemon1; 495 | m2 = p1move; 496 | } 497 | boolean fainted = mainBattle(first, second, m1, m2, channel); 498 | if (fainted) { 499 | break singlebattle; 500 | } 501 | } 502 | if (pokemon1.isFainted()) { 503 | if (player1.getPokemon().isEmpty()) { 504 | break; 505 | } else { 506 | switchPlayer1(channel); 507 | if (endBattle) { 508 | b.sendMessage(channel, "Something went wrong this battle is now over all the Pokemon got stolen by Team Rocket RuleFive"); 509 | return; 510 | } 511 | continue; 512 | } 513 | } else if (pokemon2.isFainted()) { 514 | if (player2.getPokemon().isEmpty()) { 515 | break; 516 | } else { 517 | switchPlayer2(channel); 518 | if (endBattle) { 519 | b.sendMessage(channel, "Something went wrong this battle is now over all the Pokemon got stolen by Team Rocket RuleFive"); 520 | return; 521 | } 522 | continue; 523 | } 524 | } 525 | if (endBattle) { 526 | b.sendMessage(channel, "Something went wrong this battle is now over all the Pokemon got stolen by Team Rocket RuleFive"); 527 | return; 528 | } 529 | //} while ((!player1.getPokemon().isEmpty() && !player2.getPokemon().isEmpty()) && (!pokemon1.isFainted() && !pokemon2.isFainted())); 530 | } while (continueBattle()); 531 | if (pokemon1.isFainted() && pokemon2.isFainted()) { 532 | b.sendMessage(channel, pokemon1.getName() + " fainted! But " + pokemon2.getName() + " fainted too! The Battle ends in a Draw! NotLikeThis"); 533 | } else if (pokemon1.isFainted() && !pokemon2.isFainted()) { 534 | if (pokemon2.getLevel() == 100) { 535 | b.sendMessage(channel, pokemon1.getName() + " fainted! " + player1.getTrainerName() + " is out of usable Pokemon! " + player2 + " wins! PogChamp"); 536 | } else { 537 | int levelBefore = pokemon2.getLevel(); 538 | int exp = Pokemon.calculateExperience(true, pokemon2, pokemon1); 539 | pokemon2.addExperience(exp); 540 | int levelAfter = pokemon2.getLevel(); 541 | b.sendMessage(channel, pokemon1.getName() + " fainted! " + pokemon2.getName() + " gained " + exp + " Exp. Points!"); 542 | if (levelBefore < levelAfter) { 543 | b.sendMessage(channel, pokemon2.getName() + " grew to Level " + levelAfter + "! PogChamp"); 544 | } 545 | b.sendMessage(channel, player1.getTrainerName() + " is out of usable Pokemon! " + player2 + " wins! PogChamp"); 546 | } 547 | } else if (!pokemon1.isFainted() && pokemon2.isFainted()) { 548 | if (pokemon1.getLevel() == 100) { 549 | b.sendMessage(channel, pokemon2.getName() + " fainted! " + player2.getTrainerName() + " is out of usable Pokemon! " + player1 + " wins! PogChamp"); 550 | } else { 551 | int levelBefore = pokemon1.getLevel(); 552 | int exp = Pokemon.calculateExperience(true, pokemon1, pokemon2); 553 | pokemon1.addExperience(exp); 554 | int levelAfter = pokemon1.getLevel(); 555 | b.sendMessage(channel, pokemon2.getName() + " fainted! " + pokemon1.getName() + " gained " + exp + " Exp. Points!"); 556 | if (levelBefore < levelAfter) { 557 | b.sendMessage(channel, pokemon1.getName() + " grew to Level " + levelAfter + "! PogChamp"); 558 | } 559 | b.sendMessage(channel, player2.getTrainerName() + " is out of usable Pokemon! " + player1 + " wins! PogChamp"); 560 | } 561 | } else { 562 | System.err.println("Loop dun fucked up."); 563 | } 564 | } 565 | 566 | public boolean mainBattle(Pokemon p1, Pokemon p2, String move1, String move2, String channel) { 567 | doMove(channel, move1, p1, p2); 568 | if (!p2.isFainted()) { 569 | if (p2.isFlinched()) { 570 | p2.setFlinch(false); 571 | b.sendMessage(channel, p2.getName() + " flinched!"); 572 | return false; 573 | } 574 | doMove(channel, move2, p2, p1); 575 | return false; 576 | } else { 577 | return true; 578 | } 579 | } 580 | 581 | public boolean continueBattle() { 582 | if (pokemon1.isFainted()) { 583 | if (player1.getPokemon().isEmpty()) { 584 | return false; 585 | } 586 | } 587 | if (pokemon2.isFainted()) { 588 | if (player2.getPokemon().isEmpty()) { 589 | return false; 590 | } 591 | } 592 | return true; 593 | } 594 | } 595 | -------------------------------------------------------------------------------- /src/TPPDekuBot/PWTBattle.java: -------------------------------------------------------------------------------- 1 | package TPPDekuBot; 2 | 3 | import java.io.File; 4 | import java.io.PrintWriter; 5 | import java.io.StringWriter; 6 | import java.security.SecureRandom; 7 | import java.util.concurrent.LinkedBlockingQueue; 8 | import java.util.concurrent.TimeUnit; 9 | 10 | public class PWTBattle extends Battle { 11 | 12 | private PWTType type; 13 | private PWTClass pwtclass; 14 | public Trainer player1; 15 | public Trainer player2; 16 | private Pokemon pokemon1; 17 | private Pokemon pokemon2; 18 | private PWTRound round; 19 | private boolean endBattle = false; 20 | public LinkedBlockingQueue p1msg; 21 | public LinkedBlockingQueue p2msg; 22 | 23 | public PWTBattle(BattleBot b, Trainer player1, Trainer player2, PWTType type, PWTClass pwtclass, PWTRound round) { 24 | super(b); 25 | this.type = type; 26 | this.pwtclass = pwtclass; 27 | this.player1 = player1; 28 | this.player2 = player2; 29 | this.round = round; 30 | p1msg = new LinkedBlockingQueue<>(); 31 | p2msg = new LinkedBlockingQueue<>(); 32 | } 33 | 34 | public PWTType getType() { 35 | return type; 36 | } 37 | 38 | public PWTClass getPwtclass() { 39 | return pwtclass; 40 | } 41 | 42 | public Trainer getPlayer1() { 43 | return player1; 44 | } 45 | 46 | public Trainer getPlayer2() { 47 | return player2; 48 | } 49 | 50 | public PWTRound getRound() { 51 | return round; 52 | } 53 | 54 | /** 55 | * Does the PWT Battle. 56 | * 57 | * @param channel Channel to send message to. 58 | * @return Trainer that was victorious, null if tie. 59 | * @throws Exception If Battle ends in an error 60 | */ 61 | public Trainer doBattle(String channel) throws Exception { 62 | Trainer winner = null; 63 | pokemon1 = player1.getPokemon(0); 64 | pokemon2 = player2.getPokemon(0); 65 | player1.removePokemon(0); 66 | player2.removePokemon(0); 67 | p1msg = new LinkedBlockingQueue<>(); 68 | p2msg = new LinkedBlockingQueue<>(); 69 | b.sendMessage(channel, player1.getTrainerName() + " sends out " + pokemon1.getName() + " (Level " + pokemon1.getLevel() + ")! " + player2.getTrainerName() + " sends out " + pokemon2.getName() + " (Level " + pokemon2.getLevel() + ")!"); 70 | do { 71 | singlebattle: 72 | while (!pokemon1.isFainted() && !pokemon2.isFainted()) { 73 | p1msg = new LinkedBlockingQueue<>(); 74 | p2msg = new LinkedBlockingQueue<>(); 75 | b.sendMessage(channel, "Waiting on communication..."); 76 | if (Trainer.isUserBot(player1.getTrainerName()) || !player1.isAI()) { 77 | b.sendWhisper(player1.getTrainerName(), "What will " + pokemon1.getName() + " do? (!move1)" + pokemon1.getMove1().getName() + ", (!move2)" + pokemon1.getMove2().getName() + ", (!move3)" + pokemon1.getMove3().getName() + ", (!move4)" + pokemon1.getMove4().getName() + " (!help)Additional Commands (reply in Battle Dungeon)"); 78 | } else { 79 | p1msg.add(PWTBattle.PWTAIMove(pokemon1, pokemon2)); 80 | } 81 | if (Trainer.isUserBot(player2.getTrainerName()) || !player2.isAI()) { 82 | b.sendWhisper(player2.getTrainerName(), "What will " + pokemon2.getName() + " do? (!move1)" + pokemon2.getMove1().getName() + ", (!move2)" + pokemon2.getMove2().getName() + ", (!move3)" + pokemon2.getMove3().getName() + ", (!move4)" + pokemon2.getMove4().getName() + " (!help)Additional Commands (reply in Battle Dungeon)"); 83 | } else { 84 | p2msg.add(PWTBattle.PWTAIMove(pokemon2, pokemon1)); 85 | } 86 | pokemon1.setFlinch(false); 87 | pokemon2.setFlinch(false); 88 | String p1move = ""; 89 | String p2move = ""; 90 | int p1switchTo = -1; 91 | int p2switchTo = -1; 92 | boolean p1switch = false, p2switch = false; 93 | boolean p1forfeit = false, p2forfeit = false; 94 | try { 95 | while (!p1move.startsWith("!move") && !p1move.startsWith("!run") && !p1move.startsWith("!switch")) { 96 | p1move = p1msg.poll(60, TimeUnit.SECONDS); 97 | if (p1move == null) { 98 | b.sendMessage(channel, player1.getTrainerName() + " did not select a move in time. " + player2 + " wins!"); 99 | player1.addPokemonAtBeginning(pokemon1); 100 | player2.addPokemonAtBeginning(pokemon2); 101 | player1.heal(); 102 | player2.heal(); 103 | return player2; 104 | } 105 | p1move = p1move.toLowerCase(); 106 | if (p1move.startsWith("!switch")) { 107 | if (p1move.length() >= 8) { 108 | if (Character.isDigit(p1move.charAt(7))) { 109 | p1switchTo = Integer.parseInt(p1move.split("!switch", 2)[1].split(" ", 2)[0]); 110 | if (p1switchTo >= 2 || p1switchTo < 0) { 111 | p1switchTo = -1; 112 | p1move = ""; 113 | b.sendMessage(channel, "/w " + player1.getTrainerName() + " Invalid Pokemon Position FUNgineer"); 114 | } else if (player1.getPokemon(p1switchTo).isFainted()) { 115 | p1switchTo = -1; 116 | p1move = ""; 117 | b.sendMessage(channel, "/w " + player1.getTrainerName() + " You cannot switch to a fainted Pokemon FUNgineer"); 118 | } else { 119 | p1switch = true; 120 | break; 121 | } 122 | } else { 123 | b.sendMessage(channel, "/w " + player1.getTrainerName() + " Syntax: !switch where is the number of the Pokemon you want to switch to from !list. Make sure there is no space between the number and the !switch command. For example, !switch0 will switch to the first Pokemon in the list."); 124 | p1switchTo = -1; 125 | p1move = ""; 126 | } 127 | } else { 128 | p1move = ""; 129 | } 130 | } else if (p1move.startsWith("!move")) { 131 | if (p1move.length() >= 5 && Character.isDigit(p1move.charAt(5))) { 132 | p1move = p1move.charAt(5) + ""; 133 | break; 134 | } else { 135 | p2move = ""; 136 | } 137 | } else if (p1move.startsWith("!run")) { 138 | p1forfeit = true; 139 | break; 140 | } else { 141 | p1move = ""; 142 | } 143 | } 144 | } catch (Exception ex) { 145 | StringWriter sw = new StringWriter(); 146 | PrintWriter pw = new PrintWriter(sw); 147 | ex.printStackTrace(pw); 148 | b.music.sendMessage(b.music.getChannel(), b.music.CHEF.mention() + " ```An error occurred while attempting to get " + player1 + "'s move\n" + sw.toString() + "```"); 149 | } 150 | try { 151 | while (!p2move.startsWith("!move") && !p2move.startsWith("!run") && !p2move.startsWith("!switch")) { 152 | p2move = p2msg.poll(60, TimeUnit.SECONDS); 153 | if (p2move == null) { 154 | b.sendMessage(channel, player2.getTrainerName() + " did not select a move in time. " + player1 + " wins!"); 155 | player1.addPokemonAtBeginning(pokemon1); 156 | player2.addPokemonAtBeginning(pokemon2); 157 | player1.heal(); 158 | player2.heal(); 159 | return player1; 160 | } 161 | p2move = p2move.toLowerCase(); 162 | if (p2move.startsWith("!switch")) { 163 | if (p2move.length() >= 8) { 164 | if (Character.isDigit(p2move.charAt(7))) { 165 | p2switchTo = Integer.parseInt(p2move.split("!switch", 2)[1].split(" ", 2)[0]); 166 | if (p2switchTo >= 2 || p2switchTo < 0) { 167 | p2switchTo = -1; 168 | p2move = ""; 169 | b.sendMessage(channel, "/w " + player2.getTrainerName() + " Invalid Pokemon Position FUNgineer"); 170 | } else if (player2.getPokemon(p2switchTo).isFainted()) { 171 | p2switchTo = -1; 172 | p2move = ""; 173 | b.sendMessage(channel, "/w " + player2.getTrainerName() + " You cannot switch to a fainted Pokemon FUNgineer"); 174 | } else { 175 | p2switch = true; 176 | break; 177 | } 178 | } else { 179 | b.sendMessage(channel, "/w " + player2.getTrainerName() + " Syntax: !switch where is the number of the Pokemon you want to switch to from !list. Make sure there is no space between the number and the !switch command. For example, !switch0 will switch to the first Pokemon in the list."); 180 | p2switchTo = -1; 181 | p2move = ""; 182 | } 183 | } else { 184 | p2move = ""; 185 | } 186 | } else if (p2move.startsWith("!move")) { 187 | if (p2move.length() >= 5 && Character.isDigit(p2move.charAt(5))) { 188 | p2move = p2move.charAt(5) + ""; 189 | break; 190 | } else { 191 | p2move = ""; 192 | } 193 | } else if (p2move.startsWith("!run")) { 194 | p2forfeit = true; 195 | break; 196 | } else { 197 | p2move = ""; 198 | } 199 | } 200 | } catch (Exception ex) { 201 | StringWriter sw = new StringWriter(); 202 | PrintWriter pw = new PrintWriter(sw); 203 | ex.printStackTrace(pw); 204 | b.music.sendMessage(b.music.getChannel(), b.music.CHEF.mention() + " ```An error occurred while attempting to get " + player2 + "'s move\n" + sw.toString() + "```"); 205 | } 206 | //here we go 207 | if (p1forfeit) { 208 | if (p2forfeit) { 209 | b.sendMessage(channel, player1.getTrainerName() + " forfeits! But " + player2 + " forfeits as well! This match ends in a draw!"); 210 | player1.addPokemonAtBeginning(pokemon1); 211 | player2.addPokemonAtBeginning(pokemon2); 212 | player1.heal(); 213 | player2.heal(); 214 | return null; 215 | } else { 216 | b.sendMessage(channel, player1.getTrainerName() + " forfeits! " + player2 + " wins!"); 217 | player1.addPokemonAtBeginning(pokemon1); 218 | player2.addPokemonAtBeginning(pokemon2); 219 | player1.heal(); 220 | player2.heal(); 221 | return player2; 222 | } 223 | } else if (p2forfeit) { 224 | if (p1forfeit) { 225 | b.sendMessage(channel, player2.getTrainerName() + " forfeits! But " + player1 + " forfeits as well! This match ends in a draw!"); 226 | player1.addPokemonAtBeginning(pokemon1); 227 | player2.addPokemonAtBeginning(pokemon2); 228 | player1.heal(); 229 | player2.heal(); 230 | return null; 231 | } else { 232 | b.sendMessage(channel, player2.getTrainerName() + " forfeits! " + player1 + " wins!"); 233 | player1.addPokemonAtBeginning(pokemon1); 234 | player2.addPokemonAtBeginning(pokemon2); 235 | player1.heal(); 236 | player2.heal(); 237 | return player1; 238 | } 239 | } 240 | if (p1switch && !p2switch) { 241 | String oldName = pokemon1.getName(); 242 | String newName = ""; 243 | player1.addPokemon(pokemon1); 244 | pokemon1 = player1.getPokemon(p1switchTo); 245 | player1.removePokemon(p1switchTo); 246 | newName = pokemon1.getName(); 247 | b.sendMessage(channel, player1.getTrainerName() + " calls back " + oldName + " and sent out " + newName + "!"); 248 | doMove(channel, p2move, pokemon2, pokemon1); 249 | if (pokemon1.isFainted()) { 250 | break singlebattle; 251 | } 252 | continue; 253 | } 254 | if (p2switch && !p1switch) { 255 | String oldName = pokemon2.getName(); 256 | String newName = ""; 257 | player2.addPokemon(pokemon2); 258 | pokemon2 = player2.getPokemon(p2switchTo); 259 | player2.removePokemon(p2switchTo); 260 | newName = pokemon2.getName(); 261 | b.sendMessage(channel, player2.getTrainerName() + " calls back " + oldName + " and sent out " + newName + "!"); 262 | doMove(channel, p1move, pokemon1, pokemon2); 263 | if (pokemon2.isFainted()) { 264 | break singlebattle; 265 | } 266 | continue; 267 | } 268 | if (p1switch && p2switch) { 269 | String oldName = pokemon1.getName(); 270 | String newName = ""; 271 | player1.addPokemon(pokemon1); 272 | pokemon1 = player1.getPokemon(p1switchTo); 273 | player1.removePokemon(p1switchTo); 274 | newName = pokemon1.getName(); 275 | b.sendMessage(channel, player1.getTrainerName() + " calls back " + oldName + " and sent out " + newName + "!"); 276 | oldName = pokemon2.getName(); 277 | newName = ""; 278 | player2.addPokemon(pokemon2); 279 | pokemon2 = player2.getPokemon(p2switchTo); 280 | player2.removePokemon(p2switchTo); 281 | newName = pokemon2.getName(); 282 | b.sendMessage(channel, player2.getTrainerName() + " calls back " + oldName + " and sent out " + newName + "!"); 283 | continue; 284 | } 285 | int p1speed = pokemon1.getStat(Stats.SPEED); 286 | int p2speed = pokemon2.getStat(Stats.SPEED); 287 | Pokemon first, second; 288 | String m1, m2; 289 | if (pokemon1.getStatus() == Status.PARALYSIS) { 290 | p1speed = p1speed / 2; 291 | } 292 | if (pokemon2.getStatus() == Status.PARALYSIS) { 293 | p2speed = p2speed / 2; 294 | } 295 | if (p1speed > p2speed) { 296 | first = pokemon1; 297 | m1 = p1move; 298 | second = pokemon2; 299 | m2 = p2move; 300 | } else if (p1speed < p2speed) { 301 | first = pokemon2; 302 | m1 = p2move; 303 | second = pokemon1; 304 | m2 = p1move; 305 | } else if (new SecureRandom().nextBoolean()) { 306 | first = pokemon1; 307 | m1 = p1move; 308 | second = pokemon2; 309 | m2 = p2move; 310 | } else { 311 | first = pokemon2; 312 | m1 = p2move; 313 | second = pokemon1; 314 | m2 = p1move; 315 | } 316 | boolean fainted = mainBattle(first, second, m1, m2, channel); 317 | if (fainted) { 318 | break singlebattle; 319 | } 320 | } 321 | if (pokemon1.isFainted()) { 322 | if (player1.getNumberOfPokemonRemaining() == 0) { 323 | break; 324 | } else { 325 | switchPokemon(player1, this.pokemon1, channel); 326 | if (endBattle) { 327 | b.sendMessage(channel, "Something went wrong this battle is now over all the Pokemon got stolen by Team Rocket RuleFive"); 328 | player1.addPokemonAtBeginning(pokemon1); 329 | player2.addPokemonAtBeginning(pokemon2); 330 | player1.heal(); 331 | player2.heal(); 332 | return null; 333 | } 334 | continue; 335 | } 336 | } else if (pokemon2.isFainted()) { 337 | if (player2.getNumberOfPokemonRemaining() == 0) { 338 | break; 339 | } else { 340 | switchPokemon(player2, this.pokemon2, channel); 341 | if (endBattle) { 342 | b.sendMessage(channel, "Something went wrong this battle is now over all the Pokemon got stolen by Team Rocket RuleFive"); 343 | player1.addPokemonAtBeginning(pokemon1); 344 | player2.addPokemonAtBeginning(pokemon2); 345 | player1.heal(); 346 | player2.heal(); 347 | return null; 348 | } 349 | continue; 350 | } 351 | } 352 | if (endBattle) { 353 | b.sendMessage(channel, "Something went wrong this battle is now over all the Pokemon got stolen by Team Rocket RuleFive"); 354 | player1.addPokemonAtBeginning(pokemon1); 355 | player2.addPokemonAtBeginning(pokemon2); 356 | player1.heal(); 357 | player2.heal(); 358 | return null; 359 | } 360 | } while (continueBattle()); 361 | player1.addPokemonAtBeginning(pokemon1); 362 | player2.addPokemonAtBeginning(pokemon2); 363 | if (pokemon1.isFainted()) { 364 | if (pokemon2.isFainted()) { 365 | b.sendMessage(channel, player1.getTrainerName() + " is out of usable Pokemon! " + player2 + " is out of usable Pokemon as well! The result is a draw! RuleFive"); 366 | player1.heal(); 367 | player2.heal(); 368 | return null; 369 | } 370 | b.sendMessage(channel, player1.getTrainerName() + " is out of usable Pokemon! " + player2 + " wins! PogChamp"); 371 | player1.heal(); 372 | player2.heal(); 373 | return player2; 374 | } 375 | if (pokemon2.isFainted()) { 376 | if (pokemon1.isFainted()) { 377 | b.sendMessage(channel, player2.getTrainerName() + " is out of usable Pokemon! " + player1 + " is out of usable Pokemon as well! The result is a draw! RuleFive"); 378 | player1.heal(); 379 | player2.heal(); 380 | return null; 381 | } 382 | b.sendMessage(channel, player2.getTrainerName() + " is out of usable Pokemon! " + player1 + " wins! PogChamp"); 383 | player1.heal(); 384 | player2.heal(); 385 | return player1; 386 | } 387 | System.err.println("nulled"); 388 | player1.heal(); 389 | player2.heal(); 390 | return winner; 391 | } 392 | 393 | /** 394 | * This is for Switching Pokemon after the player's Pokemon has fainted. 395 | * 396 | * @param player Player being forced to Switch 397 | * @param playerPokemon Fainted Pokemon 398 | * @param channel Channel to send Message to 399 | */ 400 | public void switchPokemon(Trainer player, Pokemon playerPokemon, String channel) { 401 | p1msg = new LinkedBlockingQueue<>(); 402 | p2msg = new LinkedBlockingQueue<>(); 403 | b.sendMessage(channel, playerPokemon.getName() + " fainted! What Pokemon will " + player.getTrainerName() + " switch to?"); 404 | LinkedBlockingQueue feed = (player.getTrainerName().equalsIgnoreCase(player1.getTrainerName()) ? p1msg : p2msg); 405 | if (Trainer.isUserBot(player.getTrainerName()) || !player.isAI()) { 406 | b.sendWhisper(player1.getTrainerName(), "Type !list to get a list of your Pokemon. Type !switch to switch to that Pokemon (for example, the if you want to switch to the first Pokemon, type !switch0 )"); 407 | try { 408 | int switchTo = -1; 409 | String temp = ""; 410 | while (!temp.startsWith("!switch")) { 411 | temp = feed.poll(60, TimeUnit.SECONDS); 412 | if (temp == null) { 413 | if (player.getTrainerName().equalsIgnoreCase(player1.getTrainerName())) { 414 | b.sendMessage(channel, player1.getTrainerName() + " did not select a new Pokemon in time. " + player2.getTrainerName() + " wins!"); 415 | } else { 416 | b.sendMessage(channel, player2.getTrainerName() + " did not select a new Pokemon in time. " + player1.getTrainerName() + " wins!"); 417 | } 418 | endBattle = true; 419 | player1.addPokemonAtBeginning(pokemon1); 420 | player2.addPokemonAtBeginning(pokemon2); 421 | player1.heal(); 422 | player2.heal(); 423 | return; 424 | } 425 | if (temp.startsWith("!switch") && temp.length() >= 8) { 426 | if (!Character.isDigit(temp.charAt(7))) { 427 | temp = ""; 428 | b.sendMessage(channel, "/w " + player.getTrainerName() + " Invalid Pokemon Position FUNgineer"); 429 | continue; 430 | } 431 | switchTo = Integer.parseInt(temp.split("!switch", 2)[1].split(" ", 2)[0]); 432 | if (switchTo >= 2 || switchTo < 0) { 433 | temp = ""; 434 | b.sendMessage(channel, "/w " + player.getTrainerName() + " Invalid Pokemon Position FUNgineer"); 435 | continue; 436 | } 437 | if (player.getPokemon(switchTo).isFainted()) { 438 | temp = ""; 439 | b.sendMessage(channel, "/w " + player.getTrainerName() + " You cannot switch to a fainted Pokemon FUNgineer"); 440 | continue; 441 | } 442 | if (player.getTrainerName().equalsIgnoreCase(player1.getTrainerName())) { 443 | p1msg = new LinkedBlockingQueue<>(); 444 | player1.getPokemon().add(this.pokemon1); 445 | this.pokemon1 = player1.getPokemon(switchTo); 446 | player1.removePokemon(switchTo); 447 | b.sendMessage(channel, player + " sends out " + this.pokemon1 + " (Level " + this.pokemon1.getLevel() + ")!"); 448 | break; 449 | } else { 450 | p2msg = new LinkedBlockingQueue<>(); 451 | player2.getPokemon().add(this.pokemon2); 452 | this.pokemon2 = player2.getPokemon(switchTo); 453 | player2.removePokemon(switchTo); 454 | b.sendMessage(channel, player + " sends out " + this.pokemon2 + " (Level " + this.pokemon2.getLevel() + ")!"); 455 | break; 456 | } 457 | } 458 | } 459 | } catch (Exception ex) { 460 | StringWriter sw = new StringWriter(); 461 | PrintWriter pw = new PrintWriter(sw); 462 | ex.printStackTrace(pw); 463 | b.music.sendMessage(b.music.getChannel(), b.music.CHEF.mention() + " ```An error occurred while attempting to switch Pokemon\n" + sw.toString() + "\nPlayer=" + player.getTrainerName() + ",Pokemon=" + playerPokemon.getName() + "```"); 464 | } 465 | } else if (player.getTrainerName().equalsIgnoreCase(player1.getTrainerName())) { 466 | p1msg = new LinkedBlockingQueue<>(); 467 | player1.getPokemon().add(this.pokemon1); 468 | this.pokemon1 = player1.getPokemon(0); 469 | player1.removePokemon(0); 470 | b.sendMessage(channel, player + " sends out " + this.pokemon1 + " (Level " + this.pokemon1.getLevel() + ")!"); 471 | } else { 472 | p2msg = new LinkedBlockingQueue<>(); 473 | player2.getPokemon().add(this.pokemon2); 474 | this.pokemon2 = player2.getPokemon(0); 475 | player2.removePokemon(0); 476 | b.sendMessage(channel, player + " sends out " + this.pokemon2 + " (Level " + this.pokemon2.getLevel() + ")!"); 477 | } 478 | } 479 | 480 | public boolean mainBattle(Pokemon p1, Pokemon p2, String move1, String move2, String channel) { 481 | doMove(channel, move1, p1, p2); 482 | if (!p2.isFainted()) { 483 | if (p2.isFlinched()) { 484 | p2.setFlinch(false); 485 | b.sendMessage(channel, p2.getName() + " flinched!"); 486 | return false; 487 | } 488 | doMove(channel, move2, p2, p1); 489 | return false; 490 | } else { 491 | return true; 492 | } 493 | } 494 | 495 | private void doMove(String channel, String move, Pokemon user, Pokemon opponent) { 496 | int m = Integer.parseInt(move); 497 | b.sendMessage(channel, user.attack(opponent, user.getMoveByNumber(m), this).replace("\n", " ")); 498 | } 499 | 500 | public boolean continueBattle() { 501 | if (pokemon1.isFainted()) { 502 | if (player1.getNumberOfPokemonRemaining() == 0) { 503 | return false; 504 | } 505 | } 506 | if (pokemon2.isFainted()) { 507 | if (player2.getNumberOfPokemonRemaining() == 0) { 508 | return false; 509 | } 510 | } 511 | return true; 512 | } 513 | 514 | public static File determineMusic(PWTBattle battle) { 515 | battle.b.music.clear(); 516 | if (battle.getRound() == PWTRound.FINALS && battle.getType() != PWTType.CHAMPIONS) { 517 | return new File(BattleBot.ROOT_PATH + "pwt\\pwt-final.mp3"); 518 | } 519 | File toReturn = new File(BattleBot.ROOT_PATH + "pwt\\pwt-trainer.mp3"); 520 | Trainer ai = null; 521 | Trainer p1 = battle.player1; 522 | Trainer p2 = battle.player2; 523 | if (p1.getTrnClass().contains("Champion")) { 524 | ai = p1; 525 | } else if (p2.getTrnClass().contains("Champion")) { 526 | ai = p2; 527 | } else if (p1.getTrnClass().contains("Gym Leader")) { 528 | ai = p1; 529 | } else if (p2.getTrnClass().contains("Gym Leader")) { 530 | ai = p2; 531 | } else { 532 | ai = new SecureRandom().nextBoolean() ? p1 : p2; 533 | } 534 | String trnClass = ai.getTrnClass(); 535 | if (trnClass.contains("Champion")) { 536 | switch (ai.getRegion()) { 537 | case KANTO: 538 | toReturn = new File(BattleBot.ROOT_PATH + "pwt\\pwt-kanto-champion.mp3"); 539 | break; 540 | case JOHTO: 541 | toReturn = new File(BattleBot.ROOT_PATH + "pwt\\pwt-johto-champion.mp3"); 542 | break; 543 | case HOENN: 544 | toReturn = new File(BattleBot.ROOT_PATH + "pwt\\pwt-hoenn-champion.mp3"); 545 | break; 546 | case SINNOH: 547 | toReturn = new File(BattleBot.ROOT_PATH + "pwt\\pwt-sinnoh-champion.mp3"); 548 | break; 549 | case UNOVA: 550 | toReturn = new File(BattleBot.ROOT_PATH + "pwt\\pwt-unova-champion.mp3"); 551 | break; 552 | default: 553 | File[] files = {new File(BattleBot.ROOT_PATH + "pwt\\pwt-unova-champion.mp3"), new File(BattleBot.ROOT_PATH + "pwt\\pwt-sinnoh-champion.mp3"), new File(BattleBot.ROOT_PATH + "pwt\\pwt-hoenn-champion.mp3"), toReturn = new File(BattleBot.ROOT_PATH + "pwt\\pwt-johto-champion.mp3"), toReturn = new File(BattleBot.ROOT_PATH + "pwt\\pwt-kanto-champion.mp3")}; 554 | toReturn = files[new SecureRandom().nextInt(files.length)]; 555 | break; 556 | } 557 | } else if (trnClass.contains("Gym Leader")) { 558 | switch (ai.getRegion()) { 559 | case KANTO: 560 | toReturn = new File(BattleBot.ROOT_PATH + "pwt\\pwt-kanto-gym.mp3"); 561 | break; 562 | case JOHTO: 563 | toReturn = new File(BattleBot.ROOT_PATH + "pwt\\pwt-johto-gym.mp3"); 564 | break; 565 | case HOENN: 566 | toReturn = new File(BattleBot.ROOT_PATH + "pwt\\pwt-hoenn-gym.mp3"); 567 | break; 568 | case SINNOH: 569 | toReturn = new File(BattleBot.ROOT_PATH + "pwt\\pwt-sinnoh-gym.mp3"); 570 | break; 571 | case UNOVA: 572 | toReturn = new File(BattleBot.ROOT_PATH + "pwt\\pwt-unova-gym.mp3"); 573 | break; 574 | default: 575 | File[] files = {new File(BattleBot.ROOT_PATH + "pwt\\pwt-unova-gym.mp3"), new File(BattleBot.ROOT_PATH + "pwt\\pwt-sinnoh-gym.mp3"), new File(BattleBot.ROOT_PATH + "pwt\\pwt-hoenn-gym.mp3"), toReturn = new File(BattleBot.ROOT_PATH + "pwt\\pwt-johto-gym.mp3"), toReturn = new File(BattleBot.ROOT_PATH + "pwt\\pwt-kanto-gym.mp3")}; 576 | toReturn = files[new SecureRandom().nextInt(files.length)]; 577 | break; 578 | } 579 | } 580 | return toReturn; 581 | } 582 | 583 | /** 584 | * Selects the AI Move for PWT Battles. Easily expandable in the future. 585 | * 586 | * @param user AI User Pokemon 587 | * @param opponent Opponent Pokemon 588 | * @return String containing which move to use 589 | */ 590 | public static String PWTAIMove(Pokemon user, Pokemon opponent) { 591 | Move mostPowerful = Move.selectBestMove(user, opponent); 592 | if (mostPowerful == null) { 593 | System.err.println("Move is null!!"); 594 | return "!move" + new SecureRandom().nextInt(3) + 1; 595 | } 596 | if (mostPowerful.equals(user.getMove1())) { 597 | return "!move1"; 598 | } else if (mostPowerful.equals(user.getMove2())) { 599 | return "!move2"; 600 | } else if (mostPowerful.equals(user.getMove3())) { 601 | return "!move3"; 602 | } else { 603 | return "!move4"; 604 | } 605 | } 606 | } 607 | -------------------------------------------------------------------------------- /src/TPPDekuBot/PWTRound.java: -------------------------------------------------------------------------------- 1 | package TPPDekuBot; 2 | 3 | public enum PWTRound { 4 | FIRST_ROUND, SECOND_ROUND, THIRD_ROUND, SEMIFINALS, FINALS; 5 | 6 | public String getText() { 7 | switch (this) { 8 | case FIRST_ROUND: 9 | return "This is a First Round "; 10 | case SECOND_ROUND: 11 | return "This is a Second Round "; 12 | case THIRD_ROUND: 13 | return "This is a Third Round "; 14 | case SEMIFINALS: 15 | return "This is a Semifinal "; 16 | case FINALS: 17 | return "PagChomp This is the FINAL "; 18 | default: 19 | return ""; 20 | } 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/TPPDekuBot/PWTType.java: -------------------------------------------------------------------------------- 1 | package TPPDekuBot; 2 | 3 | public enum PWTType { 4 | RANDOM, KANTO_GYM, JOHTO_GYM, HOENN_GYM, SINNOH_GYM, UNOVA_GYM, WORLD_GYM, CHAMPIONS, SPECIAL, TYPE_NORMAL, TYPE_FIRE, TYPE_FIGHTING, TYPE_WATER, TYPE_FLYING, TYPE_GRASS, TYPE_POISON, TYPE_ELECTRIC, TYPE_GROUND, TYPE_PSYCHIC, TYPE_ROCK, TYPE_ICE, TYPE_BUG, TYPE_DRAGON, TYPE_GHOST, TYPE_DARK, TYPE_STEEL, TYPE_FAIRY; 5 | 6 | public static PWTType typeConverter(String type) { 7 | type = type.toUpperCase().replace("-", "_"); 8 | for (PWTType el : PWTType.values()) { 9 | if (el.name().equalsIgnoreCase(type)) { 10 | return el; 11 | } 12 | } 13 | System.err.println("Type input mismatch, inputted \"" + type + "\""); 14 | return null; 15 | } 16 | 17 | @Override 18 | public String toString() { 19 | String toReturn = ""; 20 | switch (this) { 21 | case KANTO_GYM: 22 | case JOHTO_GYM: 23 | case HOENN_GYM: 24 | case SINNOH_GYM: 25 | case UNOVA_GYM: 26 | case WORLD_GYM: 27 | toReturn += this.name().split("_", 2)[0]; 28 | toReturn = toReturn.charAt(0) + toReturn.substring(1).toLowerCase() + "Gym Leader's"; 29 | break; 30 | case RANDOM: 31 | case CHAMPIONS: 32 | case SPECIAL: 33 | toReturn = this.name().charAt(0) + this.name().substring(1).toLowerCase(); 34 | break; 35 | case TYPE_NORMAL: 36 | case TYPE_FIRE: 37 | case TYPE_FIGHTING: 38 | case TYPE_WATER: 39 | case TYPE_FLYING: 40 | case TYPE_GRASS: 41 | case TYPE_POISON: 42 | case TYPE_ELECTRIC: 43 | case TYPE_GROUND: 44 | case TYPE_PSYCHIC: 45 | case TYPE_ROCK: 46 | case TYPE_ICE: 47 | case TYPE_BUG: 48 | case TYPE_DRAGON: 49 | case TYPE_GHOST: 50 | case TYPE_DARK: 51 | case TYPE_STEEL: 52 | case TYPE_FAIRY: 53 | toReturn = this.name().split("_", 2)[1]; 54 | toReturn = toReturn.charAt(0) + toReturn.substring(1).toLowerCase(); 55 | break; 56 | } 57 | return toReturn; 58 | } 59 | } 60 | 61 | enum PWTClass { 62 | NORMAL, MASTER 63 | } 64 | -------------------------------------------------------------------------------- /src/TPPDekuBot/PWTournament.java: -------------------------------------------------------------------------------- 1 | package TPPDekuBot; 2 | 3 | import java.io.File; 4 | import java.io.PrintWriter; 5 | import java.io.StringWriter; 6 | import java.security.SecureRandom; 7 | import java.util.*; 8 | 9 | public class PWTournament { 10 | 11 | private PWTType type; 12 | private PWTClass pwtclass; 13 | private int partNum; 14 | private ArrayList participants; 15 | private ArrayList bots; 16 | 17 | public PWTournament(PWTType type, PWTClass pwtclass, ArrayList participants, ArrayList bots) { 18 | this.type = type; 19 | this.pwtclass = pwtclass; 20 | this.participants = participants; 21 | this.bots = bots; 22 | partNum = 8; 23 | if (participants.size() < 4) { 24 | for (int i = 0; i < 3; i++) { 25 | try { 26 | participants.get(i); 27 | } catch (IndexOutOfBoundsException ex) { 28 | int at = new SecureRandom().nextInt(bots.size()); 29 | Trainer rand = bots.get(at); 30 | participants.add(rand); 31 | bots.remove(at); 32 | } 33 | } 34 | } 35 | } 36 | 37 | public PWTType getType() { 38 | return type; 39 | } 40 | 41 | public PWTClass getPwtclass() { 42 | return pwtclass; 43 | } 44 | 45 | public int getPartNum() { 46 | return partNum; 47 | } 48 | 49 | public ArrayList getParticipants() { 50 | return participants; 51 | } 52 | 53 | public void addParticipant(Trainer part) { 54 | participants.add(part); 55 | } 56 | 57 | public void removeParticipant(Trainer part) { 58 | participants.remove(part); 59 | } 60 | 61 | public void removeParticipant(String name) { 62 | Trainer toRemove = null; 63 | for (Trainer el : participants) { 64 | if (el.getTrainerName().equalsIgnoreCase(name)) { 65 | toRemove = el; 66 | break; 67 | } 68 | } 69 | if (toRemove != null) { 70 | participants.remove(toRemove); 71 | } 72 | } 73 | 74 | public void arrangeBracket() { 75 | ArrayList old = (ArrayList) participants.clone(); 76 | ArrayList newBracket = new ArrayList<>(); 77 | for (int i = 0; i < old.size(); i++) { 78 | Trainer el = old.get(i); 79 | if (!el.isAI() || Trainer.isUserBot(el.getTrainerName())) { 80 | newBracket.add(el); 81 | int at = new SecureRandom().nextInt(bots.size()); 82 | Trainer add = bots.get(at); 83 | newBracket.add(add); 84 | bots.remove(at); 85 | } 86 | } 87 | while (newBracket.size() < 8) { 88 | int at = new SecureRandom().nextInt(bots.size()); 89 | Trainer add = bots.get(at); 90 | newBracket.add(add); 91 | bots.remove(at); 92 | } 93 | participants = newBracket; 94 | } 95 | 96 | public void doTourney(BattleBot b, String channel) throws Exception { 97 | PWTRound pwtround = PWTRound.FIRST_ROUND; 98 | int loop = 0; 99 | while (partNum > 1) { 100 | if (loop == 1) { 101 | pwtround = PWTRound.SEMIFINALS; 102 | } 103 | if (loop == 2) { 104 | pwtround = PWTRound.FINALS; 105 | } 106 | ArrayList battles = new ArrayList<>(); 107 | for (int i = 0, j = i + 1; j < participants.size(); i++, j++) { 108 | participants.get(i).heal(); 109 | participants.get(j).heal(); 110 | battles.add(new PWTBattle(b, participants.get(i), participants.get(j), type, pwtclass, pwtround)); 111 | i = j; 112 | j++; 113 | if ((battles.size() == 4 && pwtround == PWTRound.FIRST_ROUND) || (battles.size() == 2 && pwtround == PWTRound.SEMIFINALS) || (battles.size() == 1 && pwtround == PWTRound.FINALS)) { 114 | break; 115 | } 116 | } 117 | ArrayList oldList = (ArrayList) participants.clone(); 118 | participants = new ArrayList<>(); 119 | for (PWTBattle el : battles) { 120 | boolean lastAI = false; 121 | b.sendMessage(channel, pwtround.getText() + "match of the " + type + " tournament! This match is between " + el.player1 + " and " + el.player2 + "!"); 122 | if (pwtround != PWTRound.FINALS && (el.player1.isAI() && !Trainer.isUserBot(el.player1.getTrainerName())) && (el.player2.isAI() && !Trainer.isUserBot(el.player2.getTrainerName()))) { 123 | b.music.play(new File(b.ROOT_PATH + "\\pwt\\pwt-lobby.mp3")); 124 | lastAI = true; 125 | Trainer winner = new SecureRandom().nextBoolean() ? el.player1 : el.player2; 126 | Trainer loser = (winner.getTrainerName().equalsIgnoreCase(el.player1.getTrainerName()) ? el.player2 : el.player1); 127 | b.sendMessage(channel, "After a hard fought battle, " + winner + " was victorious over " + loser + "! PogChamp"); 128 | partNum--; 129 | for (int i = 0; i < oldList.size(); i++) { 130 | if (oldList.get(i).getTrainerName().equalsIgnoreCase(winner.getTrainerName())) { 131 | participants.add(oldList.get(i)); 132 | break; 133 | } 134 | } 135 | } else { 136 | try { 137 | b.music.play(PWTBattle.determineMusic(el)); 138 | b.battle = el; 139 | Trainer winner = el.doBattle(channel); 140 | b.battle = null; 141 | if (winner == null) { 142 | throw new Exception("No winner in last match, aborting PWT"); //¯\_(ツ)_/¯ for now 143 | } else { 144 | b.music.play(new File(b.ROOT_PATH+"\\pwt\\pwt-victory-battle.mp3")); 145 | partNum--; 146 | for (int i = 0; i < oldList.size(); i++) { 147 | if (oldList.get(i).getTrainerName().equalsIgnoreCase(winner.getTrainerName())) { 148 | participants.add(oldList.get(i)); 149 | break; 150 | } 151 | } 152 | } 153 | } catch (Exception ex) { 154 | StringWriter sw = new StringWriter(); 155 | PrintWriter pw = new PrintWriter(sw); 156 | ex.printStackTrace(pw); 157 | b.music.sendMessage(b.music.getChannel(), b.music.CHEF.mention() + " ```An error occurred in the PWT!!\n" + sw.toString() + "```"); 158 | return; 159 | } 160 | } 161 | if (pwtround != PWTRound.FINALS) { 162 | b.sendMessage(channel, "Next match starting in less than 10 seconds. Get ready!"); 163 | try { 164 | Thread.sleep(17000); 165 | } catch (Exception ex) { 166 | 167 | } 168 | b.music.clear(); 169 | } else { 170 | break; 171 | } 172 | } 173 | loop++; 174 | } 175 | Trainer grandWinner = participants.get(0); 176 | b.sendMessage(channel, grandWinner + " has won the " + type + " Pokemon World Tournament! PagChomp"); 177 | b.inPWT = false; 178 | } 179 | 180 | public static Trainer generateTrainer(PWTType type, PWTClass pwtclass) { 181 | String[] classes = {"Ace Trainer", "Beauty", "Biker", "Bird Keeper", "Blackbelt", "Bug Catcher", "Burglar", "Channeler", "Cue Ball", "Engineer", "Fisherman", "Gambler", "Hiker", "Jr. Trainer", "Juggler", "Lass", "PokeManiac", "Pokemon Trainer", "Psychic", "Rocker", "Sailor", "Scientist", "Super Nerd", "Swimmer", "Tamer", "Youngster", "Boarder", "Camper", "Firebreather", "Guitarist", "Medium", "Officer", "Picnicker", "Pokefan", "Sage", "Skier", "Swimmer", "Teacher"}; 182 | String[] names = {"Samantha", "Robby", "Ray", "Carter", "Ellen", "Dawn", "Kirk", "Terrell", "Toby", "Simon", "Charlie", "Michael", "Phillip", "Bryan", "Russ", "Noland", "Margret", "Parker", "Daniel", "Dave", "Chase", "Ruth", "Brian", "Kevin", "Wayne", "Mike", "Bill", "Alfred", "Braxton", "Miki", "Trevor", "Seth", "Brenda", "Fidel", "Abe", "Stanly", "Al", "Fritz", "Paul", "Nicole", "Heidi", "Doug", "Horton", "Neal", "Ben", "Harris", "Paula", "Tully", "Red", "Gaven", "Izzy", "Ronald", "Jenn", "Tim", "Jerome", "Todd", "Emma", "Pat", "Rex", "Cameron", "Miguel", "Brad", "Lisa", "Samuel", "Kenneth", "Perry", "Owen", "Jody", "Eddie", "Jason", "Ernest", "Shawn", "Brooks", "Denise", "Rodney", "Yoshi", "Johnny", "Benny", "Benjamin", "Dean", "Sid", "Helenna", "Brooke", "Teru", "Keith", "Hank", "Darin", "Miller", "Oak", "Ed", "Tucker", "Wade", "Gregory", "Edward", "Jake", "Larry", "Jaclyn", "Rick", "Rich", "Cindy", "Riley", "Henry", "Diana", "Brett", "Kaylee", "Kent", "Kuni", "Brandon", "Joel", "Mitch", "Ryan", "Timmy", "Joey", "Bret", "Lung", "John", "Chow", "Sammy", "George", "Reena", "Shirley", "Leonard", "Phil", "Don", "Victoria", "Mathew", "Wilton", "Spencer", "Troy", "Tom", "Douglas", "Paton", "Kiyo", "Robin", "Miriam", "Preston", "Flint", "Gilbert", "Kelsey", "Richard", "Theresa", "Ross", "Tara", "Jimmy", "Bernie", "Colin", "James", "Harold", "Ned", "Salma", "Julia", "Sally", "Julie", "Garrett", "Peter", "Lao", "Frank", "Hope", "Ali", "Tony", "Tyler", "Bob", "Albert", "Gwen", "Li", "Charles", "Rob", "Rod", "Alice", "Alan", "Brent", "Sidney", "Caroline", "Elijah", "Ron", "Ping", "David", "Bonita", "Rachael", "Roy", "Andy", "Dirk", "Ann", "Krise", "Dudley", "Zach", "Rebecca", "Irwin", "Otis", "Connie", "Quentin", "Zeke", "Zuki", "Jonah", "Berke", "Glenn", "Walt", "Koji", "Dwayne", "Burt", "Andre", "Valerie", "Leroy", "Franklin", "Cody", "Jay", "Ralph", "Kara", "Beth", "Gina", "Ivan", "Theo", "Parry", "Joshua", "Alex", "Kenji", "Sayo", "Lois", "Allen", "Briana", "Bridget", "Russell", "Ken", "Ian", "Sean", "Fran", "Denis", "Georgia", "Willy", "Debra", "Bethany", "Edgar", "Haley", "Kate", "Stan", "Vance", "Sharon", "Aaron", "Jose", "Josh", "Boris", "Thomas", "Norman", "Jed", "Cale", "Norton", "Martin", "Megan", "Olivia", "Issac", "Jasper", "Hal", "Clyde", "Calvin", "Hillary", "Lloyd", "Lola", "Liz", "Duncan", "Scott", "Huey", "Tanya", "Arthur", "Eric", "Elliot", "Tommy", "Erik", "Edna", "Erin", "Martha", "Nob", "Daryl", "Harry", "Erick", "Andrew", "Allan", "William", "Kim", "Kenny", "Barry", "Markus", "Jerry", "Randall", "Wai", "Marc", "Timothy", "Irene", "Mark", "Nancy", "Greg", "Linda", "Warren", "Crissy", "Jessica", "Mary", "Billy", "Vincent", "Barney", "Carlene", "Herman", "Janice", "Marvin", "Hugh", "Jin", "Jim", "Jeremy", "Dale", "Hugo", "Harvey", "Elaine", "Stephen", "Michelle", "Blake", "Keigo", "Gregg", "Colette", "Danny", "Kazu", "Katie", "Naoko", "Cassie", "Masa", "Wendy", "Roxanne", "Dana", "Barny", "Cara", "Nikki", "Dylan", "Tiffany", "Reli", "Eusine", "Carrie", "Jill", "Lori", "Cybil", "Chad", "Jaime", "Carol", "Mikey", "Colton", "Joyce", "Nathan", "Darian", "Kendra", "Doris", "Ethan", "Edmond", "Kelly", "Dan", "Ajdnnw", "Steve", "Jeff", "Marcos", "Corey", "Clarissa", "Shane", "Grace", "Dillon", "Quinn", "Shannon", "Beverly", "Robert", "Angelica", "Jared", "Nate", "Joe", "Nico", "Yasu", "Kyle", "Nick", "Cal", "Arnold", "Eugene", "Derek", "Sam", "Lyle", "Raymond", "Susie", "Gaku", "Donald", "Arnie", "Virgil", "Jovan", "Jack", "Justin", "Kipp", "Bailey", "Jeffrey", "Gordon", "Walter", "Ethel", "Anthony", "Dick", "Ricky", "Ted", "Laura", "Roland", "Lamar", "Lewis", "Veronica", "Brock", "Misty", "Lt. Surge", "Erika", "Koga", "Janine", "Sabrina", "Blaine", "Giovanni", "Blue", "Falkner", "Bugsy", "Whitney", "Morty", "Chuck", "Jasmine", "Pryce", "Clair", "Roxanne", "Brawly", "Wattson", "Flannery", "Norman", "Winona", "Tate", "Liza", "Wallace", "Juan", "Roark", "Gardenia", "Maylene", "Crusher Wake", "Fantina", "Byron", "Candice", "Volkner", "Cilan", "Chili", "Cress", "Lenora", "Burgh", "Elesa", "Clay", "Skyla", "Brycen", "Drayden", "Iris", "Cheren", "Roxie", "Burgh", "Elesa", "Clay", "Marlon", "Red", "Blue", "Lance", "Steven", "Wallace", "Cynthia", "Alder", "23forces", "groudonger", "frunky5"}; 183 | String name = names[new SecureRandom().nextInt(names.length)]; 184 | String trnClass = ""; 185 | Region region = null; 186 | switch (name) { 187 | case "Brock": 188 | case "Misty": 189 | case "Lt. Surge": 190 | case "Erika": 191 | case "Koga": 192 | case "Janine": 193 | case "Sabrina": 194 | case "Blaine": 195 | case "Giovanni": 196 | trnClass = "Gym Leader"; 197 | region = Region.KANTO; 198 | break; 199 | case "Falkner": 200 | case "Bugsy": 201 | case "Whitney": 202 | case "Morty": 203 | case "Chuck": 204 | case "Jasmine": 205 | case "Pryce": 206 | case "Clair": 207 | trnClass = "Gym Leader"; 208 | region = Region.JOHTO; 209 | break; 210 | case "Roxanne": 211 | case "Brawly": 212 | case "Wattson": 213 | case "Flannery": 214 | case "Norman": 215 | case "Winona": 216 | case "Tate": 217 | case "Liza": 218 | case "Juan": 219 | case "groudonger": 220 | trnClass = "Gym Leader"; 221 | region = Region.HOENN; 222 | break; 223 | case "Roark": 224 | case "Gardenia": 225 | case "Maylene": 226 | case "Crusher Wake": 227 | case "Fantina": 228 | case "Byron": 229 | case "Candice": 230 | case "Volkner": 231 | trnClass = "Gym Leader"; 232 | region = Region.SINNOH; 233 | break; 234 | case "Cilan": 235 | case "Chili": 236 | case "Cress": 237 | case "Lenora": 238 | case "Burgh": 239 | case "Elesa": 240 | case "Clay": 241 | case "Skyla": 242 | case "Brycen": 243 | case "Drayden": 244 | case "Cheren": 245 | case "Roxie": 246 | case "Marlon": //jesus fuck unova has a lot of gym leaders 247 | trnClass = "Gym Leader"; 248 | region = Region.UNOVA; 249 | break; 250 | case "frunky5": 251 | trnClass = "Gym Leader"; 252 | region = Region.getRandomRegion(); 253 | break; 254 | case "Blue": 255 | trnClass = "Kanto Champion"; 256 | region = Region.KANTO; 257 | break; 258 | case "Lance": 259 | trnClass = "Johto Champion"; 260 | region = Region.JOHTO; 261 | break; 262 | case "Red": 263 | trnClass = "Kanto Champion"; 264 | region = Region.JOHTO; //this is intentional. see the actual PWT for more info 265 | break; 266 | case "Wallace": 267 | case "Steven": 268 | trnClass = "Hoenn Champion"; 269 | region = Region.HOENN; 270 | break; 271 | case "Cynthia": 272 | trnClass = "Sinnoh Champion"; 273 | region = Region.SINNOH; 274 | break; 275 | case "Alder": 276 | trnClass = "Unova Champion"; 277 | region = Region.UNOVA; 278 | break; 279 | case "23forces": 280 | trnClass = "Elite Four"; 281 | region = Region.getRandomRegion(); 282 | break; 283 | default: 284 | trnClass = classes[new SecureRandom().nextInt(classes.length)]; 285 | region = Region.getRandomRegion(); 286 | break; 287 | } 288 | ArrayList pokemon = Trainer.generatePokemon(3, 50); 289 | Trainer t = new Trainer(name, trnClass, region, pokemon, true); 290 | return t; 291 | } 292 | } 293 | -------------------------------------------------------------------------------- /src/TPPDekuBot/Pokeball.java: -------------------------------------------------------------------------------- 1 | package TPPDekuBot; 2 | 3 | public class Pokeball extends Item { 4 | 5 | public enum Type { 6 | 7 | POKEBALL, GREATBALL, ULTRABALL, MASTERBALL, SAFARIBALL; 8 | } 9 | private double catchModifier; 10 | private Pokeball.Type type; 11 | 12 | public Pokeball(String name, ItemType iType, Pokeball.Type type) { 13 | super(name, iType); 14 | this.type = type; 15 | switch (type) { 16 | case POKEBALL: 17 | catchModifier = 1.0; 18 | break; 19 | case GREATBALL: 20 | catchModifier = 1.5; 21 | break; 22 | case ULTRABALL: 23 | catchModifier = 2.0; 24 | break; 25 | case MASTERBALL: 26 | catchModifier = 255.0; 27 | break; 28 | case SAFARIBALL: 29 | catchModifier = 1.5; 30 | break; 31 | } 32 | } 33 | 34 | public double getCatchModifier() { 35 | return catchModifier; 36 | } 37 | 38 | public Type getType() { 39 | return type; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/TPPDekuBot/PokemonBaseStat.java: -------------------------------------------------------------------------------- 1 | package TPPDekuBot; 2 | 3 | import java.util.*; 4 | import java.io.*; 5 | 6 | /** 7 | * Holds the Pokemon base stats for easy getting. 8 | * 9 | * @author Michael 10 | */ 11 | public class PokemonBaseStat implements Serializable{ 12 | 13 | private String name; 14 | private int id; 15 | private int attack, defense, spAttack, spDefense, speed, HP; 16 | 17 | public PokemonBaseStat(int id, String name, int attack, int defense, int spAttack, int spDefense, int speed, int HP) { 18 | this.name = name; 19 | this.id = id; 20 | this.attack = attack; 21 | this.defense = defense; 22 | this.spAttack = spAttack; 23 | this.spDefense = spDefense; 24 | this.speed = speed; 25 | this.HP = HP; 26 | } 27 | 28 | public int getStat(Stats stat) { 29 | int toReturn = -1; 30 | switch (stat) { 31 | case HP: 32 | toReturn = HP; 33 | break; 34 | case ATTACK: 35 | toReturn = attack; 36 | break; 37 | case DEFENSE: 38 | toReturn = defense; 39 | break; 40 | case SP_ATTACK: 41 | toReturn = spAttack; 42 | break; 43 | case SP_DEFENSE: 44 | toReturn = spDefense; 45 | break; 46 | case SPEED: 47 | toReturn = speed; 48 | break; 49 | } 50 | return toReturn; 51 | } 52 | 53 | public static int getStat(int id, Stats stat) { 54 | PokemonBaseStat base = null; 55 | while (base == null) { 56 | try (FileInputStream f = new FileInputStream(BattleBot.BASE_PATH + "pokemonBaseStats.dat"); ObjectInputStream o = new ObjectInputStream(f)) { 57 | ArrayList list = (ArrayList) o.readObject(); 58 | base = list.get(id); 59 | } catch (Exception ex) { 60 | System.err.println("Failed to get the Pokemon Base Stat List! " + ex); 61 | } 62 | } 63 | return base.getStat(stat); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/TPPDekuBot/PokemonBattle.java: -------------------------------------------------------------------------------- 1 | package TPPDekuBot; 2 | 3 | import java.io.PrintWriter; 4 | import java.io.StringWriter; 5 | import java.security.SecureRandom; 6 | import java.util.HashMap; 7 | import java.util.concurrent.LinkedBlockingQueue; 8 | import java.util.concurrent.TimeUnit; 9 | 10 | public class PokemonBattle extends Battle { 11 | 12 | private BattleBot b; 13 | private String channel; 14 | private String player; 15 | 16 | public PokemonBattle(BattleBot b, String channel, boolean bigBrother, boolean fromChef, String player, boolean test) { 17 | super(b); 18 | this.b = b; 19 | this.channel = channel; 20 | this.player = player; 21 | b.battle = this; 22 | SecureRandom rand = new SecureRandom(); 23 | int rand1 = rand.nextInt(718); 24 | int rand2 = rand1; 25 | while (rand2 == rand1) { 26 | rand2 = rand.nextInt(718); 27 | } 28 | if (Pokemon.isBannedPokemon(rand1) || Pokemon.isBannedPokemon(rand2)) { 29 | rand1 = rand.nextInt(718); 30 | rand2 = rand1; 31 | while (rand2 == rand1) { 32 | rand2 = rand.nextInt(718); 33 | } 34 | } 35 | int level1 = rand.nextInt(100 - 20 + 1) + 20; 36 | while (level1 < 20) { 37 | level1 = rand.nextInt(100 - 20 + 1) + 20; 38 | } 39 | int level1bufUpper = level1 + 7; 40 | int level1bufLower = level1 - 7; 41 | if (level1bufUpper > 100) { 42 | level1bufUpper = 100; 43 | } 44 | if (level1bufLower < 20) { 45 | level1bufLower = 20; 46 | } 47 | int level2 = rand.nextInt((level1bufUpper - level1bufLower) + 1) + level1bufLower; 48 | if (bigBrother) { 49 | if (fromChef) { 50 | level1 = 100; 51 | rand1 = 129; 52 | } else { 53 | level2 = 100; 54 | rand2 = 129; 55 | } 56 | } 57 | System.out.println("Generated userID " + rand1 + ", level " + level1 + " and computerID " + rand2 + ", level " + level2); 58 | Pokemon user = new Pokemon(rand1, level1); 59 | Pokemon computer = new Pokemon(rand2, level2); 60 | try { 61 | if (bigBrother) { 62 | if (fromChef) { 63 | user.setMove1(Pokemon.getMove("Shadow-force")); 64 | user.setMove2(Pokemon.getMove("Explosion")); 65 | user.setMove3(Pokemon.getMove("Overheat")); 66 | user.setMove4(Pokemon.getMove("Hydro-pump")); 67 | user.setStat(Stats.HP, 1000); 68 | user.setStat(Stats.ATTACK, 1000); 69 | user.setStat(Stats.DEFENSE, 1000); 70 | user.setStat(Stats.SPEED, 1000); 71 | user.setStat(Stats.SP_ATTACK, 1000); 72 | user.setStat(Stats.SP_DEFENSE, 1000); 73 | computer.assignMoves(); 74 | } else { 75 | computer.setMove1(Pokemon.getMove("Shadow-force")); 76 | computer.setMove2(Pokemon.getMove("Explosion")); 77 | computer.setMove3(Pokemon.getMove("Overheat")); 78 | computer.setMove4(Pokemon.getMove("Hydro-pump")); 79 | computer.setStat(Stats.HP, 1000); 80 | computer.setStat(Stats.ATTACK, 1000); 81 | computer.setStat(Stats.DEFENSE, 1000); 82 | computer.setStat(Stats.SPEED, 1000); 83 | computer.setStat(Stats.SP_ATTACK, 1000); 84 | computer.setStat(Stats.SP_DEFENSE, 1000); 85 | user.assignMoves(); 86 | } 87 | } 88 | if (user.getLevel() < 0 || computer.getLevel() < 0) { 89 | throw new Exception("Level is negative!!"); 90 | } 91 | if (!bigBrother) { 92 | user.assignMoves(); 93 | computer.assignMoves(); 94 | } 95 | } catch (Exception ex) { 96 | System.err.println("[POKEMON] Failed to generate moves! UserID: " + rand1 + ", ComputerID: " + rand2 + "\n[POKEMON] " + ex); 97 | b.sendMessage(channel, "Something fucked up OneHand give it another try"); 98 | StringWriter sw = new StringWriter(); 99 | PrintWriter pw = new PrintWriter(sw); 100 | ex.printStackTrace(pw); 101 | b.music.sendMessage(b.music.getChannel(), b.music.CHEF.mention() + " ```" + sw.toString() + "\nUser ID: " + rand1 + " Computer ID: " + rand2 + "```"); 102 | b.battle = null; 103 | return; 104 | } 105 | if (test) { 106 | user = new Pokemon(363, 70); 107 | computer = new Pokemon(170, 51); 108 | HashMap moves = Pokemon.reloadMoves(); 109 | user.setMove1(moves.get("Horn-drill")); 110 | user.setMove2(moves.get("Double-edge")); 111 | user.setMove3(moves.get("Toxic")); 112 | user.setMove4(moves.get("Twineedle")); 113 | user.setStat(Stats.SPEED, 1000); 114 | user.setStat(Stats.HP, 10000); 115 | computer.setMove1(moves.get("Take-down")); 116 | computer.setMove2(moves.get("Thunderbolt")); 117 | computer.setMove3(moves.get("Round")); 118 | computer.setMove4(moves.get("Blizzard")); 119 | } 120 | b.music.play(b.determineMusic(computer)); 121 | b.sendMessage(channel, (BattleBot.isLegendary(computer.getId()) ? "Woah! " : "") + "A wild " + computer.getName() + " (level " + (bigBrother && !fromChef ? "1͗̎̔ͪͫ̃͒͜͠҉̥̝̜ͅͅ0̴̵̞͖̪̻͎̦̯̒̔ͫ̾ͣ̃̅̉0̑̔̽̓͊̈̏ͧ̀̾͆͜͏̸̹̹͇̠̺̞̻̯̦͈̦̹̥͕̙" : computer.getLevel()) + ") appeared! Go " + user.getName() + "! (Level " + (bigBrother && fromChef && user.getName().equalsIgnoreCase("Magikarp") && user.getMove1().getName().equalsIgnoreCase("Shadow-force") ? "1͗̎̔ͪͫ̃͒͜͠҉̥̝̜ͅͅ0̴̵̞͖̪̻͎̦̯̒̔ͫ̾ͣ̃̅̉0̑̔̽̓͊̈̏ͧ̀̾͆͜͏̸̹̹͇̠̺̞̻̯̦͈̦̹̥͕̙" : user.getLevel()) + ")"); 122 | System.err.println("User moves = " + user.getMove1().getName() + ", " + user.getMove2().getName() + ", " + user.getMove3().getName() + ", " + user.getMove4().getName() + ", "); 123 | System.err.println("Computer moves = " + computer.getMove1().getName() + ", " + computer.getMove2().getName() + ", " + computer.getMove3().getName() + ", " + computer.getMove4().getName() + ", "); 124 | try { 125 | while (!user.isFainted() && !computer.isFainted()) { 126 | BattleBot.pokemonMessages = new LinkedBlockingQueue<>(); 127 | b.sendMessage(channel, "What will " + user.getName() + " do? (!move1)" + user.getMove1().getName() + ", (!move2)" + user.getMove2().getName() + ", (!move3)" + user.getMove3().getName() + ", (!move4)" + user.getMove4().getName()); 128 | user.setFlinch(false); 129 | computer.setFlinch(false); 130 | int userSpeed = user.getStat(Stats.SPEED); 131 | int compSpeed = computer.getStat(Stats.SPEED); 132 | if (user.getStatus() == Status.PARALYSIS) { 133 | userSpeed = userSpeed / 2; 134 | } 135 | if (computer.getStatus() == Status.PARALYSIS) { 136 | compSpeed = compSpeed / 2; 137 | } 138 | if (userSpeed > compSpeed) { 139 | String move = BattleBot.pokemonMessages.poll(60, TimeUnit.SECONDS); 140 | if (move == null) { 141 | b.sendMessage(channel, player + " did not select a move in time and got their Pokemon stolen by Team Rocket! RuleFive"); 142 | return; 143 | } 144 | if (move.equalsIgnoreCase("run")) { 145 | b.sendMessage(channel, "You got away safely!"); 146 | return; 147 | } 148 | doUsersMove(user, computer, move); 149 | if (!computer.isFainted()) { 150 | if (computer.isFlinched()) { 151 | b.sendMessage(channel, computer.getName() + " flinched!"); 152 | computer.setFlinch(false); 153 | } else { 154 | doComputerMove(user, computer); 155 | } 156 | } 157 | } else if (userSpeed < compSpeed) { 158 | String move = BattleBot.pokemonMessages.poll(60, TimeUnit.SECONDS); 159 | if (move == null) { 160 | b.sendMessage(channel, player + " did not select a move in time and got their Pokemon stolen by Team Rocket! RuleFive"); 161 | return; 162 | } 163 | doComputerMove(user, computer); 164 | if (!user.isFainted()) { 165 | if (user.isFlinched()) { 166 | b.sendMessage(channel, user.getName() + " flinched!"); 167 | user.setFlinch(false); 168 | } else { 169 | if (move.equalsIgnoreCase("run")) { 170 | b.sendMessage(channel, "You got away safely!"); 171 | return; 172 | } 173 | doUsersMove(user, computer, move); 174 | } 175 | } 176 | } else { 177 | rand = new SecureRandom(); 178 | int chance = rand.nextInt(2); 179 | if (chance == 1) { 180 | String move = BattleBot.pokemonMessages.poll(60, TimeUnit.SECONDS); 181 | if (move == null) { 182 | b.sendMessage(channel, player + " did not select a move in time and got their Pokemon stolen by Team Rocket! RuleFive"); 183 | return; 184 | } 185 | if (move.equalsIgnoreCase("run")) { 186 | b.sendMessage(channel, "You got away safely!"); 187 | return; 188 | } 189 | doUsersMove(user, computer, move); 190 | if (!computer.isFainted()) { 191 | if (computer.isFlinched()) { 192 | b.sendMessage(channel, computer.getName() + " flinched!"); 193 | computer.setFlinch(false); 194 | } else { 195 | doComputerMove(user, computer); 196 | } 197 | } 198 | } else { 199 | String move = BattleBot.pokemonMessages.poll(60, TimeUnit.SECONDS); 200 | if (move == null) { 201 | b.sendMessage(channel, player + " did not select a move in time and got their Pokemon stolen by Team Rocket! RuleFive"); 202 | return; 203 | } 204 | doComputerMove(user, computer); 205 | if (!user.isFainted()) { 206 | if (user.isFlinched()) { 207 | b.sendMessage(channel, user.getName() + " flinched!"); 208 | user.setFlinch(false); 209 | } else { 210 | if (move.equalsIgnoreCase("run")) { 211 | b.sendMessage(channel, "You got away safely!"); 212 | return; 213 | } 214 | doUsersMove(user, computer, move); 215 | } 216 | } 217 | } 218 | } 219 | } 220 | if (user.isFainted()) { 221 | b.sendMessage(channel, user.getName() + " fainted! You lose! BibleThump"); 222 | } else if (computer.isFainted()) { 223 | b.sendMessage(channel, computer.getName() + " fainted! You Win! PogChamp"); 224 | if (user.getLevel() != 100) { 225 | int levelBefore = user.getLevel(); 226 | int exp = Pokemon.calculateExperience(false, user, computer); 227 | user.addExperience(exp); 228 | int levelAfter = user.getLevel(); 229 | b.sendMessage(channel, user.getName() + " gained " + exp + " Exp. Points!"); 230 | if (levelBefore < levelAfter) { 231 | b.sendMessage(channel, user.getName() + " grew to Level " + levelAfter + "! PogChamp"); 232 | } 233 | } 234 | } 235 | } catch (Exception ex) { 236 | StringWriter sw = new StringWriter(); 237 | PrintWriter pw = new PrintWriter(sw); 238 | ex.printStackTrace(pw); 239 | b.music.sendMessage(b.music.getChannel(), b.music.CHEF.mention() + " ```" + sw.toString() + "\nUser ID: " + rand1 + " Computer ID: " + rand2 + "```"); 240 | } 241 | } 242 | 243 | private void doComputerMove(Pokemon user, Pokemon computer) { 244 | b.sendMessage(channel, computer.attack(user, Move.selectBestMove(computer, user), this).replace("\n", " ")); 245 | } 246 | 247 | private void doUsersMove(Pokemon user, Pokemon computer, String move) { 248 | switch (move) { 249 | case "1": 250 | b.sendMessage(channel, user.attack(computer, user.getMove1(), this).replace("\n", " ")); 251 | break; 252 | case "2": 253 | b.sendMessage(channel, user.attack(computer, user.getMove2(), this).replace("\n", " ")); 254 | break; 255 | case "3": 256 | b.sendMessage(channel, user.attack(computer, user.getMove3(), this).replace("\n", " ")); 257 | break; 258 | case "4": 259 | b.sendMessage(channel, user.attack(computer, user.getMove4(), this).replace("\n", " ")); 260 | break; 261 | case "run": 262 | b.sendMessage(channel, "You got away safely!"); 263 | return; 264 | } 265 | } 266 | 267 | } 268 | -------------------------------------------------------------------------------- /src/TPPDekuBot/Region.java: -------------------------------------------------------------------------------- 1 | package TPPDekuBot; 2 | 3 | import java.security.SecureRandom; 4 | 5 | public enum Region { 6 | KANTO, JOHTO, HOENN, SINNOH, UNOVA, KALOS; 7 | 8 | @Override 9 | public String toString() { 10 | return this.name().charAt(0) + this.name().toLowerCase().substring(1); 11 | } 12 | 13 | public static Region getRandomRegion() { 14 | return Region.values()[new SecureRandom().nextInt(Region.values().length)]; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/TPPDekuBot/SafariBattle.java: -------------------------------------------------------------------------------- 1 | package TPPDekuBot; 2 | 3 | import java.io.PrintWriter; 4 | import java.io.StringWriter; 5 | import java.security.SecureRandom; 6 | import java.util.concurrent.LinkedBlockingQueue; 7 | import java.util.concurrent.TimeUnit; 8 | 9 | public class SafariBattle extends Battle { 10 | 11 | public Trainer user; 12 | private Pokemon wild; 13 | private int angry = 0, eat = 0; 14 | public LinkedBlockingQueue msg = new LinkedBlockingQueue<>(); 15 | private double hpMax; 16 | private double hpCurrent; 17 | private double rate; 18 | private double catchChance; 19 | private double shakeProbability; 20 | private BattleBot b; 21 | 22 | public SafariBattle(BattleBot b, String user, Pokemon wild) { 23 | super(b); 24 | this.b = b; 25 | this.user = new Trainer(user); 26 | this.wild = wild; 27 | } 28 | 29 | public SafariBattle(BattleBot b, Trainer user, Pokemon wild) { 30 | super(b); 31 | this.b = b; 32 | this.user = user; 33 | this.wild = wild; 34 | } 35 | 36 | private void recalcCatch() { 37 | hpMax = wild.getMaxHP(); 38 | hpCurrent = wild.getStat(Stats.HP); 39 | rate = Pokemon.getCatchRate(wild.getName()); 40 | catchChance = ((((3 * hpMax) - (2 * hpCurrent)) * rate * 1.5) / (3 * hpMax)); 41 | if (catchChance > 255) { 42 | catchChance = 255; 43 | } 44 | shakeProbability = 1048560.0 / (Math.sqrt(Math.sqrt(16711680.0 / catchChance))); 45 | } 46 | 47 | public void doBattle(BattleBot b, String channel) { 48 | b.music.play(b.determineMusic(wild)); 49 | b.sendMessage(channel, (BattleBot.isLegendary(wild.getId()) ? "Woah! " : "") + "A Wild " + wild.getName() + " (Level " + wild.getLevel() + ") Appeared!"); 50 | recalcCatch(); 51 | boolean caught = false; 52 | boolean end = false; 53 | String lastTurn = ""; 54 | while (true) { 55 | msg = new LinkedBlockingQueue<>(); 56 | b.sendMessage(channel, "What will " + user + " do? (!bait) Throw Bait, (!rock) Throw Rock, (!ball) Throw Pokeball, (!run) Run"); 57 | try { 58 | String move = msg.poll(60, TimeUnit.SECONDS); 59 | if (move == null) { 60 | b.sendMessage(channel, user.getTrainerName() + " did not select an action in time, the Pokemon was stolen by Team Flare WutFace"); 61 | end = true; 62 | return; 63 | } 64 | if (move.startsWith("!bait")) { 65 | lastTurn = "bait"; 66 | angry = 0; 67 | eat += new SecureRandom().nextInt(5 - 1 + 1) + 1; 68 | 69 | } else if (move.startsWith("!rock")) { 70 | lastTurn = "rock"; 71 | angry += new SecureRandom().nextInt(5 - 1 + 1) + 1; 72 | eat = 0; 73 | } else if (move.startsWith("!ball")) { 74 | lastTurn = "ball"; 75 | b.sendMessage(channel, user.getTrainerName() + " threw a Pokeball!"); 76 | System.err.println("catchChance = " + catchChance + "\nshakeProb = " + shakeProbability); 77 | int shake1 = new SecureRandom().nextInt(65536); 78 | if (shake1 >= shakeProbability) { 79 | b.sendMessage(channel, "You missed the Pokemon! RuleFive Good Job, Dumbass. FUNgineer"); 80 | continue; 81 | } 82 | b.sendMessage(channel, "Shake..."); 83 | int shake2 = new SecureRandom().nextInt(65536); 84 | if (shake2 >= shakeProbability) { 85 | b.sendMessage(channel, "Aww! It appeared to be caught! BibleThump"); 86 | continue; 87 | } 88 | b.sendMessage(channel, "Shake.... ThunBeast"); 89 | int shake3 = new SecureRandom().nextInt(65536); 90 | if (shake3 >= shakeProbability) { 91 | b.sendMessage(channel, "Aargh! Almost had it caught! DansGame"); 92 | continue; 93 | } 94 | b.sendMessage(channel, "Shake..... PogChamp"); 95 | int shake4 = new SecureRandom().nextInt(65536); 96 | if (shake4 >= shakeProbability) { 97 | b.sendMessage(channel, "Gah! It was so close, too! SwiftRage"); 98 | continue; 99 | } 100 | b.sendMessage(channel, "Awright! " + wild.getName() + " was caught! Kreygasm"); 101 | caught = true; 102 | return; 103 | 104 | } else if (move.startsWith("!run")) { 105 | b.sendMessage(channel, "You got away safely!"); 106 | lastTurn = "run"; 107 | return; 108 | } 109 | } catch (Exception ex) { 110 | StringWriter sw = new StringWriter(); 111 | PrintWriter pw = new PrintWriter(sw); 112 | ex.printStackTrace(pw); 113 | b.music.sendMessage(b.music.getChannel(), b.music.CHEF.mention() + " ```" + sw.toString() + "Pokemon ID: " + this.wild.getId() + "```"); 114 | } finally { 115 | if (caught || lastTurn.equalsIgnoreCase("run") || end) { 116 | return; 117 | } 118 | if (eat > angry) { 119 | b.sendMessage(channel, wild.getName() + " is eating!"); 120 | int random = new SecureRandom().nextInt(256); 121 | if (random < (wild.getStat(Stats.SPEED) / 2)) { 122 | b.sendMessage(channel, "The wild " + wild.getName() + " ran away!"); 123 | return; 124 | } 125 | } else if (angry > eat) { 126 | b.sendMessage(channel, wild.getName() + " is pissed off!"); 127 | int random = new SecureRandom().nextInt(256); 128 | if (random < (wild.getStat(Stats.SPEED) * 4)) { 129 | b.sendMessage(channel, "The wild " + wild.getName() + " ran away!"); 130 | return; 131 | } 132 | } else { 133 | b.sendMessage(channel, wild.getName() + " is watching carefully..."); 134 | int random = new SecureRandom().nextInt(256); 135 | if (random < (wild.getStat(Stats.SPEED) * 2)) { 136 | b.sendMessage(channel, "The wild " + wild.getName() + " ran away!"); 137 | return; 138 | } 139 | } 140 | if (angry > 0) { 141 | angry--; 142 | } 143 | if (eat > 0) { 144 | eat--; 145 | } 146 | if (angry == 0) { 147 | recalcCatch(); 148 | } 149 | switch (lastTurn) { 150 | case "bait": 151 | catchChance = catchChance / 2; 152 | shakeProbability = 1048560.0 / (Math.sqrt(Math.sqrt(16711680.0 / catchChance))); 153 | continue; 154 | case "rock": 155 | catchChance = catchChance * 2; 156 | shakeProbability = 1048560.0 / (Math.sqrt(Math.sqrt(16711680.0 / catchChance))); 157 | if (catchChance > 255) { 158 | catchChance = 255; 159 | } 160 | continue; 161 | default: 162 | continue; 163 | } 164 | 165 | } 166 | } 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /src/TPPDekuBot/Stats.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package TPPDekuBot; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * 12 | * @author Michael 13 | */ 14 | public enum Stats implements Serializable{ 15 | 16 | HP, ATTACK, DEFENSE, SP_ATTACK, SP_DEFENSE, SPEED, EVASION, ACCURACY; 17 | } 18 | -------------------------------------------------------------------------------- /src/TPPDekuBot/Status.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package TPPDekuBot; 7 | 8 | /** 9 | * 10 | * @author Michael 11 | */ 12 | public enum Status { 13 | 14 | NORMAL, BURN, FREEZE, PARALYSIS, POISON, TOXIC, SLEEP, ATTACK_NEXT_TURN, NO_MOVE_THIS_TURN; 15 | } 16 | -------------------------------------------------------------------------------- /src/TPPDekuBot/Trainer.java: -------------------------------------------------------------------------------- 1 | package TPPDekuBot; 2 | 3 | import PircBot.*; 4 | import java.io.FileInputStream; 5 | import java.io.ObjectInputStream; 6 | import java.security.SecureRandom; 7 | import java.util.*; 8 | 9 | public class Trainer implements Cloneable { 10 | 11 | private ArrayList pokemon; 12 | private ArrayList items; 13 | private String name; 14 | protected String trnClass; 15 | private int pokemonLeft; 16 | private int money; 17 | private ArrayList badges; 18 | private boolean defeatedChampion = false; 19 | private int eliteFour; 20 | private Region homeRegion; 21 | private boolean ai; 22 | 23 | public Trainer(String name, ArrayList pokemon, ArrayList items) { 24 | this.pokemon = pokemon; 25 | this.items = items; 26 | this.name = name; 27 | this.pokemonLeft = pokemon.size(); 28 | money = 0; 29 | getTrainerClass(); 30 | } 31 | 32 | public Trainer(String name, ArrayList pokemon, ArrayList items, int money) { 33 | this.pokemon = pokemon; 34 | this.items = items; 35 | this.name = name; 36 | this.pokemonLeft = pokemon.size(); 37 | this.money = money; 38 | getTrainerClass(); 39 | } 40 | 41 | public Trainer(String name, ArrayList pokemon, ArrayList items, int pokemonLeft, int money, ArrayList badges, int eliteFour) { 42 | this.pokemon = pokemon; 43 | this.items = items; 44 | this.name = name; 45 | this.pokemonLeft = pokemonLeft; 46 | this.money = money; 47 | this.badges = badges; 48 | this.eliteFour = eliteFour; 49 | getTrainerClass(); 50 | } 51 | 52 | public Trainer(User user, ArrayList pokemon) { 53 | this.name = user.getNick(); 54 | this.pokemon = pokemon; 55 | this.pokemonLeft = pokemon.size(); 56 | money = 0; 57 | getTrainerClass(); 58 | } 59 | 60 | public Trainer(String name) { 61 | this.name = name; 62 | this.pokemon = generatePokemon(1); 63 | this.pokemonLeft = 1; 64 | money = 0; 65 | getTrainerClass(); 66 | } 67 | 68 | public Trainer(String name, int amt) { 69 | this.name = name; 70 | this.pokemon = generatePokemon(amt); 71 | this.pokemonLeft = amt; 72 | money = 0; 73 | getTrainerClass(); 74 | } 75 | 76 | public Trainer(String name, int amt, int level) { 77 | this.name = name; 78 | this.pokemon = generatePokemon(amt, level); 79 | this.pokemonLeft = amt; 80 | money = 0; 81 | getTrainerClass(); 82 | } 83 | 84 | public Trainer(String name, String trnClass, Region region, ArrayList pokemon, boolean ai) { 85 | this.name = name; 86 | this.pokemon = pokemon; 87 | this.pokemonLeft = pokemon.size(); 88 | this.homeRegion = region; 89 | money = 0; 90 | this.trnClass = trnClass; 91 | this.ai = ai; 92 | } 93 | 94 | public boolean hasDefeatedChampion() { 95 | return defeatedChampion; 96 | } 97 | 98 | public void setDefeatedChampion(boolean defeated) { 99 | this.defeatedChampion = defeated; 100 | } 101 | 102 | private void getTrainerClass() { 103 | try (FileInputStream f = new FileInputStream(BattleBot.BASE_PATH + "/trainerclasses.wdu"); ObjectInputStream o = new ObjectInputStream(f)) { 104 | HashMap classes = (HashMap) o.readObject(); 105 | trnClass = (classes.containsKey(this.name.toLowerCase())) ? classes.get(this.name.toLowerCase()) : "Pokemon Trainer"; 106 | } catch (Exception ex) { 107 | trnClass = "Pokemon Trainer"; 108 | } 109 | } 110 | 111 | public static String getTrainerClass(String input) { 112 | try (FileInputStream f = new FileInputStream(BattleBot.BASE_PATH + "/trainerclasses.wdu"); ObjectInputStream o = new ObjectInputStream(f)) { 113 | HashMap classes = (HashMap) o.readObject(); 114 | return (classes.containsKey(input.toLowerCase())) ? classes.get(input.toLowerCase()) : "Pokemon Trainer"; 115 | } catch (Exception ex) { 116 | return "Pokemon Trainer"; 117 | } 118 | } 119 | 120 | private ArrayList generatePokemon(int amt) { 121 | int level = new SecureRandom().nextInt((100 - 20) + 1) + 20; 122 | return generatePokemon(amt, level); 123 | } 124 | 125 | public static ArrayList generatePokemon(int amt, int level) { 126 | if (amt > 6) { 127 | amt = 6; 128 | } 129 | if (amt < 1) { 130 | amt = 1; 131 | } 132 | ArrayList toReturn = new ArrayList<>(); 133 | for (int i = 0; i < amt; i++) { 134 | int pokemon = new SecureRandom().nextInt(719); 135 | while (Pokemon.isBannedPokemon(pokemon)) { 136 | pokemon = new SecureRandom().nextInt(719); 137 | } 138 | Pokemon pkm = new Pokemon(pokemon, level); 139 | pkm.assignMoves(); 140 | toReturn.add(pkm); 141 | } 142 | return toReturn; 143 | } 144 | 145 | public void swapPokemon(int position1, int position2) { 146 | Collections.swap(pokemon, position1, position2); 147 | } 148 | 149 | public int getNumberOfPokemonRemaining() { 150 | pokemonLeft = 0; 151 | for (Pokemon el : this.pokemon) { 152 | if (!el.isFainted()) { 153 | pokemonLeft++; 154 | } 155 | } 156 | return pokemonLeft; 157 | } 158 | 159 | public void addPokemon(Pokemon pokemon) { 160 | this.pokemon.add(pokemon); 161 | } 162 | 163 | public void addPokemonAtBeginning(Pokemon pokemon) { 164 | ArrayList newList = new ArrayList<>(); 165 | newList.add(pokemon); 166 | for (Pokemon el : this.pokemon) { 167 | newList.add(el); 168 | } 169 | this.pokemon = newList; 170 | } 171 | 172 | public void removePokemon(Pokemon pokemon) { 173 | this.pokemon.remove(pokemon); 174 | } 175 | 176 | public void removePokemon(int pos) { 177 | this.pokemon.remove(pos); 178 | } 179 | 180 | public void removeAllPokemon() { 181 | this.pokemon.clear(); 182 | } 183 | 184 | public void changePokemon(int pos, Pokemon newPokemon) { 185 | this.pokemon.remove(pos); 186 | this.pokemon.add(pos, newPokemon); 187 | } 188 | 189 | public Pokemon getPokemon(int pos) { 190 | return this.pokemon.get(pos); 191 | } 192 | 193 | public int getMoney() { 194 | return money; 195 | } 196 | 197 | public void setMoney(int money) { 198 | this.money = money; 199 | } 200 | 201 | public void addMoney(int money) { 202 | this.money += money; 203 | } 204 | 205 | public void subtractMoney(int money) { 206 | this.money -= money; 207 | } 208 | 209 | public String getPokemonList() { 210 | String toReturn = ""; 211 | int pos = 0; 212 | for (Pokemon el : pokemon) { 213 | toReturn += "(" + pos + ") "; 214 | String fainted = el.isFainted() ? " (FNT)" : ""; 215 | toReturn += el.getName() + fainted + ", "; 216 | pos++; 217 | } 218 | toReturn = toReturn.substring(0, toReturn.length() - 2); 219 | return toReturn; 220 | } 221 | 222 | public ArrayList getPokemon() { 223 | return this.pokemon; 224 | } 225 | 226 | public String getTrainerName() { 227 | return this.name; 228 | } 229 | 230 | public String getTrnClass() { 231 | return this.trnClass; 232 | } 233 | 234 | public boolean isAI() { 235 | return ai; 236 | } 237 | 238 | public void heal() { 239 | for (Pokemon el : this.pokemon) { 240 | el.heal(); 241 | } 242 | this.pokemonLeft = this.pokemon.size(); 243 | } 244 | 245 | public Region getRegion() { 246 | return homeRegion; 247 | } 248 | 249 | public void setRegion(Region region) { 250 | this.homeRegion = region; 251 | } 252 | 253 | @Override 254 | public int hashCode() { 255 | int hash = 3; 256 | hash = 67 * hash + Objects.hashCode(this.pokemon); 257 | hash = 67 * hash + Objects.hashCode(this.name); 258 | hash = 67 * hash + this.pokemonLeft; 259 | return hash; 260 | } 261 | 262 | @Override 263 | public boolean equals(Object obj) { 264 | if (this == obj) { 265 | return true; 266 | } 267 | if (obj == null) { 268 | return false; 269 | } 270 | if (getClass() != obj.getClass()) { 271 | return false; 272 | } 273 | final Trainer other = (Trainer) obj; 274 | if (this.money != other.money) { 275 | return false; 276 | } 277 | if (this.defeatedChampion != other.defeatedChampion) { 278 | return false; 279 | } 280 | if (this.eliteFour != other.eliteFour) { 281 | return false; 282 | } 283 | if (this.ai != other.ai) { 284 | return false; 285 | } 286 | if (!Objects.equals(this.name, other.name)) { 287 | return false; 288 | } 289 | if (!Objects.equals(this.trnClass, other.trnClass)) { 290 | return false; 291 | } 292 | if (!Objects.equals(this.items, other.items)) { 293 | return false; 294 | } 295 | if (!Objects.equals(this.badges, other.badges)) { 296 | return false; 297 | } 298 | return this.homeRegion == other.homeRegion; 299 | } 300 | 301 | @Override 302 | protected Object clone() throws CloneNotSupportedException { 303 | return super.clone(); 304 | } 305 | 306 | @Override 307 | public String toString() { 308 | return this.trnClass + " " + this.name; 309 | } 310 | 311 | public static boolean isValidTrainerClass(String input) { 312 | String[] classes = {"Ace Trainer", "Beauty", "Biker", "Bird Keeper", "Blackbelt", "Bug Catcher", "Burglar", "Channeler", "Cue Ball", "Engineer", "Fisherman", "Gambler", "Gentleman", "Hiker", "Jr. Trainer", "Juggler", "Lass", "Leader", "PokeManiac", "Pokemon Trainer (default)", "Psychic", "Rocker", "Sailor", "Scientist", "Super Nerd", "Swimmer", "Tamer", "Youngster", "Boarder", "Camper", "Firebreather", "Guitarist", "Kimono Girl", "Medium", "Officer", "Picnicker", "Pokefan", "Sage", "Schoolboy", "Skier", "Swimmer", "Teacher", "Team Rocket", "Rocket Grunt", "Team Aqua", "Team Magma", "Team Aqua Grunt", "Team Magma Grunt", "Team Galactic", "Team Galactic Grunt", "Rocket Bomb", "Team Plasma", "Team Plasma Grunt", "Team Flare", "Team Flare Grunt"}; 313 | for (String el : classes) { 314 | if (input.equals(el)) { 315 | return true; 316 | } 317 | } 318 | return false; 319 | } 320 | 321 | public static boolean isUserBot(String input) { 322 | String[] userBots = {"frunky5", "23forces", "groudonger"}; 323 | for (String el : userBots) { 324 | if (el.equalsIgnoreCase(input)) { 325 | return true; 326 | } 327 | } 328 | return false; 329 | } 330 | 331 | } 332 | -------------------------------------------------------------------------------- /src/TPPDekuBot/Type.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package TPPDekuBot; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * 12 | * @author Michael 13 | */ 14 | public enum Type implements Serializable { 15 | 16 | NORMAL, FIRE, WATER, ELECTRIC, GRASS, ICE, FIGHTING, POISON, GROUND, FLYING, PSYCHIC, BUG, ROCK, GHOST, DRAGON, DARK, STEEL, FAIRY, NONE; 17 | 18 | @Override 19 | public String toString() { 20 | String toReturn = this.name().toLowerCase().replace("type.", ""); 21 | char first = toReturn.charAt(0); 22 | first = Character.toUpperCase(first); 23 | toReturn = first + toReturn.substring(1); 24 | return toReturn; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/TPPDekuBot/Weather.java: -------------------------------------------------------------------------------- 1 | package TPPDekuBot; 2 | 3 | public enum Weather { 4 | NORMAL, SUN, SUN_EXTREME, RAIN, RAIN_HEAVY, SANDSTORM, HAIL, FOG, AIR_CURRENT; 5 | } 6 | --------------------------------------------------------------------------------