Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- /**
- * A class to represent all the different types of Pokemon
- */
- public class PKMN {
- /** public static array for tracking PKMN that have been constructed */
- public static ArrayList<PKMN> allPKMN = new ArrayList<>();
- /** PKMNs Name (String) */
- private String name;
- /** int representation of PKMNS current stats */
- private int level, XP, XP2LVL, hp, maxHp, attack, defense, spAttack, spDefense, speed;
- /** If PKMN has lost a fight or hp less than 0 */
- private boolean faint;
- /** PKMNs current Location (Place OBJ)*/
- private Place currentLoc;
- /** PKMNs Elemental Type */
- private TYPE type;
- /**
- * Constructor for PKMN
- *
- * @param name PKMN's name
- * @param level PKMN's level
- */
- public PKMN(String name, int level, TYPE type) {
- this.name = name;
- this.level = level;
- this.hp = 10;
- this.maxHp = 10;
- this.attack = 5;
- this.defense = 5;
- this.spAttack = 5;
- this.spDefense = 5;
- this.speed = 5;
- this.type = type;
- allPKMN.add(this);
- }
- /**
- * @return String PKMNs Name
- */
- public String name() {
- return this.name;
- }
- /**
- * @return int PKMNs level
- */
- public int level() {
- return this.level;
- }
- /**
- * @return int current xp
- */
- public int XP(){
- return this.XP;
- }
- /**
- * @return int xp required to level up
- */
- public int XP2LVL(){
- return this.XP2LVL;
- }
- /**
- * @return int PKMNs hp
- */
- public int hp() {
- return this.hp;
- }
- /**
- * @return int PKMNs max hp
- */
- public int maxHp() {
- return this.maxHp;
- }
- /**
- * @return int PKMNs attack
- */
- public int attack() {
- return this.attack;
- }
- /**
- * @return int PKMNs defense
- */
- public int defense() {
- return this.defense;
- }
- /**
- * @return int PKMNs sp attack
- */
- public int spAttack() {
- return this.spAttack;
- }
- /**
- * @return int PKMNs sp defense
- */
- public int spDefense() {
- return this.spDefense;
- }
- /**
- * @return int PKMNs speed
- */
- public int speed() {
- return this.speed;
- }
- /**
- * @return TYPE The PKMNs type (element)
- */
- public TYPE type() {
- return this.type;
- }
- /**
- * @Override toString
- */
- public String toString() {
- return this.name;
- }
- /**
- * @return bool PKMN faint status
- */
- public boolean faint() {
- return this.faint;
- }
- /**
- * String set PKMNs name
- */
- public void setName(String n) {
- this.name = n;
- }
- /**
- * int set PKMNs level
- */
- public void setLevel(int l) {
- this.level = l;
- }
- /**
- * int add or remove xp from PKMNs current XP
- */
- public void modXP(int x){
- this.XP += x;
- }
- /**
- * int set the maximum XP required for the PKMN to reach the next level
- */
- public void setXP2LVL(int xp){
- this.XP2LVL = xp;
- }
- /**
- * int modifies PKMNs hp
- */
- public void modHp(int h) {
- this.hp += h;
- if (this.hp < 0) {
- this.hp = 0;
- }
- }
- /**
- * int set PKMNs max hp
- */
- public void setMaxHp(int m) {
- this.maxHp = m;
- }
- /**
- * int set PKMNs attack
- */
- public void setAttack(int a) {
- this.attack = a;
- }
- /**
- * int set PKMNs defense
- */
- public void setDefense(int d) {
- this.defense = d;
- }
- /**
- * int set PKMNs sp attack
- */
- public void setSpAttack(int sa) {
- this.spAttack = sa;
- }
- /**
- * int set PKMNs sp defense
- */
- public void setSpDefense(int sd) {
- this.spDefense = sd;
- }
- /**
- * int set PKMNs Speed
- */
- public void setSpeed(int s) {
- this.speed = s;
- }
- /**
- * @param f boolean which sets PKMN faint status
- */
- public void setFaint(boolean f) {
- this.faint = f;
- }
- /**
- * @param p Place where the PKMN currently is
- */
- public void setLoc(Place p){
- this.currentLoc = p;
- }
- /**
- * Prints out the PKMNs info and stats as a block of Strings
- */
- public void info() {
- System.out.println(String.format("\n%s Type: %s", this.name(), this.type.toString()));
- System.out.println(String.format("Level: %d HP: %d/%d ", this.level(), this.hp(), this.maxHp()));
- System.out.println(String.format("ATK: %d DEF: %d SPD: %d", this.attack(), this.defense(), this.speed()));
- System.out.println(String.format("SP ATK: %d SP DEF: %d", this.spAttack(), this.spDefense()));
- }
- /**
- *
- * @param target the PKMN being targeted
- * @return if this PKMN is Strong to target PKMNs type
- */
- public boolean counterTypes(PKMN target) {
- if (this.type() == type.Normal || target.type() == TYPE.Normal) {
- return false;
- } else if (this.type() == type.Water && target.type() == type.Fire) {
- return true;
- } else if (this.type() == type.Nature && target.type() == type.Water) {
- return true;
- } else if (this.type() == type.Fire && target.type() == type.Nature) {
- return true;
- } else if (this.type() == type.Electric && target.type() == type.Water) {
- return true;
- }
- return false;
- }
- /**
- * Different elemental types for the PKMN
- */
- public enum TYPE {
- Normal,
- Fire,
- Nature,
- Water,
- Electric
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment