Character chooser

Side project of mine

  • (2 Pages)
  • +
  • 1
  • 2

17 Replies - 953 Views - Last Post: 29 June 2009 - 09:43 AM

#1 NeoTifa  Icon User is offline

  • Whorediot
  • member icon





Reputation: 2495
  • View blog
  • Posts: 15,453
  • Joined: 24-September 08

Character chooser

Posted 11 May 2009 - 01:30 PM

Don't know what it's gonna be called yet, but.... oh well. Project: N00b has been kinda at a stand-still. So, I decided I was gonna work on my own little mini project. I had in mind a little character chooser/creator for an rpg (maybe even morpg or something. Gabe's inspired me lol). I'm working on some generic sprites to load into it. They suck. Lol. I only have 4 done.


What I want it to do:
-player can pick class
-pic of character of that class will display in same screen
-player can pick characters name
-characters stats will display under name, which is under the pic

What I might do in the future:
-make changeable gender
-make changeable equipment
-make changeable colors for under armor and hair
-make changeable hair styles

What I got done so far:
-male warrior sprite
Posted Image
-male knight sprite
Posted Image
-male black mage
Posted Image
-male white mage
Posted Image

I'm planning on doing this in Java so far, with GUI. By the time I finish the sprites though I might be on my way with c++ lol. I'm going to be working on an archer, black mage, white mage, and maybe a monk or something.

This post has been edited by NeoTifa: 12 May 2009 - 06:44 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Character chooser

#2 NeoTifa  Icon User is offline

  • Whorediot
  • member icon





Reputation: 2495
  • View blog
  • Posts: 15,453
  • Joined: 24-September 08

Re: Character chooser

Posted 13 May 2009 - 05:43 AM

I did some drafting of the layout. After I take my exams today I might work on some female sprites. <3

[attachment=11875:attachment]
Was This Post Helpful? 0
  • +
  • -

#3 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 942
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: Character chooser

Posted 14 May 2009 - 02:04 PM

Lay out looks good. Keep up the good work.
Was This Post Helpful? 0
  • +
  • -

#4 NeoTifa  Icon User is offline

  • Whorediot
  • member icon





Reputation: 2495
  • View blog
  • Posts: 15,453
  • Joined: 24-September 08

Re: Character chooser

Posted 14 May 2009 - 05:08 PM

Thank you. I've been busy, so I'll update later.
Was This Post Helpful? 0
  • +
  • -

#5 NeoTifa  Icon User is offline

  • Whorediot
  • member icon





Reputation: 2495
  • View blog
  • Posts: 15,453
  • Joined: 24-September 08

Re: Character chooser

Posted 15 May 2009 - 07:11 PM

This is what I've gotten done of my player class of my game library (which I will be making at the same time, and using to make the chooser and such)


/**
 *
 * @author Erica Boyer
 * @datecreated 19 Mar 2009
 * @lastupdate 15 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.
 * 
 * 
 */
public class Player {

    public enum Job {WARRIOR, KNIGHT, BMAGE, WMAGE}
    public enum Status {NORMAL, KO, POISON, SLEEP, PETRIFIED, CURSED}
    public enum Gender {MALE, FEMALE}
    
    private final int initHp = 25;                      //Initial hit points
    private final int initMp = 10;                      //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 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 lvlUpHp = 5;                      //Amount of hit points gained every level up  
    private final int lvlUpMp = 3;                      //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 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 jLuck;                                  //Holds the luck the class gives initially

    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 long xp;                                    //Holds the characters experience points
    private int lvl;                                    //Holds the characters level
    private int str;                                    //Holds the characters strength
    private int end;                                    //Holds the characters endurance
    private int dex;                                    //Holds the characters dexterity
    private int luck;
    private Status status;

    //Player[] heroList = new Player[4];
    /**No-Arg Constructor Player
     * 
     * Sets up all the stats the the character will need.
     * 
     * @param none
     *  
     */
    public Player() {

        setName("New Character");
        setJob(job);                    //need to get Job from chooser or other class

        setHp(initHp);
        setMp(initMp);
        setXp(initXp);
        setLvl(initLvl);

        if (gender.equals(0)) {
            setStr(initMaleStr);
        } else if (gender.equals(1)) {
            setStr(initFemaleStr);
        }

        if (gender.equals(0)) {
            setEnd(initMaleEnd);
        } else if (gender.equals(1)) {
            setEnd(initFemaleEnd);
        }

        if (gender.equals(0)) {
            setDex(initMaleDex);
        } else if (gender.equals(1)) {
            setDex(initFemaleDex);
        }

        if (gender.equals(0)) {
            setLuck(initLuck);
        } else if (gender.equals(1)) {
            setLuck(initLuck);
        }

        setStatus(status);

    //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) {

        setHp(initHp + lvl * lvlUpHp * end);
        setMp(initMp + lvl * lvlUpMp * str);

        if (gender.equals("male")) {
            setStr(initMaleStr + lvl * lvlUpStat);
        } else if (gender.equals("female")) {
            setStr(initFemaleStr + lvl * lvlUpStat);
        }

        if (gender.equals("male")) {
            setEnd(initMaleEnd + lvl * lvlUpStat);
        } else if (gender.equals("female")) {
            setEnd(initFemaleEnd + lvl * lvlUpStat);
        }

        if (gender.equals("male")) {
            setDex(initMaleDex + lvl * lvlUpStat);
        } else if (gender.equals("female")) {
            setDex(initFemaleDex + lvl * lvlUpStat);
        }

        if (gender.equals("male")) {
            setLuck(initLuck + lvl * lvlUpStat);
        } else if (gender.equals("female")) {
            setLuck(initLuck + lvl * lvlUpStat);
        }


    }

    /** 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;

    }//End setMp

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

        return (mp);

    }//End getMp

    /** 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;

    }//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;

    }//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;

    }//End setDex

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

        return (dex);

    }//End getDex

    /** setLuck method
     * 
     * Sets the luck of the character
     * 
     * @param luck Holds the luck of the character
     */
    public void setLuck(int luck) {

        this.luck = luck;

    }//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() {

        hp = hp + lvlUpHp;
        mp = mp + lvlUpMp;
        str = str + lvlUpStat;
        end = end + lvlUpStat;
        dex = dex + lvlUpStat;
        luck = luck + lvlUpStat;

        lvl = lvl + 1;

    }//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;

        switch (status) {

            case NORMAL: {
            }//End normal case

            case KO: {
            }//End ko case

            case POISON: {
            }//End poison case

            case SLEEP: {
            }//End sleep case

            case PETRIFIED: {
            }//End petrified case

            case CURSED: {
            }//End cursed 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 = ;
            }//End WARRIOR case

            case KNIGHT: {
            }//End KNIGHT case

            case BMAGE: {
            }//End BMAGE case

            case WMAGE: {
            }//End WMAGE case

            default: {
            }//End default

        }//End switch

    }//End setJob method
}//End Player class



Was This Post Helpful? 0
  • +
  • -

#6 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 942
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: Character chooser

Posted 15 May 2009 - 10:46 PM

Don't know much about Java. It look similar to C++/C# code and it looks pretty solid. Using enums will enable you to easily add new states to the class.
Was This Post Helpful? 0
  • +
  • -

#7 NeoTifa  Icon User is offline

  • Whorediot
  • member icon





Reputation: 2495
  • View blog
  • Posts: 15,453
  • Joined: 24-September 08

Re: Character chooser

Posted 17 May 2009 - 12:48 PM

Okay, updated my Player class, and started on an Item class to break up the monotony. <3 Barely anywhere on it.


/**
 *
 * @author Erica Boyer
 * @datecreated 19 Mar 2009
 * @lastupdate 17 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 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;                                   //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 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 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
    private int end;                                    //Holds the characters endurance
    private int dex;                                    //Holds the characters dexterity
    private int luck;                                   //Holds the characters luck
    private Status status;                              //Holds the characters status
    
    private final int poisonDamage = 5;                 //How much damage being poisoned does a turn

    //Player[] heroList = new Player[4];
    /**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 + jHpBonus * jLvl);
        setMaxMp(initMp + jMpBonus * jLvl);
        
        setHp(maxHp);
        setMp(maxMp);
       
        setXp(initXp);
        setLvl(initLvl);

        if (gender.equals(0)) {
            setStr(initMaleStr);
        } else if (gender.equals(1)) {
            setStr(initFemaleStr);
        }

        if (gender.equals(0)) {
            setEnd(initMaleEnd);
        } else if (gender.equals(1)) {
            setEnd(initFemaleEnd);
        }

        if (gender.equals(0)) {
            setDex(initMaleDex);
        } else if (gender.equals(1)) {
            setDex(initFemaleDex);
        }

        if (gender.equals(0)) {
            setLuck(initLuck);
        } else if (gender.equals(1)) {
            setLuck(initLuck);
        }

        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);
              
        setMaxHp(initHp + lvl * lvlUpHp * end + jHpBonus * jLvl);
        setMaxMp(initMp + lvl * lvlUpMp * str + jMpBonus * jLvl);
        
        setHp(maxHp);
        setMp(maxMp);
  
        if (gender.equals("male")) {
            setStr(initMaleStr + jStr + lvl * lvlUpStat);
        } else if (gender.equals("female")) {
            setStr(initFemaleStr + jStr + lvl * lvlUpStat);
        }

        if (gender.equals("male")) {
            setEnd(initMaleEnd + jEnd * jLvl + lvl * lvlUpStat);
        } else if (gender.equals("female")) {
            setEnd(initFemaleEnd + jEnd * jLvl + lvl * lvlUpStat);
        }

        if (gender.equals("male")) {
            setDex(initMaleDex + jDex + lvl * lvlUpStat);
        } else if (gender.equals("female")) {
            setDex(initFemaleDex + jDex + lvl * lvlUpStat);
        }

        if (gender.equals("male")) {
            setLuck(initLuck + jLuck + lvl * lvlUpStat);
        } else if (gender.equals("female")) {
            setLuck(initLuck + jLuck + lvl * lvlUpStat);
        }

        setStatus(Status.NORMAL);

        
    }//End Level 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;

    }//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
    
    /** 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;

    }//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;

    }//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;

    }//End setDex

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

        return (dex);

    }//End getDex

    /** setLuck method
     * 
     * Sets the luck of the character
     * 
     * @param luck Holds the luck of the character
     */
    public void setLuck(int luck) {

        this.luck = luck;

    }//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;
                jLuck = 0;
                
            }//End WARRIOR case

            case KNIGHT: {
                
            }//End KNIGHT case

            case BMAGE: {
                
            }//End BMAGE case

            case WMAGE: {
                
            }//End WMAGE case

            default: {
                
            }//End default

        }//End switch

    }//End setJob method
    
}//End Player class




603 lines



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

    private final int potion = 100;
    private final int hiPotion = 250;
    private final int ether = 50;
    private final int hiEther = 100;
    
    
}//End Item class



20 lines lol.


This is really just a draft until I figure out what I want to do with it :\
Was This Post Helpful? 0
  • +
  • -

#8 gabehabe  Icon User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1376
  • View blog
  • Posts: 10,951
  • Joined: 06-February 08

Re: Character chooser

Posted 27 May 2009 - 04:46 AM

View PostNeoTifa, on 17 May, 2009 - 06:48 PM, said:

603 lines
Line count isn't everything. :)
Was This Post Helpful? 0
  • +
  • -

#9 NeoTifa  Icon User is offline

  • Whorediot
  • member icon





Reputation: 2495
  • View blog
  • Posts: 15,453
  • Joined: 24-September 08

Re: Character chooser

Posted 27 May 2009 - 06:14 AM

That's the most I've ever really done...
Was This Post Helpful? 0
  • +
  • -

#10 NeoTifa  Icon User is offline

  • Whorediot
  • member icon





Reputation: 2495
  • View blog
  • Posts: 15,453
  • Joined: 24-September 08

Re: Character chooser

Posted 31 May 2009 - 09:05 AM

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



Was This Post Helpful? 0
  • +
  • -

#11 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 942
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: Character chooser

Posted 31 May 2009 - 09:36 AM

Cool beans! :^: :D
Was This Post Helpful? 0
  • +
  • -

#12 NeoTifa  Icon User is offline

  • Whorediot
  • member icon





Reputation: 2495
  • View blog
  • Posts: 15,453
  • Joined: 24-September 08

Re: Character chooser

Posted 04 June 2009 - 07:38 PM

I submitted this project to sourceforge. It's still pending. Working on actually building this chooser now. Worked on the library enough for now x__X I'm thinking about using DirectX instead of just using Java awt/swing.
Was This Post Helpful? 0
  • +
  • -

#13 NeoTifa  Icon User is offline

  • Whorediot
  • member icon





Reputation: 2495
  • View blog
  • Posts: 15,453
  • Joined: 24-September 08

Re: Character chooser

Posted 05 June 2009 - 08:42 PM

Okay, got my project approved. I'm almost done setting up my GUI. Very generic and buggy. This is what I have so far:

**NOTICE**
This is NOT done. If you compile you wont get want I was hoping for!!!

/**
 *
 * @author Erica Boyer
 * @datecreated 4 Jun 2009
 * @lastupdate 5 Jun 2009
 * 
 * This is a GUI window for selecting and customizing new characters.
 * 
 * >>To be converted to C++ later 
 * 
 */

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
//import java.util.*;

public class Selector{

    private final int WINDOW_WIDTH = 950;
    private final int WINDOW_HEIGHT = 650;
    
    String title = "NeoTifa's Generic Character Chooser";
    String nameMessage = "Please enter your characters name:";
    //String defualtName = "Sexy McLuffykins";                //LOL!!!!!
    String classMessage = "What class is your character?";
    String genderMessage = "Male or female?";
    ImageIcon sprite;
            
    private String name;
    private String Class;
    private int lvl;
    private int jLvl;
    private int hp;
    private int mp;
    private int str;
    private int dex;
    private int end;
    private int Int;
    private int luck;
    private String sLvl;
    private String sJLvl;
    private String sHp;
    private String sMp;
    private String sStr;
    private String sDex;
    private String sEnd;
    private String sInt;
    private String sLuck;
    
    //private JPanel mainPanel = new JPanel(new GridLayout(1, 2));
    private JPanel chooserSidePanel;
    private JPanel displaySidePanel;
    
    private JPanel namePanel;
    private JLabel nameMessageLabel;
    private JTextField nameTextField;
    private JPanel classPanel;
    private JLabel classMessageLabel;
    private JRadioButton warrior;
    private JRadioButton knight;
    private JRadioButton bMage;
    private JRadioButton wMage;
    private JPanel genderPanel;
    private JLabel genderMessageLabel;
    private JRadioButton male;
    private JRadioButton female;
    
    private JPanel displayPanel;
    private JLabel charImage;
    private JPanel infoPanel;
    private JLabel charName;
    private JLabel charClass;
    private JLabel charLvl;
    private JLabel charJLvl;
    private JLabel charHp;
    private JLabel charMp;
    private JLabel charStr;
    private JLabel charDex;
    private JLabel charEnd;
    private JLabel charInt;
    private JLabel charLuck;
    
    public Selector() {
        
        JFrame charChooserWindow = new JFrame();
        charChooserwindow.setTitle(title);
        charChooserwindow.setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
        charChooserwindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        charChooserwindow.setLayout(new GridLayout(0,2));              
        
        buildPanels();
               
        charChooserwindow.add(chooserSidePanel);
        charChooserwindow.add(displaySidePanel); 
        //charChooserwindow.add(mainPanel);
        
        charChooserwindow.setVisible(true);
        
    }//End constructor
    
    private void buildPanels(){ 
                       
        //Stuff on the left with the buttons
                    
            chooserSidePanel = new JPanel(new GridLayout(3, 0));
        
            //Name panel stuff
            namePanel = new JPanel();
            nameMessageLabel = new JLabel(nameMessage);
            nameTextField = new JTextField("Sexy McLuffykins", 10);
            nameTextField.addActionListener(new nameListener());
            namePanel.add(nameMessageLabel);
            namePanel.add(nameTextField);
        
            //Class panel stuff
            classPanel = new JPanel();
            classMessageLabel = new JLabel(classMessage);
            ButtonGroup classGroup = new ButtonGroup();
            warrior = new JRadioButton("Warrior", true);
            knight = new JRadioButton("Knight");
            bMage = new JRadioButton("Black Mage");
            wMage = new JRadioButton("White Mage");
            classGroup.add(warrior);
            classGroup.add(knight);
            classGroup.add(bMage);
            bMage.setEnabled(false);
            classGroup.add(wMage);
            wMage.setEnabled(false);
            warrior.addActionListener(new radioButtonListener());
            knight.addActionListener(new radioButtonListener());
            bMage.addActionListener(new radioButtonListener());
            wMage.addActionListener(new radioButtonListener());
            classPanel.add(classMessageLabel);
            classPanel.add(warrior);
            classPanel.add(knight);
            classPanel.add(bMage);
            classPanel.add(wMage);
            
            //Gender panel stuff
            genderPanel = new JPanel();
            genderMessageLabel = new JLabel(genderMessage);
            ButtonGroup genderGroup = new ButtonGroup();
            male = new JRadioButton("Male", true);
            female = new JRadioButton("Female"); 
            female.setEnabled(false);
            genderGroup.add(male);
            genderGroup.add(female);
            male.addActionListener(new radioButtonListener());
            female.addActionListener(new radioButtonListener());
            genderPanel.add(genderMessageLabel);
            genderPanel.add(male);
            genderPanel.add(female);           
            
            //Add sub-sub panels to sub panel
            chooserSidePanel.add(namePanel);
            chooserSidePanel.add(classPanel);
            chooserSidePanel.add(genderPanel);
            
        //End left panel side creation
        
        //Stuff on the right that displays stuff
                    
            displaySidePanel = new JPanel(new GridLayout(2,0));
            
            //Character display panel stuff
            displayPanel = new JPanel(new BorderLayout());
            charImage = new JLabel(sprite);
            displayPanel.add(charImage, BorderLayout.CENTER);
        
            
            //Info panel 
            infoPanel = new JPanel();
            charName = new JLabel("Name: " + name);
            charClass = new JLabel("Class: " + Class);
            charLvl = new JLabel("Level: " + sLvl);
            charJLvl = new JLabel("Job Level: " + sJLvl);
            charHp = new JLabel("HP: " + sHp);
            charMp = new JLabel("MP: " + sMp);
            charStr = new JLabel("STR: " + sStr);
            charDex = new JLabel("DEX: " + sDex);
            charEnd = new JLabel("END: " + sEnd);
            charInt = new JLabel("INT: " + sInt);
            charLuck = new JLabel("LUCK: " + sLuck);
            infoPanel.add(charName);
            infoPanel.add(charClass);
            infoPanel.add(charLvl);
            infoPanel.add(charJLvl);
            infoPanel.add(charHp);
            infoPanel.add(charMp);
            infoPanel.add(charStr);
            infoPanel.add(charDex);
            infoPanel.add(charEnd);
            infoPanel.add(charInt);
            infoPanel.add(charLuck);
            
            //Add sub-sub panels to sub panel
            displaySidePanel.add(displayPanel);
            displaySidePanel.add(infoPanel);
            
        //End right panel side creation
                          
    }//End buildPanels method
    
    private class nameListener implements ActionListener {
                
        public void actionPerformed(ActionEvent e) {
            
            name = nameTextField.getText();
            
        }//End actionPerformed
        
    }//End nameListener
    
    private class radioButtonListener implements ActionListener {

        public void actionPerformed(ActionEvent e) {
            
            if(warrior.isSelected() && male.isSelected()) {
                
                sprite = new ImageIcon("C:\\Users\\Erica\\Documents\\projectn00b\\char_chooser\\sprites_and_tiles\\warrior_m_still.GIF");
                Class = "Warrior";
                lvl = 1;
                jLvl = 1;
                hp = 20;
                mp = 7;
                str = 6;
                dex = 4;
                end = 5;
                Int = 2;
                luck = 2;
                
                
                
            }//End if
            
            else if(knight.isSelected() && male.isSelected()){
                
                sprite = new ImageIcon("C:\\Users\\Erica\\Documents\\projectn00b\\char_chooser\\sprites_and_tiles\\knight_m_still.GIF");
                Class = "Knight";
                lvl = 1;
                jLvl = 1;
                hp = 21;
                mp = 8;
                str = 8;
                dex = 1;
                end = 6;
                Int = 3;
                luck = 5;
                
            }//End if
            
            sLvl = Integer.toString(lvl);
            sJLvl = Integer.toString(jLvl);
            sHp = Integer.toString(hp);
            sMp = Integer.toString(mp);
            sStr = Integer.toString(str);
            sDex = Integer.toString(dex);
            sEnd = Integer.toString(end);
            sInt = Integer.toString(Int);
            sLuck = Integer.toString(luck);
            
        }//End actionPerformed
        
    }//End classListener
    
}//End Selector Class



This post has been edited by NeoTifa: 05 June 2009 - 11:34 PM

Was This Post Helpful? 0
  • +
  • -

#14 Locke  Icon User is offline

  • Sarcasm Extraordinaire!
  • member icon

Reputation: 520
  • View blog
  • Posts: 5,596
  • Joined: 20-March 08

Re: Character chooser

Posted 06 June 2009 - 10:55 PM

View PostSixOfEleven, on 31 May, 2009 - 10:36 AM, said:

Cool beans! :^: :D


@SixOfEleven: Replying in a thread about a Java project with that...is amazing. Whether you get the joke or not. :lol:

@NeoTifa...if you want to collaborate on this project, I have a lot of experience with stuff like this. I've written a character creation dialog in 3 languages, remarkably similar to the one you're making, actually. :) (Java, VB.NET, C#.NET) -- granted, the GUIs were much easier in the .NET ones...as you can probably imagine.

I can certainly help with the backend code if you'd like, and leave the GUI solely to you. I know you said you didn't really want any help with this, but I would only do what you tell me to do. I can just work on cleaning stuff up, or helping you realize efficiency problems/upgrades, or whatever, I'm just eager to help.

If you'd like my assistance, let me know. :)

This post has been edited by Locke: 06 June 2009 - 10:57 PM

Was This Post Helpful? 0
  • +
  • -

#15 NeoTifa  Icon User is offline

  • Whorediot
  • member icon





Reputation: 2495
  • View blog
  • Posts: 15,453
  • Joined: 24-September 08

Re: Character chooser

Posted 07 June 2009 - 12:51 PM

View PostLocke, on 6 Jun, 2009 - 09:55 PM, said:

View PostSixOfEleven, on 31 May, 2009 - 10:36 AM, said:

Cool beans! :^: :D


@SixOfEleven: Replying in a thread about a Java project with that...is amazing. Whether you get the joke or not. :lol:

@NeoTifa...if you want to collaborate on this project, I have a lot of experience with stuff like this. I've written a character creation dialog in 3 languages, remarkably similar to the one you're making, actually. :) (Java, VB.NET, C#.NET) -- granted, the GUIs were much easier in the .NET ones...as you can probably imagine.

I can certainly help with the backend code if you'd like, and leave the GUI solely to you. I know you said you didn't really want any help with this, but I would only do what you tell me to do. I can just work on cleaning stuff up, or helping you realize efficiency problems/upgrades, or whatever, I'm just eager to help.

If you'd like my assistance, let me know. :)



@bold text LOL if a monkey can do it... :P Yea, you can be my Java goto guy. *nudge* lol get it? :P Am I on the right track, do you think?
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2