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 ArrayList<PKMN> allPKMN = new ArrayList<>();
- private String name;
- private int level, CurrentXp, XpRequiredToLevel, hp, maxHp, atkVal, defVal, spAtkVal, spDefVal, speed;
- private boolean faint;
- private Place currentLoc;
- private ElementalType type;
- /**
- * Constructor for PKMN
- */
- public PKMN(String name, int level, ElementalType type) {
- this.name = name;
- this.level = level;
- this.hp = 10;
- this.maxHp = 10;
- this.atkVal = 5;
- this.defVal = 5;
- this.spAtkVal = 5;
- this.spDefVal = 5;
- this.speed = 5;
- this.type = type;
- allPKMN.add(this);
- }
- public String toString() {return this.name;}
- public String getName() {return this.name;}
- public int getLevel() {return this.level;}
- public int getCurrentXp() {return this.CurrentXp;}
- public int getXpRequiredToLevel() {return this.XpRequiredToLevel;}
- public int getHp() {return this.hp;}
- public int getMaxHp() {return this.maxHp;}
- public int getAtkVal() {return this.atkVal;}
- public int getDefVal() {return this.defVal;}
- public int getSpAtkVal() {return this.spAtkVal;}
- public int getSpDefVal() {return this.spDefVal;}
- public int getSpeed() {return this.speed;}
- public ElementalType getElemType() {return this.type;}
- public boolean isFaint() {return this.faint;}
- public void setName(String n) {this.name = n;}
- public void setLevel(int l) {this.level = l;}
- public void modXp(int x) {this.CurrentXp += x;}
- public void setXp(int x) {this.CurrentXp = x;}
- public void setXpRequiredToLevel(int xp) {this.XpRequiredToLevel = xp;}
- public void setHp(int h) {this.hp = h;}
- public void modHp(int h) {this.hp += h;if (this.hp < 0) {this.hp = 0;}}
- public void setMaxHp(int m) {this.maxHp = m;}
- public void setAtkValue(int a) {this.atkVal = a;}
- public void setDefValue(int d) {this.defVal = d;}
- public void setSpAtkValue(int sa) {this.spAtkVal = sa;}
- public void setSpDefValue(int sd) {this.spDefVal = sd;}
- public void setSpeed(int s) {this.speed = s;}
- public void setFaint(boolean f) {this.faint = f;}
- public void setLoc(Place p) {this.currentLoc = p;}
- public void info() {
- System.out.println(String.format("\n%s Type: %s", this.getName(), this.type.toString()));
- System.out.println(String.format("Level: %d HP: %d/%d ", this.getLevel(), this.getHp(), this.getMaxHp()));
- System.out.println(String.format("ATK: %d DEF: %d SPD: %d", this.getAtkVal(), this.getDefVal(), this.getSpeed()));
- System.out.println(String.format("SP ATK: %d SP DEF: %d", this.getSpAtkVal(), this.getSpDefVal()));
- }
- /**
- * Determines if the pokemon attacking crits against the pokemon defending
- */
- public boolean counterTypes(PKMN target) {
- if (this.getElemType() == type.Normal || target.getElemType() == type.Normal) {
- return false;
- } else if (this.getElemType() == type.Water && target.getElemType() == type.Fire) {
- return true;
- } else if (this.getElemType() == type.Nature && target.getElemType() == type.Water) {
- return true;
- } else if (this.getElemType() == type.Fire && target.getElemType() == type.Nature) {
- return true;
- } else if (this.getElemType() == type.Electric && target.getElemType() == type.Water) {
- return true;
- }
- return false;
- }
- public enum ElementalType {
- Normal,
- Fire,
- Nature,
- Water,
- Electric
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment