Subscribe to NeoTifa's Blog of |)00M!!!!        RSS Feed
-----

NeoTifa's Folly

Icon 2 Comments
Okay, so this is a giant learning process, as I have no one to help me (and don't really want any) so it's not very efficient yet. I realized my handling of the jobs was kinda... lame.... and then it hit me! Inheritance! What a dope. Ha ha why didn't I think of that before. <3 I'm still figuring out what to do with my town. I'll figure it out as I go through it. <3

Player Class

/**
 *
 * @author Erica Boyer
 * @datecreated 19 Mar 2009
 * @lastupdate 30 May 2009
 * 
 * This is the class for an rpg character. It can be used for the user's players, 
 * npc's, and  enemies. Basically, it just sets the player up with basic stats, 
 * job (optional), gender, and such.
 * 
 * >>To be converted to C++ later.
 * 
 */

import javax.swing.*;

public class Player {

    public enum Job {WARRIOR, KNIGHT, BMAGE, WMAGE}
    public enum Status {NORMAL, KO, POISON, SLEEP, PETRIFIED, CURSED, BLIND}
    public enum Gender {MALE, FEMALE}
    
    private final int initHp = 15;                      //Initial hit points
    private final int initMp = 5;                       //Initial magic points
    private final int initXp = 0;                       //Initial experience
    private final int initLvl = 1;                      //Initial level
    private final int initMaleStr = 4;                  //Initial male strength
    private final int initFemaleStr = 3;                //Initial female strength
    private final int initMaleEnd = 3;                  //Initial male endurance
    private final int initFemaleEnd = 2;                //Initial female endurance
    private final int initMaleInt = 2;                  //Initial male intelligence
    private final int initFemaleInt = 4;                //Initial female intelligence
    private final int initMaleDex = 2;                  //Initial male dexerity
    private final int initFemaleDex = 4;                //Initial female dexerity
    private final int initLuck = 2;                     //They start out the same luck

    private final int lvlUpFirst5 = 50;                 //Amount of experience needed to level up the first 5 levels
    private final int lvlUp6Thru20 = 100;               //Amount of experience needed to level up levels 6 through 20
    private final int lvlUp21Thru50 = 200;              //Amount of experience needed to level up levels 21 through 50
    private final int jLvlUp = 10;                      //Amount of job experience needed to level up a job
    private final int lvlUpHp = 4;                      //Amount of hit points gained every level up  
    private final int lvlUpMp = 2;                      //Amount of magic points gained every level up
    private final int lvlUpStat = 1;                    //Amount of str, end, dex, and luck gained every level up
    private final int maxLvl = 50;                      //Max level a character can be
    private final int maxJlvl = 10;                     //Max level a characters job can be

    private int jLvl;                                   //Holds the level of the jobs held by the character
    private int jStr;                                   //Holds the stegth the class gives initially
    private int jEnd;                                   //Holds the endurance the class gives initially
    private int jDex;                                   //Holds the dexterity the class gives initially
    private int jInt;                                   //Holds the intelligence the class gives initially
    private int jLuck;                                  //Holds the luck the class gives initially
    private int jHpBonus;                               //Holds the bonus hit points the characters job gives
    private int jMpBonus;                               //Holds the bonus magic points the characters job gives

    private String name;                                //Holds the characters name
    private Gender gender;                              //Holds the characters gender
    private Job job;                                    //Holds the characters job
    private int hp;                                     //Holds the characters hit points
    private int mp;                                     //Holds the characters magic points
    private int jp;                                     //Holds the characters job points (experience for jobs)
    private int maxHp;                                  //Holds the max hit points the character has
    private int maxMp;                                  //Holds the mas magic points the character has
    private long xp;                                    //Holds the characters experience points
    private int lvl;                                    //Holds the characters level
    private int str;                                    //Holds the characters strength (double due to Warriors focus ability)
    private int end;                                    //Holds the characters endurance
    private int Int;                                    //Holds the characters intelligence
    private int dex;                                    //Holds the characters dexterity
    private int luck;                                   //Holds the characters luck
    private Status status;                              //Holds the characters status
    private final int xpGained = lvl * 2;               //The amount of experience given per victory (enemies lvl * 2);
    
    private final int poisonDamage = 5;                 //How much damage being poisoned does a turn

     
    /**No-Arg Constructor Player
     * 
     * Sets up all the stats the the character will need.
     * 
     * @param none
     *  
     */
    public Player() {

        setName("New Character");
        setJob(Job.WARRIOR);                    //need to get Job from chooser or other class. Default is warrior
 
        setMaxHp(initHp + end);
        setMaxMp(initMp + Int);
        
        setHp(maxHp);
        setMp(maxMp);
        setJp(0);
       
        setXp(initXp);
        setLvl(initLvl);

        if (gender.equals(Gender.MALE)) {
            setStr(initMaleStr);
        } else if (gender.equals(Gender.FEMALE)) {
            setStr(initFemaleStr);
        }

        if (gender.equals(Gender.MALE)) {
            setEnd(initMaleEnd);
        } else if (gender.equals(Gender.FEMALE)) {
            setEnd(initFemaleEnd);
        }

        if (gender.equals(Gender.MALE)) {
            setDex(initMaleDex);
        } else if (gender.equals(Gender.FEMALE)) {
            setDex(initFemaleDex);
        }

        setLuck(initLuck);
        
        if (gender.equals(Gender.MALE)) {
            setInt(initMaleInt);
        } else if (gender.equals(Gender.FEMALE)) {
            setInt(initFemaleInt);
        }

        setStatus(Status.NORMAL);

    //INCOMPLETE!!!!!!!!!!!!

    }//End constructor

    /** Level Defined Constructor
     * 
     * Sets the stats up according to the level given
     * 
     * @param lvl The level of the character created
     * 
     */
    public Player(int lvl) {

        setName("");                                        //To be set in main game loop or something
        setJob(Job.WARRIOR);
        setLvl(lvl);      
        setMaxHp(initHp + lvl * lvlUpHp * end);
        setMaxMp(initMp + lvl * lvlUpMp * Int);
        
        setHp(maxHp);
        setMp(maxMp);
        setJp(0);
  
        if (gender.equals(Gender.MALE)) {
            setStr(initMaleStr);
        } else if (gender.equals(Gender.FEMALE)) {
            setStr(initFemaleStr);
        }

        if (gender.equals(Gender.MALE)) {
            setEnd(initMaleEnd);
        } else if (gender.equals(Gender.FEMALE)) {
            setEnd(initFemaleEnd);
        }

        if (gender.equals(Gender.MALE)) {
            setDex(initMaleDex);
        } else if (gender.equals(Gender.FEMALE)) {
            setDex(initFemaleDex);
        }

        setLuck(initLuck);
        
        if (gender.equals(Gender.MALE)) {
            setInt(initMaleInt);
        } else if (gender.equals(Gender.FEMALE)) {
            setInt(initFemaleInt);
        }

        setStatus(Status.NORMAL);

        
    }//End Level Defined Constructor
    
    /** Name-Level Defined Constructor
     * 
     * Sets the stats up according to the name and level given
     * 
     * @param name Name of the character
     * @param lvl Level of the character
     */

    public Player(String name, int lvl) {
        
        setName(name);                                        //To be set in main game loop or something
        setJob(Job.WARRIOR);
        setLvl(lvl);      
        setMaxHp(initHp + lvl * lvlUpHp * end);
        setMaxMp(initMp + lvl * lvlUpMp * Int);
        
        setHp(maxHp);
        setMp(maxMp);
        setJp(0);
  
        if (gender.equals(Gender.MALE)) {
            setStr(initMaleStr);
        } else if (gender.equals(Gender.FEMALE)) {
            setStr(initFemaleStr);
        }

        if (gender.equals(Gender.MALE)) {
            setEnd(initMaleEnd);
        } else if (gender.equals(Gender.FEMALE)) {
            setEnd(initFemaleEnd);
        }

        if (gender.equals(Gender.MALE)) {
            setDex(initMaleDex);
        } else if (gender.equals(Gender.FEMALE)) {
            setDex(initFemaleDex);
        }

        setLuck(initLuck);
        
        if (gender.equals(Gender.MALE)) {
            setInt(initMaleInt);
        } else if (gender.equals(Gender.FEMALE)) {
            setInt(initFemaleInt);
        }

        setStatus(Status.NORMAL);
        
    }//End Name-Level Defined Constructor
    
    /** Name-Level-Job Defined Constructor
     * 
     * Sets the stats of the character according to name, level, and job given
     * 
     * @param name Name of the character
     * @param lvl Level of the character
     * @param job Job of the character
     */
    
    public Player(String name, int lvl, Job job){
        
        setName(name);                                        //To be set in main game loop or something
        setJob(job);
        setLvl(lvl);      
        setMaxHp(initHp + lvl * lvlUpHp * end);
        setMaxMp(initMp + lvl * lvlUpMp * Int);
        
        setHp(maxHp);
        setMp(maxMp);
        setJp(jLvl * jLvlUp);
  
        if (gender.equals(Gender.MALE)) {
            setStr(initMaleStr);
        } else if (gender.equals(Gender.FEMALE)) {
            setStr(initFemaleStr);
        }

        if (gender.equals(Gender.MALE)) {
            setEnd(initMaleEnd);
        } else if (gender.equals(Gender.FEMALE)) {
            setEnd(initFemaleEnd);
        }

        if (gender.equals(Gender.MALE)) {
            setDex(initMaleDex);
        } else if (gender.equals(Gender.FEMALE)) {
            setDex(initFemaleDex);
        }

        setLuck(initLuck);
        
        if (gender.equals(Gender.MALE)) {
            setInt(initMaleInt);
        } else if (gender.equals(Gender.FEMALE)) {
            setInt(initFemaleInt);
        }

        setStatus(Status.NORMAL);
        
    }//End Name-Level-Job Defined constructor
  
    ////////////////////////////////////////////////////////////////////////////////////////////////
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
    ////////////////////////////////////////////////////////////////////////////////////////////////
    
    /** setName method
     * 
     * Sets the name of the character
     * 
     * @param name Holds the String with the characters name
     * 
     */
    public void setName(String name) {

        this.name = name;

    }//End setName

    /** getName method
     * 
     * Returns the name of the character
     * 
     * @return name 
     */
    public String getName() {

        return (name);

    }//End getName

    /** setGender method
     * 
     * Sets the gender of the character
     * 
     * Pre-Conditon: Has to be either male or female. If using a wierd 
     * race with 3 genders, this class doesn't support it. lol. 
     * 
     * @param gender
     */
    public void setGender(Gender gender) {

        this.gender = gender;

    }//End setGender

    /** getGender method
     * 
     * Returns the gender of the character
     * 
     * @return gender
     */
    public Gender getGender() {

        return (gender);

    }//End getGender

    /** setHp method
     * 
     * Sets the hit points of the character
     * 
     * @param hp Holds the hit points
     */
    public void setHp(int hp) {

        this.hp = hp;
        this.hp = this.hp + end;

    }//End setHp

    /** getHp method
     * 
     * Returns the hit points of the character
     * 
     * @return hp
     */
    public int getHp() {

        return (hp);

    }//End getHp

    /** setMp method
     * 
     * Sets the magic points of the character
     * 
     * @param mp Holds the magic points of the character
     */
    public void setMp(int mp) {

        this.mp = mp;
        this.mp = this.mp + jInt;

    }//End setMp

    /** getMp method
     * 
     * Returns the magic points of the character
     * 
     * @return mp
     */
    public int getMp() {

        return (mp);

    }//End getMp
    
    /** setMaxHp method
     * 
     * Sets the max hit points the character has
     * 
     * @param maxHp The max hit points
     */

    public void setMaxHp(int maxHp) {
        
        this.maxHp = maxHp;
        
    }//End setMaxHp
    
    /** getMaxHp method
     * 
     * Returns the max hit points of the character
     * 
     * @return maxHp 
     */
    
    public int getMaxHp() {
        
        return (maxHp);
        
    }//End getMaxHp
    
    /** setMaxMp method
     * 
     * Sets the max magic points the character has
     * 
     * @param maxMp
     */
        
    public void setMaxMp(int maxMp) {
        
        this.maxMp = maxMp;
        
    }//End setMaxMp
    
    /** getMaxMp method
     * 
     * Returns the max magic points the character has
     * 
     * @return maxMp
     */
    
    public int getMaxMp() {
        
        return (maxMp);
        
    }//End getMaxHp
    
    /** setJp method
     * 
     * Sets the job points the character has
     * 
     * @param jp The amount of job experience the player has
     */
    
    public void setJp(int jp) {
        
        this.jp = jp;
        
    }//End setJp
    
    /** getJp method
     * 
     * Returns the amount of job points a character has
     * 
     * @return jp Job points
     */
    
    public int getJp() {
        
        return (jp);
        
    }//End getJp
    
    /** setXp method
     * 
     * Sets the experience points of the character
     * 
     * @param xp Holds the experience points of the character
     */
    public void setXp(long xp) {

        this.xp = xp;

    }//End setXp

    /** getXp method
     * 
     * Returns the experience points of the character
     * 
     * @return xp
     */
    public long getXp() {

        return (xp);

    }//End getXp

    /** setLvl method
     * 
     * Sets the level of the character
     * 
     * @param lvl Holds the level of the character
     */
    public void setLvl(int lvl) {

        this.lvl = lvl;

    }//End setLvl

    /** getLvl method
     * 
     * Returns the level of the character
     * 
     * @return lvl
     */
    public int getLvl() {

        return (lvl);

    }//End getLvl

    /** setStr method
     * 
     * Sets the strength of the character
     * 
     * @param str Holds the strength of the character
     */
    public void setStr(int str) {

        this.str = str;
        this.str = this.str + jStr;

    }//End setStr

    /** getStr method
     * 
     * Returns the strength of the character
     * 
     * @return str
     */
    public int getStr() {

        return (str);

    }//End getStr

    /** setEnd method
     * 
     * Sets the endurance of the character
     * 
     * @param end Holds the endurance of the character
     */
    public void setEnd(int end) {

        this.end = end;
        this.end = this.end + jEnd;

    }//End setEnd

    /** getEnd method
     * 
     * Returns the endurance of the character
     * 
     * @return end
     */
    public int getEnd() {

        return (end);

    }//End getEnd

    /** setDex method
     * 
     * Sets the dexterity of the character
     * 
     * @param deex Holds the dexterity of the character
     */
    public void setDex(int dex) {

        this.dex = dex;
        this.dex = this.dex + jDex;

    }//End setDex

    /** getDex method
     * 
     * Returns the dexterity of the character
     * 
     * @return dex
     */
    public int getDex() {

        return (dex);

    }//End getDex

    /** setInt method
     * 
     * Sets the characters intelligence
     * 
     * @param Int The intelligence of the character
     */
    
    public void setInt(int Int) {
        
        this.Int = Int;
        this.Int = Int + jInt;
        
    }//End setInt
    
    /** getInt method
     * 
     * Returns the intelligence of the character
     * 
     * @return Int
     */
    
    public int getInt() {
        
        return (Int);
        
    }//End getInt 
    
    /** setLuck method
     * 
     * Sets the luck of the character
     * 
     * @param luck Holds the luck of the character
     */
    public void setLuck(int luck) {

        this.luck = luck;
        this.luck = this.luck + jLuck;

    }//End setLuck

    /** getLuck method
     * 
     * Returns the luck of the character
     * 
     * @return luck
     */
    public int getLuck() {

        return (luck);

    }//End getLuck

    /** lvlUp method
     * 
     * Updates the status of the character when s/he levels up
     * 
     */
    public void lvlUp() {

        while(lvl < maxLvl) {
            maxHp = maxHp + lvlUpHp;
            maxMp = maxMp + lvlUpMp;
            hp = maxHp;                                     //Restores all the characters hp on levelup
            mp = maxMp;                                     //Restores all the characters mp on levelup
            str = str + lvlUpStat;
            end = end + lvlUpStat;
            dex = dex + lvlUpStat;
            luck = luck + lvlUpStat;

            lvl = lvl + 1;
        }//End while
        
        while(lvl == maxLvl){
            
            JOptionPane.showMessageDialog(null, "You are already at the maximum level!!!");      //Display method will change
            
        }//End while
        
    }//End lvlUp

    /** setStatus method
     * 
     * Sets the status of the character
     * 
     * @param status Holds the status of the character
     */
    public void setStatus(Status status) {

        this.status = status;

        if(hp == 0) {
            
            status = Status.KO;
            
        }//End if
        
        switch (status) {

            case NORMAL: {
                
            }//End normal case

            case KO: {
                
            }//End ko case

            case POISON: {
                
                //hp = hp - poisonDamage;
                
            }//End poison case

            case SLEEP: {
                
            }//End sleep case

            case PETRIFIED: {
                
            }//End petrified case

            case CURSED: {
                
            }//End cursed case

            case BLIND: {
                
            }//End blind case
            
            default: {
            }//End default

        }//End switch

    }//End setStatus

    /** getStatus method
     * 
     * Returns the status of the character
     * 
     * @return status
     */
    public Status getStatus() {

        return (status);

    }//End getStatus

    /** setJob method
     * 
     * Sets the job/class of the character
     * 
     * @param job Holds the job/class of the character
     */
    private void setJob(Job job) {

        //this.job = job;


        switch (job) {

            case WARRIOR: {
                
                jStr = 2;
                jEnd = 2;
                jDex = 1;
                jInt = 0;
                jLuck = 0;
                
            }//End WARRIOR case

            case KNIGHT: {
                
                jStr = 4;
                jEnd = 3;
                jDex = -3;
                jInt = 2;
                jLuck = 3;
                                
            }//End KNIGHT case

            case BMAGE: {
                
                jStr = -1;
                jEnd = 1;
                jDex = 3;
                jInt = 4;
                jLuck = 2;
                
            }//End BMAGE case

            case WMAGE: {
                
                jStr = -1;
                jEnd = 1;
                jDex = 3;
                jInt = 4;
                jLuck = 2;
                
            }//End WMAGE case

            default: {
                
                job = Job.WARRIOR;
                
            }//End default

        }//End switch

    }//End setJob method
    
    /** getJob method
     * 
     * Returns the job of the character
     * 
     * @return job
     */
    
    public Job getJob() {
        
        return(job);
        
    }//End getJob
    
}//End Player class





Item Class

/**
 *
 * @author Erica Boyer
 * @datecreated 30 May 2009
 * 
 * This class handles the events for using items and such.
 * 
 * >>to be converted to C++ later
 * 
 */
public class Item {

    public enum Items {POTION, HIPOTION, ETHER, HIETHER, ELIXIR}
    
    private final int potion = 100;                             //How many hit points a potion heals
    private final int hiPotion = 250;                           //How many hit points a hi-potion heals
    private final int ether = 50;                               //How many magic points an ether heals
    private final int hiEther = 100;                            //How many magic points a hi-ether heals
    private final int elixir = 9999;                            //How many hit/magic points an elixir heals
    
    private int potionInvetory = 1;                             //How many potions are in your invetory
    private int hiPotionInvetory = 0;                           //How many hi-potions are in your invetory
    private int etherInvetory = 1;                              //How many ethers are in your invetory
    private int hiEtherInvetory = 0;                            //How many hi-ethers are in your invetory
    private int elixirInvetory = 0;                             //How many elixirs are in your invetory
    
    private int invetory = potionInvetory + 
            hiPotionInvetory + etherInvetory +
            hiEtherInvetory + elixirInvetory;                   //Holds the total amount of items in your invetory
    
    /**useRestorativeItem method
     * 
     * Uses given item on given character and minuses it from the invetory
     * Also checks to make sure you're not trying to use items you don't have >_>
     * 
     * @param item
     * @param character
     */
    
    public void useItem(Items item, Player character) {
        
        switch(item) {
            
            case POTION: {
                
                while(potionInvetory > 0) {
                
                    character.setHp(character.getHp() + potion);
                    potionInvetory = potionInvetory - 1;
                
                }//End while
                
            }//End potion case
            
            case HIPOTION: {
                
                while(hiPotionInvetory > 0) {
                
                    character.setHp(character.getHp() + hiPotion);
                    hiPotionInvetory = hiPotionInvetory - 1;
                
                }//End while
                
            }//End hi-potion case
            
            case ETHER: {
                
                while(etherInvetory > 0) {
                
                    character.setMp(character.getMp() + ether);
                    etherInvetory = etherInvetory - 1;
                
                }//End while
                
            }//End ether case
            
            case HIETHER: {
                
                while(hiEtherInvetory > 0) {
                
                    character.setMp(character.getMp() + hiEther);
                    hiEtherInvetory = hiEtherInvetory - 1;
                
                }//End while
                
            }//End hi-ether case
             
            case ELIXIR: {
                
                while(elixirInvetory > 0) {
                    
                    character.setHp(character.getHp() + elixir);
                    character.setMp(character.getMp() + elixir);
                    elixirInvetory = elixir - 1;
                
                }//End while
                
            }//End elixir case
            
        }//End switch
        
    }//End useItem
    
    /** getItem method
     * 
     * Adds items to your invetory, provided that you have room.
     * 
     * @param item
     */
    
    public void getItem(Items item) {
        
        switch(item) {
            
            case POTION: {
                
                while(potionInvetory < 20) {
                    
                    potionInvetory = potionInvetory + 1;
                    
                }//End while
                
            }//End potion case
            
            case HIPOTION: {
                
                while(hiPotionInvetory < 10) {
                    
                    hiPotionInvetory = hiPotionInvetory + 1;
                    
                }//End while
                
            }//End hi-potion case
            
            case ETHER: {
                
                while(etherInvetory < 20){
                    
                    etherInvetory = etherInvetory + 1;
                
                }//End while
                
            }//End ether case
            
            case HIETHER: {
                
                while(hiEtherInvetory < 10) {
                    
                    hiEtherInvetory = hiEtherInvetory + 1;
                    
                }//End while
                
            }//End hi-ether case
             
        }//End switch
        
    }//End getItem
    
}//End Item class




Warrior Class

/**
 *
 * @author Erica Boyer
 * @datecreated 30 May 2009
 * 
 * Extends player. Can't believe I didn't think of this sooner. What a retard.
 * 
 * >>To be converted to C++ later.
 * 
 */

public class Warrior extends Player{

    private final int initHp = 15;                      //Initial hit points
    private final int initMp = 5;                       //Initial magic points
    private final int initXp = 0;                       //Initial experience
    private final int initLvl = 1;                      //Initial level
    private final int initMaleStr = 4;                  //Initial male strength
    private final int initFemaleStr = 3;                //Initial female strength
    private final int initMaleEnd = 3;                  //Initial male endurance
    private final int initFemaleEnd = 2;                //Initial female endurance
    private final int initMaleInt = 2;                  //Initial male intelligence
    private final int initFemaleInt = 4;                //Initial female intelligence
    private final int initMaleDex = 2;                  //Initial male dexerity
    private final int initFemaleDex = 4;                //Initial female dexerity
    private final int initLuck = 2;                     //They start out the same luck

    private final int lvlUpFirst5 = 50;                 //Amount of experience needed to level up the first 5 levels
    private final int lvlUp6Thru20 = 100;               //Amount of experience needed to level up levels 6 through 20
    private final int lvlUp21Thru50 = 200;              //Amount of experience needed to level up levels 21 through 50
    private final int lvlUpHp = 4;                      //Amount of hit points gained every level up  
    private final int lvlUpMp = 2;                      //Amount of magic points gained every level up
    private final int lvlUpStat = 1;                    //Amount of str, end, dex, and luck gained every level up
    private final int maxLvl = 50;                      //Max level a character can be
    private final int maxJlvl = 10;                     //Max level a characters job can be
    
    private int jLvl = 1;                               //Holds the level of the jobs held by the character
    private int jStr = 2;                               //Holds the stegth the class gives initially
    private int jEnd = 2;                               //Holds the endurance the class gives initially
    private int jDex = 1;                               //Holds the dexterity the class gives initially
    private int jInt = 0;                               //Holds the intelligence the class gives initially
    private int jLuck = 0;                              //Holds the luck the class gives initially
    //private int jHpBonus;                             //Holds the bonus hit points the characters job gives
    //private int jMpBonus;                             //Holds the bonus magic points the characters job gives

    private String name;                                //Holds the characters name
    private Gender gender;                              //Holds the characters gender
    private int hp;                                     //Holds the characters hit points
    private int mp;                                     //Holds the characters magic points
    private int jp;                                     //Holds the characters job points (experience for jobs)
    private int maxHp;                                  //Holds the max hit points the character has
    private int maxMp;                                  //Holds the mas magic points the character has
    private long xp;                                    //Holds the characters experience points
    private int lvl;                                    //Holds the characters level
    private int str;                                    //Holds the characters strength (double due to Warriors focus ability)
    private int end;                                    //Holds the characters endurance
    private int Int;                                    //Holds the characters intelligence
    private int dex;                                    //Holds the characters dexterity
    private int luck;                                   //Holds the characters luck
    private Status status;                              //Holds the characters status
    private double strMultiplier;                          //Holds the strenth multiplier for the character during battle
    
    ////////////////////////////////////////////////////////////////////////////////////////////////
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
    ////////////////////////////////////////////////////////////////////////////////////////////////
    
    public Warrior() {

        setName("New Character");
        
        setMaxHp(initHp + end);
        setMaxMp(initMp + Int);
        
        setHp(maxHp);
        setMp(maxMp);
        setJp(0);
       
        setXp(initXp);
        setLvl(initLvl);

        if (gender.equals(Gender.MALE)) {
            setStr(initMaleStr);
        } else if (gender.equals(Gender.FEMALE)) {
            setStr(initFemaleStr);
        }

        if (gender.equals(Gender.MALE)) {
            setEnd(initMaleEnd);
        } else if (gender.equals(Gender.FEMALE)) {
            setEnd(initFemaleEnd);
        }

        if (gender.equals(Gender.MALE)) {
            setDex(initMaleDex);
        } else if (gender.equals(Gender.FEMALE)) {
            setDex(initFemaleDex);
        }

        setLuck(initLuck);
        
        if (gender.equals(Gender.MALE)) {
            setInt(initMaleInt);
        } else if (gender.equals(Gender.FEMALE)) {
            setInt(initFemaleInt);
        }

        setStatus(Status.NORMAL);

    }//End constructor

    /** Level Defined Constructor
     * 
     * Sets the stats up according to the level given
     * 
     * @param lvl The level of the character created
     * 
     */
    public Warrior(int lvl) {

        setName("");                                        //To be set in main game loop or something

        setLvl(lvl);      
        setMaxHp(initHp + lvl * lvlUpHp * end);
        setMaxMp(initMp + lvl * lvlUpMp * Int);
        
        setHp(maxHp);
        setMp(maxMp);
        setJp(0);
  
        if (gender.equals(Gender.MALE)) {
            setStr(initMaleStr);
        } else if (gender.equals(Gender.FEMALE)) {
            setStr(initFemaleStr);
        }

        if (gender.equals(Gender.MALE)) {
            setEnd(initMaleEnd);
        } else if (gender.equals(Gender.FEMALE)) {
            setEnd(initFemaleEnd);
        }

        if (gender.equals(Gender.MALE)) {
            setDex(initMaleDex);
        } else if (gender.equals(Gender.FEMALE)) {
            setDex(initFemaleDex);
        }

        setLuck(initLuck);
        
        if (gender.equals(Gender.MALE)) {
            setInt(initMaleInt);
        } else if (gender.equals(Gender.FEMALE)) {
            setInt(initFemaleInt);
        }

        setStatus(Status.NORMAL);

        
    }//End Level Defined Constructor
    
    /** Name-Level Defined Constructor
     * 
     * Sets the stats up according to the name and level given
     * 
     * @param name Name of the character
     * @param lvl Level of the character
     */

    public Warrior(String name, int lvl) {
        
        setName(name);                                        //To be set in main game loop or something
        setLvl(lvl);      
        setMaxHp(initHp + lvl * lvlUpHp * end);
        setMaxMp(initMp + lvl * lvlUpMp * Int);
        
        setHp(maxHp);
        setMp(maxMp);
        setJp(0);
  
        if (gender.equals(Gender.MALE)) {
            setStr(initMaleStr);
        } else if (gender.equals(Gender.FEMALE)) {
            setStr(initFemaleStr);
        }

        if (gender.equals(Gender.MALE)) {
            setEnd(initMaleEnd);
        } else if (gender.equals(Gender.FEMALE)) {
            setEnd(initFemaleEnd);
        }

        if (gender.equals(Gender.MALE)) {
            setDex(initMaleDex);
        } else if (gender.equals(Gender.FEMALE)) {
            setDex(initFemaleDex);
        }

        setLuck(initLuck);
        
        if (gender.equals(Gender.MALE)) {
            setInt(initMaleInt);
        } else if (gender.equals(Gender.FEMALE)) {
            setInt(initFemaleInt);
        }

        setStatus(Status.NORMAL);
        
    }//End Name-Level Defined Constructor
    
    ////////////////////////////////////////////////////////////////////////////////////////////////
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
    ////////////////////////////////////////////////////////////////////////////////////////////////
    
    public void attack(Player victim) {
        
        //Have to look at api for random. Determines hit or miss.
        int attack = str;  //luck will determine the multiplier. rand(luck/2)*str
        victim.setHp(victim.getHp() - attack);
        jp = jp + 1;
        
        if(victim.getHp() <= 0) {
            
            xp = xp + (victim.getLvl() * 2);
            
        }//end if
        
    }//End attack
    
    public void focus() {
        
        str = str + (str % 2);
        
    }//End focus
    
}//End Warrior class




Town Class

/**
 *
 * @author Erica Boyer
 * @datecreated 30 May, 2009
 * 
 * This class makes town objects. You can add more action events yourself.
 * 
 */

public class Town {

    public enum Buildings{SHOP, ARMORY, LIBRARY, HOUSE, CASTLE}
    
    private String townName;                            //Holds towns name
    
    public Town(String townName) {
        
        setTownName(townName);
        
    }//End constructor
    
    /** setTownName
     * 
     * Sets the towns name
     * 
     * @param townName 
     */
    
    public void setTownName(String townName) {
        
        this.townName = townName;
        
    }//End setTownName
    
    /** getTownName method
     * 
     * Returns the towns name
     * 
     * @return townName
     */
    
    public String getTownName() {
        
        return (townName);
        
    }//End getTownName
    
    public void enterShop() {
        
        //Shop menu prompt (seperate class I guess)
        
    }//End enterShop
    
}//End Town class


2 Comments On This Entry

Page 1 of 1

janne_panne 

31 July 2009 - 02:51 PM
HelloJust thought I'd give you some feedback of your code which I noticed being helpful and making the code look better, even though this post is already two months old and your code might have changed dramatically.You have total of 4 constructors in your player class and all of them set the player's str/dex/int/end exactly the same way. It would be a pain to update that code so I think you should make another method, maybe something called: private void setPlayerInitialStats() {} which sets player's str/dex/int/end and then call that method from each constructor. The same goes for warrior class.I would also do something for those final variables. Maybe create a new class which has all of them and just change them to public static final so you could call them by just typing MyClass.initMaleEnd;This way you wouldn't have them in all of your classes which inherits Player class so they would again be much easier to administrate later on when you notice you need something to be different.
0

NeoTifa 

09 October 2009 - 08:29 PM
Thanks. I've let this project go for now. Maybe during winter break I might pick it back up. ^___^ Good ideas. Never programmed a game like this before.
0
Page 1 of 1

Trackbacks for this entry [ Trackback URL ]

There are no Trackbacks for this entry

September 2020

S M T W T F S
  12345
6789101112
13141516171819
2021 22 23242526
27282930   

Recent Entries

Search My Blog

0 user(s) viewing

0 Guests
0 member(s)
0 anonymous member(s)