Refactoring.

This commit is contained in:
Josh Ashton
2022-11-17 19:12:49 -07:00
parent dd6a0c4ce4
commit b951b04e66
40 changed files with 1529 additions and 1550 deletions
@@ -10,7 +10,7 @@ public class CharacterStats {
}
// TODO: Need to implement constructor, validates all proposed ability scores and creates new objects containing corresponding values.
// TODO: Need to implement constructor, validates all proposed ability scores and creates new objects containing corresponding values.
public CharacterStats(int str, int dex, int con, int intel, int wis, int cha) {
this.stats = new Stats[]{
@@ -32,7 +32,7 @@ public class CharacterStats {
}
// TODO: Need to implement ability score validation.
// TODO: Need to implement ability score validation.
public boolean validateAbilityScore(int abilityScore) {
return false;
@@ -46,12 +46,10 @@ public class CharacterStats {
}
/**
*
* Allows for access to a particular stat.
*
* @param index
* @return a specific stat
*
*/
public Stats getStats(int index) {
@@ -70,7 +68,7 @@ public class CharacterStats {
String statsString = "";
for(int i = 0; i < stats.length; i++) {
for (int i = 0; i < stats.length; i++) {
statsString = statsString.concat(stats[i].getClass().getSimpleName() + ": " + stats[i].getScore() + " | ");
@@ -30,7 +30,7 @@ public class Charisma extends Stats {
}
// TODO: Need description.
// TODO: Need description.
public String getDescription() {
return "Confidence, eloquence, and leadership.";
@@ -30,7 +30,7 @@ public class Constitution extends Stats {
}
// TODO: Need description.
// TODO: Need description.
public String getDescription() {
return "Health, stamina, vital force.";
@@ -30,7 +30,7 @@ public class Dexterity extends Stats {
}
// TODO: Need description.
// TODO: Need description.
public String getDescription() {
return "";
@@ -1,6 +1,6 @@
package Character.AbilityScores;
public class Intelligence extends Stats{
public class Intelligence extends Stats {
private int abilityScore;
private int abilityScoreModifier;
@@ -30,7 +30,7 @@ public class Intelligence extends Stats{
}
// TODO: Need description.
// TODO: Need description.
public String getDescription() {
return "";
@@ -30,7 +30,7 @@ public class Wisdom extends Stats {
}
// TODO: Need description.
// TODO: Need description.
public String getDescription() {
return "";
+19 -20
View File
@@ -1,15 +1,13 @@
package Character;
import java.util.Arrays;
public class Background {
int backgroundIndex;
private String name;
private boolean[] proficientStatus;
private String[] skills;
private String feature;
private String skillProficiencies;
int backgroundIndex;
/**
* @param name
@@ -23,16 +21,16 @@ public class Background {
skillProficiencies = null;
}
public void setAcolyte(){
public void setAcolyte() {
name = "Acolyte";
proficientStatus[5] = true;
proficientStatus[14] = true;
skillProficiencies = skills[5] + ", " + skills[14];
feature = "Shelter of the Faithful"+ "\nAs an acolyte, you command the respect of those who share your faith, and you can perform the religious ceremonies of your deity. You and your adventuring companions can expect to receive free healing and care at a temple, shrine, or other established presence of your faith, though you must provide any material components needed for spells. Those who share your religion will support you (but only you) at a modest lifestyle."
feature = "Shelter of the Faithful" + "\nAs an acolyte, you command the respect of those who share your faith, and you can perform the religious ceremonies of your deity. You and your adventuring companions can expect to receive free healing and care at a temple, shrine, or other established presence of your faith, though you must provide any material components needed for spells. Those who share your religion will support you (but only you) at a modest lifestyle."
+ "\nYou might also have ties to a specific temple dedicated to your chosen deity or pantheon, and you have a residence there. This could be the temple where you used to serve, if you remain on good terms with it, or a temple where you have found a new home. While near your temple, you can call upon the priests for assistance, provided the assistance you ask for is not hazardous and you remain in good standing with your temple.";
}
public void setCharlatan(){
public void setCharlatan() {
name = "Charlatan";
proficientStatus[4] = true;
proficientStatus[15] = true;
@@ -41,7 +39,7 @@ public class Background {
}
public void setCriminal(){
public void setCriminal() {
name = "Criminal";
proficientStatus[4] = true;
proficientStatus[16] = true;
@@ -49,7 +47,7 @@ public class Background {
feature = "Feature: Criminal Contact" + "\nYou have a reliable and trustworthy contact who acts as your liaison to a network of other criminals. You know how to get messages to and from your contact, even over great distances; specifically, you know the local messengers, corrupt caravan masters, and seedy sailors who can deliver messages for you.";
}
public void setSpy(){
public void setSpy() {
name = "Spy";
proficientStatus[4] = true;
proficientStatus[16] = true;
@@ -57,7 +55,7 @@ public class Background {
feature = "Criminal Contact" + "\nYou have a reliable and trustworthy contact who acts as your liaison to a network of other criminals. You know how to get messages to and from your contact, even over great distances; specifically, you know the local messengers, corrupt caravan masters, and seedy sailors who can deliver messages for you.";
}
public void setEntertainer(){
public void setEntertainer() {
name = "Entertainer";
proficientStatus[0] = true;
proficientStatus[12] = true;
@@ -65,7 +63,7 @@ public class Background {
feature = "By Popular Demand" + "\nYou can always find a place to perform, usually in an inn or tavern but possibly with a circus, at a theater, or even in a noble's court. At such a place, you receive free lodging and food of a modest or comfortable standard (depending on the quality of the establishment), as long as you perform each night. In addition, your performance makes you something of a local figure. When strangers recognize you in a town where you have performed, they typically take a liking to you.";
}
public void setFolkHero(){
public void setFolkHero() {
name = "Folk Hero";
proficientStatus[1] = true;
proficientStatus[17] = true;
@@ -73,7 +71,7 @@ public class Background {
feature = "Rustic Hospitality" + "\nSince you come from the ranks of the common folk, you fit in among them with ease. You can find a place to hide, rest, or recuperate among other commoners, unless you have shown yourself to be a danger to them. They will shield you from the law or anyone else searching for you, though they will not risk their lives for you.";
}
public void setGladiator(){
public void setGladiator() {
name = "Gladiator";
proficientStatus[0] = true;
proficientStatus[12] = true;
@@ -81,27 +79,27 @@ public class Background {
feature = "By Popular Demand" + "\nYou can always find a place to perform in any place that features combat for entertainment — perhaps a gladiatorial arena or secret pit fighting club. At such a place, you receive free lodging and food of a modest or comfortable standard (depending on the quality of the establishment), as long as you perform each night. In addition, your performance makes you something of a local figure. When strangers recognize you in a town where you have performed, they typically take a liking to you.";
}
public void setGuildArtisan(){
public void setGuildArtisan() {
name = "Guild Artisan";
proficientStatus[6] = true;
proficientStatus[13] = true;
skillProficiencies = skills[6] + ", " + skills[13];
feature = "Guild Membership" + "\nAs an established and respected member of a guild, you can rely on certain benefits that membership provides. Your fellow guild members will provide you with lodging and food if necessary, and pay for your funeral if needed. In some cities and towns, a guildhall offers a central place to meet other members of your profession, which can be a good place to meet potential patrons, allies, or hirelings."
+"\nGuilds often wield tremendous political power. If you are accused of a crime, your guild will support you if a good case can be made for your innocence or the crime is justifiable. You can also gain access to powerful political figures through the guild, if you are a member in good standing. Such connections might require the donation of money or magic items to the guilds coffers."
+"\nYou must pay dues of 5 gp per month to the guild. If you miss payments, you must make up back dues to remain in the guilds good graces.";
+ "\nGuilds often wield tremendous political power. If you are accused of a crime, your guild will support you if a good case can be made for your innocence or the crime is justifiable. You can also gain access to powerful political figures through the guild, if you are a member in good standing. Such connections might require the donation of money or magic items to the guilds coffers."
+ "\nYou must pay dues of 5 gp per month to the guild. If you miss payments, you must make up back dues to remain in the guilds good graces.";
}
public void setGuildMerchant(){
public void setGuildMerchant() {
name = "Guild Merchant";
proficientStatus[6] = true;
proficientStatus[13] = true;
skillProficiencies = skills[6] + ", " + skills[13];
feature = "Guild Membership" + "\nAs an established and respected member of a guild, you can rely on certain benefits that membership provides. Your fellow guild members will provide you with lodging and food if necessary, and pay for your funeral if needed. In some cities and towns, a guildhall offers a central place to meet other members of your profession, which can be a good place to meet potential patrons, allies, or hirelings."
+"\nGuilds often wield tremendous political power. If you are accused of a crime, your guild will support you if a good case can be made for your innocence or the crime is justifiable. You can also gain access to powerful political figures through the guild, if you are a member in good standing. Such connections might require the donation of money or magic items to the guilds coffers."
+"\nYou must pay dues of 5 gp per month to the guild. If you miss payments, you must make up back dues to remain in the guilds good graces.";
+ "\nGuilds often wield tremendous political power. If you are accused of a crime, your guild will support you if a good case can be made for your innocence or the crime is justifiable. You can also gain access to powerful political figures through the guild, if you are a member in good standing. Such connections might require the donation of money or magic items to the guilds coffers."
+ "\nYou must pay dues of 5 gp per month to the guild. If you miss payments, you must make up back dues to remain in the guilds good graces.";
}
public void setGuildHermit(){
public void setGuildHermit() {
name = "Hermit";
proficientStatus[9] = true;
proficientStatus[14] = true;
@@ -110,7 +108,7 @@ public class Background {
+ "\nWork with your DM to determine the details of your discovery and its impact on the campaign.";
}
public void setKnight(){
public void setKnight() {
name = "Knight";
proficientStatus[5] = true;
proficientStatus[11] = true;
@@ -124,12 +122,14 @@ public class Background {
public String getName() {
return name;
}
/**
* @return the skillProficiencies
*/
public String getskillProficiences() {
return skillProficiencies;
}
/**
* @return the feature
*/
@@ -151,5 +151,4 @@ public class Background {
}
}
+9 -2
View File
@@ -1,8 +1,7 @@
package Character;
import Character.AbilityScores.CharacterStats;
import Character.Classes.ClassTemplate;
import Character.Races.*;
import Character.Races.Race;
import java.io.Serializable;
@@ -41,6 +40,7 @@ public class CharacterSheet implements Serializable {
this.race = race;
this.stats = stats;
}
/**
* Default constructor
*/
@@ -54,42 +54,49 @@ public class CharacterSheet implements Serializable {
this.hair = "null";
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @return the age
*/
public int getAge() {
return age;
}
/**
* @return the heightFeet
*/
public int getHeightFeet() {
return heightFeet;
}
/**
* @return the heightInch
*/
public int getHeightInch() {
return heightInch;
}
/**
* @return the weigth
*/
public int getWeight() {
return weight;
}
/**
* @return the eye
*/
public String getEye() {
return eye;
}
/**
* @return the hair
*/
@@ -1,6 +1,6 @@
package Character.Classes;
import Character.AbilityScores.*;
import Character.AbilityScores.Stats;
public interface ClassTemplate {
+2 -3
View File
@@ -1,6 +1,6 @@
package Character.Classes;
import Character.AbilityScores.*;
import Character.AbilityScores.Stats;
public class Cleric implements ClassTemplate {
@@ -8,13 +8,12 @@ public class Cleric implements ClassTemplate {
private int level;
// TODO: This should be the type of die.
// TODO: This should be the type of die.
private int hitDie;
public Cleric(Stats[] stats, int level) {
}
// TODO: Need to figure out how to contain class progression information. Potentially a double String array, each row equals a level, each column a different thing. Should class features be a separate class, ie. BarbFeatures, BardFeatures, etc?
@@ -1,6 +1,6 @@
package Character.Classes;
import Character.AbilityScores.*;
import Character.AbilityScores.Stats;
public class Fighter implements ClassTemplate {
@@ -8,13 +8,12 @@ public class Fighter implements ClassTemplate {
private int level;
// TODO: This should be the type of die.
// TODO: This should be the type of die.
private int hitDie;
public Fighter(Stats[] stats, int level) {
}
// TODO: Need to figure out how to contain class progression information. Potentially a double String array, each row equals a level, each column a different thing. Should class features be a separate class, ie. BarbFeatures, BardFeatures, etc?
+3 -3
View File
@@ -1,19 +1,19 @@
package Character.Classes;
import Character.AbilityScores.*;
import Character.AbilityScores.Stats;
public class Wizard implements ClassTemplate {
private int HP;
private int level;
// TODO: This should be the type of die.
// TODO: This should be the type of die.
private int hitDie;
public Wizard(Stats[] stats, int level) {
}
// TODO: Need to figure out how to contain class progression information. Potentially a double String array, each row equals a level, each column a different thing. Should class features be a separate class, ie. BarbFeatures, BardFeatures, etc?
@@ -1,17 +1,17 @@
package Character.Races;
public class Dragonborn implements Race{
private String[] traits;
public class Dragonborn implements Race {
private final int speed = 30;
private final int maxAge = 80;
private String[] traits;
private String[] skills;
private String[] languages;
private String[] proficiencies;
public Dragonborn() {
this.languages = new String[] {"Common", "Draconic"};
this.skills = new String[] {};
this.languages = new String[]{"Common", "Draconic"};
this.skills = new String[]{};
}
@Override
@@ -60,7 +60,7 @@ public class Dragonborn implements Race{
@Override
public int[] getASI() {
// TODO Auto-generated method stub
return new int[]{0,0,5};
return new int[]{0, 0, 5};
}
@Override
+5 -5
View File
@@ -1,17 +1,17 @@
package Character.Races;
public class Dwarf implements Race{
private String[] traits;
public class Dwarf implements Race {
private final int speed = 25;
private final int maxAge = 350;
private String[] traits;
private String[] skills;
private String[] languages;
private String[] proficiencies;
public Dwarf() {
this.languages = new String[] {"Common", "Dwarvish"};
this.skills = new String[] {};
this.languages = new String[]{"Common", "Dwarvish"};
this.skills = new String[]{};
}
@Override
@@ -60,7 +60,7 @@ public class Dwarf implements Race{
@Override
public int[] getASI() {
// TODO Auto-generated method stub
return new int[]{2,2};
return new int[]{2, 2};
}
@Override
+5 -5
View File
@@ -1,17 +1,17 @@
package Character.Races;
public class Elf implements Race{
private String[] traits;
public class Elf implements Race {
private final int speed = 30;
private final int maxAge = 750;
private String[] traits;
private String[] skills;
private String[] languages;
private String[] proficiencies;
public Elf() {
this.languages = new String[] {"Common", "Elvish"};
this.skills = new String[] {};
this.languages = new String[]{"Common", "Elvish"};
this.skills = new String[]{};
}
@Override
@@ -60,7 +60,7 @@ public class Elf implements Race{
@Override
public int[] getASI() {
// TODO Auto-generated method stub
return new int[]{1,1};
return new int[]{1, 1};
}
@Override
+5 -5
View File
@@ -1,17 +1,17 @@
package Character.Races;
public class Gnome implements Race{
private String[] traits;
public class Gnome implements Race {
private final int speed = 25;
private final int maxAge = 500;
private String[] traits;
private String[] skills;
private String[] languages;
private String[] proficiencies;
public Gnome() {
this.languages = new String[] {"Common", "Gnomish"};
this.skills = new String[] {};
this.languages = new String[]{"Common", "Gnomish"};
this.skills = new String[]{};
}
@Override
@@ -60,7 +60,7 @@ public class Gnome implements Race{
@Override
public int[] getASI() {
// TODO Auto-generated method stub
return new int[]{3,3};
return new int[]{3, 3};
}
@Override
+5 -5
View File
@@ -1,9 +1,9 @@
package Character.Races;
public class HalfElf implements Race{
private String[] traits;
public class HalfElf implements Race {
private final int speed = 30;
private final int maxAge = 180;
private String[] traits;
private String[] skills;
private String[] languages;
private String[] proficiencies;
@@ -12,8 +12,8 @@ public class HalfElf implements Race{
//TODO HalfElf get's to increase 1 ASI of their choice to increase.
public HalfElf(String chosenLanguage, int chosenASI) {
this.languages = new String[] {"Common", "Elvish", chosenLanguage };
this.skills = new String[] {};
this.languages = new String[]{"Common", "Elvish", chosenLanguage};
this.skills = new String[]{};
this.chosenASI = chosenASI;
}
@@ -64,7 +64,7 @@ public class HalfElf implements Race{
@Override
public int[] getASI() {
// TODO Auto-generated method stub
return new int[]{5,5, chosenASI};
return new int[]{5, 5, chosenASI};
}
@Override
+5 -5
View File
@@ -1,17 +1,17 @@
package Character.Races;
public class HalfOrc implements Race{
private String[] traits;
public class HalfOrc implements Race {
private final int speed = 30;
private final int maxAge = 75;
private String[] traits;
private String[] skills;
private String[] languages;
private String[] proficiencies;
public HalfOrc() {
this.languages = new String[] {"Common", "Orc"};
this.skills = new String[] {};
this.languages = new String[]{"Common", "Orc"};
this.skills = new String[]{};
}
@Override
@@ -60,7 +60,7 @@ public class HalfOrc implements Race{
@Override
public int[] getASI() {
// TODO Auto-generated method stub
return new int[]{0,0,2};
return new int[]{0, 0, 2};
}
@Override
+5 -5
View File
@@ -1,17 +1,17 @@
package Character.Races;
public class Halfling implements Race{
private String[] traits;
public class Halfling implements Race {
private final int speed = 30;
private final int maxAge = 750;
private String[] traits;
private String[] skills;
private String[] languages;
private String[] proficiencies;
public Halfling() {
this.languages = new String[] {"Common", "Elvish"};
this.skills = new String[] {};
this.languages = new String[]{"Common", "Elvish"};
this.skills = new String[]{};
}
@@ -61,7 +61,7 @@ public class Halfling implements Race{
@Override
public int[] getASI() {
// TODO Auto-generated method stub
return new int[]{1,1};
return new int[]{1, 1};
}
@Override
+3 -3
View File
@@ -2,17 +2,17 @@ package Character.Races;
public class Human implements Race {
private String[] traits;
private final int speed = 30;
private final int maxAge = 80;
private String[] traits;
private String[] skills;
private String[] languages;
private String[] proficiencies;
public Human(String chosenLanguage) {
this.languages = new String[] {"Common", chosenLanguage};
this.skills = new String[] {};
this.languages = new String[]{"Common", chosenLanguage};
this.skills = new String[]{};
}
-1
View File
@@ -44,5 +44,4 @@ public interface Race {
// }
}
+5 -5
View File
@@ -1,17 +1,17 @@
package Character.Races;
public class Tiefling implements Race{
private String[] traits;
public class Tiefling implements Race {
private final int speed = 30;
private final int maxAge = 85;
private String[] traits;
private String[] skills;
private String[] languages;
private String[] proficiencies;
public Tiefling() {
this.languages = new String[] {"Common", "Infernal"};
this.skills = new String[] {};
this.languages = new String[]{"Common", "Infernal"};
this.skills = new String[]{};
}
@Override
@@ -60,7 +60,7 @@ public class Tiefling implements Race{
@Override
public int[] getASI() {
// TODO Auto-generated method stub
return new int[]{3,5,5};
return new int[]{3, 5, 5};
}
@Override
+8 -18
View File
@@ -1,33 +1,27 @@
package Character;
import Character.AbilityScores.*;
import Character.AbilityScores.Stats;
/**
*
* Object stores information about a character's skills arrays. Firstly, the name of each skill, and secondly the value of each skill. When constructed, a private method is called
* which adds any proficiency bonus to each skill and then adds the ability score modifier to each skill.
*
*/
public class Skills {
// TODO: Need to verify skills are in correct order.
private String[] allSkillsText = {"Acrobatics", "Animal Handling", "Arcana", "Athletics", "Deception", "History", "Insight", "Intimidation", "Investigation", "Medicine", "Nature", "Perception", "Performance", "Persuasion", "Religion", "Sleight of Hand", "Stealth", "Survival"};
// TODO: Prof bonus comes from the class, changes upon certain level thresholds.
// TODO: Prof bonus comes from the class, changes upon certain level thresholds.
private final int profBonus = 5;
// TODO: Need to verify skills are in correct order.
private String[] allSkillsText = {"Acrobatics", "Animal Handling", "Arcana", "Athletics", "Deception", "History", "Insight", "Intimidation", "Investigation", "Medicine", "Nature", "Perception", "Performance", "Persuasion", "Religion", "Sleight of Hand", "Stealth", "Survival"};
private Stats[] stats;
private int[] skills;
/**
*
* Default constructor for the Skills class. Should be constructed AFTER the user has generated their stats and chosen the skills they are proficient in.
*
* @param skills
* @param stats
*
*/
public Skills(int[] skills, Stats[] stats) {
@@ -40,18 +34,16 @@ public class Skills {
}
/**
*
* Adds proficiency bonus to each element of the skills array, and then adds the corresponding AS modifier to each skill.
*
*/
private void setSkills() {
// TODO: Need to verify these are the correct ability scores for each skill.
int[] skillsAbilities = { 1, 4, 3, 0, 5, 3, 4, 5, 3, 4, 3, 4, 5, 5, 3, 1, 4 };
int[] skillsAbilities = {1, 4, 3, 0, 5, 3, 4, 5, 3, 4, 3, 4, 5, 5, 3, 1, 4};
for(int i = 0; i < allSkillsText.length; i++) {
for (int i = 0; i < allSkillsText.length; i++) {
if(skills[i] == 1) {
if (skills[i] == 1) {
skills[i] = profBonus;
@@ -64,11 +56,9 @@ public class Skills {
}
/**
*
* Returns the value of each skill's score.
*
* @return int[] skills
*
*/
public int[] getSkills() {
@@ -76,7 +66,7 @@ public class Skills {
}
// TODO: Need to implement overloaded method to return one specific skill.
// TODO: Need to implement overloaded method to return one specific skill.
public int getSkill(String skill) {
return 0;
+12 -21
View File
@@ -4,25 +4,21 @@
*/
package DieRoller;
import javax.swing.*;
import java.util.Arrays;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
public class DiceRoller
{
public class DiceRoller {
public static void main(String[] args)
{
public static void main(String[] args) {
JTextField diceNum = new JTextField();
JTextField diceMod = new JTextField();
String[] diceTypes = { "4", "6", "8", "10", "12", "20", "100"};
String[] diceTypes = {"4", "6", "8", "10", "12", "20", "100"};
JComboBox diceSize = new JComboBox(diceTypes);
Object[] fields = {"Number of dice", diceNum, "Type of dice", diceSize, "Modifier", diceMod};
JOptionPane.showConfirmDialog(null, fields, "Dice Roller",JOptionPane.OK_CANCEL_OPTION);
JOptionPane.showConfirmDialog(null, fields, "Dice Roller", JOptionPane.OK_CANCEL_OPTION);
int numberOfDice = Integer.parseInt(diceNum.getText());
@@ -36,37 +32,32 @@ public class DiceRoller
rollString += ": " + rollTotal;
else
rollString += " with " + modifierString(modifier) + " modifier: " + rollTotal;
JOptionPane.showMessageDialog(null,rollString,"Dice Rolls", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, rollString, "Dice Rolls", JOptionPane.INFORMATION_MESSAGE);
}
public static int[] rollDice(int numberOfDice, int sizeOfDice)
{
public static int[] rollDice(int numberOfDice, int sizeOfDice) {
int[] diceRolls = new int[numberOfDice];
for (int rolledDice = 0; rolledDice < diceRolls.length; rolledDice++)
{
for (int rolledDice = 0; rolledDice < diceRolls.length; rolledDice++) {
diceRolls[rolledDice] = (int) (Math.random() * sizeOfDice) + 1;
}
return diceRolls;
}
public static int rollTotal(int[] diceRolls, int modifier)
{
public static int rollTotal(int[] diceRolls, int modifier) {
int rollTotal = 0;
for (int index = 0; index < diceRolls.length; index++)
{
for (int index = 0; index < diceRolls.length; index++) {
rollTotal += diceRolls[index];
}
rollTotal += modifier;
return rollTotal;
}
public static String modifierString(int modifier)
{
public static String modifierString(int modifier) {
String modifierString = "";
if (modifier < 0)
modifierString += modifier;
if (modifier > 0)
modifierString+= "+" + modifier;
modifierString += "+" + modifier;
return modifierString;
}
}
+2 -2
View File
@@ -1,5 +1,5 @@
import GUI.*;
import FileManagement.*;
import FileManagement.FileManager;
import GUI.GUImanager;
public class DndCharacterBuilder {
@@ -5,7 +5,6 @@ public class ExportPDF {
public ExportPDF() {
}
}
@@ -1,10 +1,9 @@
package FileManagement;
import Character.CharacterSheet;
import java.awt.*;
import java.io.*;
import java.util.Arrays;
import Character.*;
public class FileManager {
@@ -24,7 +23,7 @@ public class FileManager {
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, new File("dndBuilder/src/Resources/Fonts/SanSalvi.ttf")));
} catch (IOException|FontFormatException e) {
} catch (IOException | FontFormatException e) {
//Handle exception
System.out.println("Error finding font.");
}
@@ -33,7 +32,7 @@ public class FileManager {
public boolean isReturninguser() {
if(savedCharacters == null) {
if (savedCharacters == null) {
return false;
@@ -70,7 +69,7 @@ public class FileManager {
}
public void saveCharacter (CharacterSheet completedCharacter) {
public void saveCharacter(CharacterSheet completedCharacter) {
try {
@@ -97,7 +96,7 @@ public class FileManager {
for (int i = 0; i < savedCharacters.length; i++) {
if(i != index) {
if (i != index) {
tmp[i] = savedCharacters[i];
+55 -29
View File
@@ -1,6 +1,9 @@
package GUI;
import GUI.Panels.*;
import GUI.Panels.BasicPanel;
import GUI.Panels.ChooseAbilityScoresPanel;
import GUI.Panels.DescriptionPanel;
import GUI.Panels.MainMenuPanel;
import Resources.CustomAssets.BasicNavPanel;
import Resources.CustomAssets.DefaultButton;
@@ -32,28 +35,23 @@ public class GUImanager extends JFrame {
private int[] selectedStats;
public GUImanager (boolean returningUser) {
public GUImanager(boolean returningUser) {
super("D&D Character Builder");
frameSetup();
setupPanelInfo();
this.panels = new JPanel[]{
new MainMenuPanel(),
new MainMenuPanel(createNewCharacterButton(), createRandomCharacterButton(), createLoadButton()),
new BasicPanel(createNavPanel(), raceOptions, raceDescriptions, "Step 1: Choose Your Race"), // To choose Race.
new BasicPanel(createNavPanel(), classOptions, classDescriptions, "Step 2: Choose Your Class"), // To choose Class.
new ChooseAbilityScoresPanel(createNavPanel(27), statOptions, statDescriptions, selectedStats, "Step 3: Choose Your Ability Scores"),
new ChooseAbilityScoresPanel(createNavPanel(1), statOptions, statDescriptions, selectedStats, "Step 3: Choose Your Ability Scores"),
new DescriptionPanel(createNavPanel(), characteristics, alignmentOptions, alignmentDescriptions, backgroundOptions, backgroundDescriptions, "Step 4: Describe your character")
};
this.currentPanel = 4;
/*
this.currentPanel = 0;
this.lastPanel = currentPanel - 1;
this.nextPanel = currentPanel + 1;
this.nextPanel = currentPanel + 1;*/
/* this.lastPanel = 0;
this.currentPanel = 1;
this.nextPanel = 2;*/
/* if (returningUser) {
if (returningUser) {
this.currentPanel = 0;
@@ -62,7 +60,6 @@ public class GUImanager extends JFrame {
this.currentPanel = 1;
}
*/
add(panels[currentPanel]);
@@ -72,13 +69,13 @@ public class GUImanager extends JFrame {
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLayout(new BorderLayout());
setPreferredSize(new Dimension(750,550));
setPreferredSize(new Dimension(750, 550));
setSize(getPreferredSize());
// setResizable(false);
setLocationRelativeTo(null);
try {
UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName() );
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
} catch (Exception e) {
System.out.println("Error with cross platform look/feel in frameSetup().");
}
@@ -113,7 +110,7 @@ public class GUImanager extends JFrame {
};
classOptions = new String[] {
classOptions = new String[]{
"Artificer",
"Barbarian",
@@ -149,7 +146,7 @@ public class GUImanager extends JFrame {
};
statOptions = new String[] {
statOptions = new String[]{
"Strength",
"Dexterity",
@@ -160,7 +157,7 @@ public class GUImanager extends JFrame {
};
statDescriptions = new String[] {
statDescriptions = new String[]{
"Strength is a thing.",
"Dexterity is a thing",
@@ -171,9 +168,9 @@ public class GUImanager extends JFrame {
};
selectedStats = new int[] {8, 8, 8, 8, 8, 8};
selectedStats = new int[]{8, 8, 8, 8, 8, 8};
characteristics = new String[] {
characteristics = new String[]{
"Name",
"Age",
@@ -184,7 +181,7 @@ public class GUImanager extends JFrame {
};
alignmentOptions = new String[] {
alignmentOptions = new String[]{
"Lawful Good",
"Neutral Good",
@@ -198,7 +195,7 @@ public class GUImanager extends JFrame {
};
alignmentDescriptions = new String[] {
alignmentDescriptions = new String[]{
"LG - need description",
"NG - need description",
@@ -212,7 +209,7 @@ public class GUImanager extends JFrame {
};
backgroundOptions = new String[] {
backgroundOptions = new String[]{
"Acolyte",
"Charlatan",
@@ -235,7 +232,7 @@ public class GUImanager extends JFrame {
};
backgroundDescriptions = new String[] {
backgroundDescriptions = new String[]{
"Acolyte - need description",
"Charlatan - need description",
@@ -312,6 +309,15 @@ public class GUImanager extends JFrame {
}
private DefaultButton createNewCharacterButton() {
DefaultButton button = createContinueButton();
button.setText("Create New Character");
return button;
}
// TODO: Need to implement.
private DefaultButton createRandomCharacterButton() {
@@ -323,7 +329,7 @@ public class GUImanager extends JFrame {
createRandomCharacter();
lastPanel = currentPanel;
currentPanel = 6;
currentPanel = 3;
nextPanel = currentPanel + 1;
clearAndReset();
@@ -335,7 +341,7 @@ public class GUImanager extends JFrame {
}
// TODO: Need to implement.
// TODO: Need to implement with exact indices and file manager logic.
private DefaultButton createSaveButton() {
DefaultButton button = new DefaultButton("Save");
@@ -356,10 +362,30 @@ public class GUImanager extends JFrame {
}
// TODO: Need to implement.
private DefaultButton createLoadButton() {
DefaultButton button = new DefaultButton("Load");
button.addActionListener(
e -> {
lastPanel = currentPanel;
currentPanel = 3;
nextPanel = currentPanel + 1;
clearAndReset();
}
);
return button;
}
// TODO: Need to implement random character creation.
private void createRandomCharacter() {
System.out.println("Request to create random character. Need to implement.");
}
+3 -3
View File
@@ -1,11 +1,11 @@
package GUI.Panels;
import GUI.AppTheme;
import Resources.CustomAssets.*;
import java.awt.*;
import Resources.CustomAssets.DefaultButton;
import Resources.CustomAssets.ImageInfoPanel;
import javax.swing.*;
import java.awt.*;
public class BasicPanel extends JPanel implements AppTheme {
@@ -1,9 +1,9 @@
package GUI.Panels;
import GUI.AppTheme;
import Resources.CustomAssets.InfoPanel;
import Resources.CustomAssets.BasicNavPanel;
import Resources.CustomAssets.DefaultButton;
import Resources.CustomAssets.InfoPanel;
import javax.swing.*;
import javax.swing.border.LineBorder;
@@ -116,17 +116,14 @@ public class ChooseAbilityScoresPanel extends JPanel implements AppTheme {
JLabel scoreLabel = new JLabel("" + selectedStats[statIndex]);
scoreLabel.setFont(paragraphFont);
scoreLabel.setHorizontalAlignment(SwingConstants.CENTER);
scoreLabel.setBounds(56, 50, 30, 30);
statLabels[statIndex] = scoreLabel;
DefaultButton increaseButton = new DefaultButton("+");
increaseButton.setBounds(90, 50, 50, 50);
increaseButton.addActionListener(e -> increase(statIndex));
DefaultButton decreaseButton = new DefaultButton("-");
decreaseButton.setBounds(21, 50, 50, 50);
decreaseButton.addActionListener(e -> decrease(statIndex));
subPanel.add(decreaseButton);
@@ -147,14 +144,14 @@ public class ChooseAbilityScoresPanel extends JPanel implements AppTheme {
if (isDecreasing) {
if(currentStatValue <= 8) {
if (currentStatValue <= 8) {
System.out.println("registered invalid decrease");
return -1;
}
if(currentStatValue < 14) {
if (currentStatValue < 14) {
cost = 1;
@@ -166,7 +163,7 @@ public class ChooseAbilityScoresPanel extends JPanel implements AppTheme {
} else {
if(currentStatValue < 13) {
if (currentStatValue < 13) {
cost = 1;
@@ -190,13 +187,13 @@ public class ChooseAbilityScoresPanel extends JPanel implements AppTheme {
int value = statCostCalculator(statIndex, false);
if(value == -1) {
if (value == -1) {
return;
}
if(basicNavPanel.getContinueRequirement() - value >= 0) {
if (basicNavPanel.getContinueRequirement() - value >= 0) {
selectedStats[statIndex]++;
statLabels[statIndex].setText("" + selectedStats[statIndex]);
@@ -211,13 +208,13 @@ public class ChooseAbilityScoresPanel extends JPanel implements AppTheme {
int value = statCostCalculator(statIndex, true);
if(value == -1) {
if (value == -1) {
return;
}
if(basicNavPanel.getContinueRequirement() + value <= 27) {
if (basicNavPanel.getContinueRequirement() + value <= 27) {
selectedStats[statIndex]--;
statLabels[statIndex].setText("" + selectedStats[statIndex]);
+45 -50
View File
@@ -3,7 +3,6 @@ package GUI.Panels;
import GUI.AppTheme;
import Resources.CustomAssets.BasicNavPanel;
import Resources.CustomAssets.DefaultButton;
import Resources.CustomAssets.InfoPanel;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
@@ -71,7 +70,7 @@ public class DescriptionPanel extends JPanel implements AppTheme {
alignmentButtons = new DefaultButton[alignmentOptions.length];
backgroundButtons = new DefaultButton[backgroundOptions.length];
characteristicsHolder = new String[] {
characteristicsHolder = new String[]{
"Name: ",
"Age: ",
@@ -87,7 +86,6 @@ public class DescriptionPanel extends JPanel implements AppTheme {
}
private void createPanel(String panelTitle, BasicNavPanel nav) {
add(createPanelTitle(panelTitle), BorderLayout.NORTH);
@@ -165,80 +163,59 @@ public class DescriptionPanel extends JPanel implements AppTheme {
JPanel panel = new JPanel(new GridLayout(1, 3));
panel.setOpaque(false);
panel.add(createAlignmentPanel());
panel.add(createBackgroundPanel());
panel.add(createSubPanel("Alignment"));
panel.add(createSubPanel("Background"));
panel.add(createTextBoxPanel());
return panel;
}
private JPanel createAlignmentPanel() {
private JPanel createSubPanel(String labelName) {
JPanel alignmentPanel = new JPanel(new BorderLayout(0, 0));
alignmentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
alignmentPanel.setOpaque(false);
JPanel panel = new JPanel(new BorderLayout(0, 0));
panel.setBorder(new EmptyBorder(5, 5, 5, 5));
panel.setOpaque(false);
JLabel backgroundLabel = new JLabel("Alignment");
backgroundLabel.setForeground(darkestBrown);
backgroundLabel.setFont(subHeaderFont);
backgroundLabel.setHorizontalAlignment(SwingConstants.CENTER);
JLabel label = new JLabel(labelName);
label.setForeground(darkestBrown);
label.setFont(subHeaderFont);
label.setHorizontalAlignment(SwingConstants.CENTER);
JPanel innerPanel = new JPanel(new GridLayout(9, 1));
JPanel innerPanel;
if(labelName.equals("Alignment")) {
innerPanel = new JPanel(new GridLayout(9, 1));
innerPanel.setOpaque(false);
for (int i = 0; i < alignmentOptions.length; i++) {
createButtons(alignmentOptions, alignmentButtons, labelName);
for (int i = 0; i < alignmentButtons.length; i++) {
alignmentButtons[i] = createButton(alignmentOptions[i], false, i);
innerPanel.add(alignmentButtons[i]);
if(i == 0) {
alignmentButtons[i].select();
}
}
} else {
alignmentPanel.add(backgroundLabel, BorderLayout.NORTH);
alignmentPanel.add(innerPanel);
return alignmentPanel;
}
private JPanel createBackgroundPanel() {
JPanel backgroundPanel = new JPanel(new BorderLayout(0, 0));
backgroundPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
backgroundPanel.setOpaque(false);
JLabel backgroundLabel = new JLabel("Background");
backgroundLabel.setForeground(darkestBrown);
backgroundLabel.setFont(subHeaderFont);
backgroundLabel.setHorizontalAlignment(SwingConstants.CENTER);
backgroundPanel.add(backgroundLabel, BorderLayout.NORTH);
JPanel innerPanel = new JPanel(new GridLayout(9, 2));
innerPanel = new JPanel(new GridLayout(9, 2));
innerPanel.setOpaque(false);
for (int i = 0; i < backgroundOptions.length; i++) {
createButtons(backgroundOptions, backgroundButtons, labelName);
for (int i = 0; i < backgroundButtons.length; i++) {
backgroundButtons[i] = createButton(backgroundOptions[i], false, i);
innerPanel.add(backgroundButtons[i]);
if(i == 0) {
backgroundButtons[i].select();
}
}
backgroundPanel.add(innerPanel);
panel.add(label);
panel.add(innerPanel);
return backgroundPanel;
return panel;
}
@@ -288,6 +265,24 @@ public class DescriptionPanel extends JPanel implements AppTheme {
}
private void createButtons(String[] options, DefaultButton[] buttons, String type) {
boolean tmp = type.equals("Alignment");
for (int i = 0; i < options.length; i++) {
buttons[i] = createButton(options[i], tmp, i);
if(i == 0) {
buttons[i].select();
}
}
}
private DefaultButton createButton(String name, boolean isAlignmentElseBackground, int index) {
DefaultButton button = new DefaultButton(name);
+52 -66
View File
@@ -1,83 +1,69 @@
package GUI.Panels;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import java.awt.Font;
import java.awt.Color;
import GUI.AppTheme;
import Resources.CustomAssets.DefaultButton;
import javax.swing.*;
import javax.swing.border.BevelBorder;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class MainMenuPanel extends JPanel {
public class MainMenuPanel extends JPanel implements AppTheme {
/**
* Create the panel.
*/
public MainMenuPanel() {
setBackground(new Color(222, 184, 135));
setBorder(new BevelBorder(BevelBorder.RAISED, new Color(160, 82, 45), new Color(165, 42, 42), new Color(0, 0, 0), null));
private DefaultButton newCharacter;
private DefaultButton randomCharacter;
private DefaultButton loadCharacter;
public MainMenuPanel(DefaultButton newCharacter, DefaultButton randomCharacter, DefaultButton loadCharacter) {
super();
panelSetup();
this.newCharacter = newCharacter;
this.randomCharacter = randomCharacter;
this.loadCharacter = loadCharacter;
add(createLabel(), BorderLayout.NORTH);
add(createControlPanel(), BorderLayout.CENTER);
}
private void panelSetup() {
setBackground(lightBrown);
setLayout(new BorderLayout(0, 0));
JLabel mainMenuLbl = mainMenuLbl();
add(mainMenuLbl, BorderLayout.NORTH);
JPanel controlPanel = createControlPanel();
add(controlPanel, BorderLayout.CENTER);
}
/**
* @return
*/
private JLabel createLabel() {
JLabel label = new JLabel("D&D Character Builder");
label.setFont(headerFont);
label.setForeground(darkestBrown);
label.setOpaque(false);
label.setHorizontalAlignment(SwingConstants.CENTER);
label.setBorder(new EmptyBorder(5, 5, 5, 5));
return label;
}
private JPanel createControlPanel() {
JPanel controlPanel = new JPanel();
controlPanel.setOpaque(false);
controlPanel.setLayout(null);
JPanel panel = new JPanel(new GridLayout(1, 2, 50, 0));
panel.setOpaque(false);
panel.setBorder(new EmptyBorder(25, 25, 25, 25));
JButton newCharBtn = new JButton("New \nCharacter");
newCharBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
newCharBtn.setOpaque(true);
newCharBtn.setBackground(new Color(160, 82, 45));
newCharBtn.setFont(new Font("Bodoni 72 Oldstyle", Font.PLAIN, 23));
newCharBtn.setBounds(118, 90, 200, 50);
controlPanel.add(newCharBtn);
JPanel subPanel = new JPanel(new GridLayout(2, 1, 0, 50));
subPanel.setOpaque(false);
JButton randCharacterBtn = new JButton("Random Character");
randCharacterBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
randCharacterBtn.setOpaque(true);
randCharacterBtn.setBackground(new Color(160, 82, 45));
randCharacterBtn.setFont(new Font("Bodoni 72 Oldstyle", Font.PLAIN, 23));
randCharacterBtn.setBounds(118, 156, 200, 50);
controlPanel.add(randCharacterBtn);
subPanel.add(newCharacter);
subPanel.add(randomCharacter);
JButton loadCharacter = new JButton("Load Character");
loadCharacter.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
loadCharacter.setOpaque(true);
loadCharacter.setBackground(new Color(160, 82, 45));
loadCharacter.setFont(new Font("Bodoni 72 Oldstyle", Font.PLAIN, 23));
loadCharacter.setBounds(376, 98, 233, 97);
controlPanel.add(loadCharacter);
return controlPanel;
panel.add(subPanel);
panel.add(loadCharacter);
return panel;
}
/**
* @return
*/
private JLabel mainMenuLbl() {
JLabel mainMenuLbl = new JLabel("Main Menu");
mainMenuLbl.setFont(new Font("Bodoni 72 Smallcaps", Font.PLAIN, 33));
mainMenuLbl.setHorizontalAlignment(SwingConstants.CENTER);
return mainMenuLbl;
}
}
+4 -12
View File
@@ -2,21 +2,12 @@ package GUI.Panels;
import GUI.AppTheme;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.GridLayout;
import javax.swing.*;
import javax.swing.border.BevelBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.border.BevelBorder;
import javax.swing.JTextField;
import javax.swing.JTextArea;
public class step4 extends JPanel implements AppTheme {
private JTextField nameTxtField;
private JTextField ageTextField;
@@ -34,6 +25,7 @@ public class step4 extends JPanel implements AppTheme {
}
private void createEntirePanel() {
setBackground(new Color(222, 184, 135));
setBorder(new BevelBorder(BevelBorder.RAISED, new Color(160, 82, 45), new Color(165, 42, 42), new Color(0, 0, 0), null));
@@ -58,7 +58,7 @@ public class BasicNavPanel extends JPanel implements AppTheme {
setBorder(new EmptyBorder(15, 150, 15, 150));
add(backButton);
if(continueRequirement == 0) {
if (continueRequirement == 0) {
add(continueButton);
@@ -52,13 +52,22 @@ public class DefaultButton extends JButton implements AppTheme {
addMouseListener(
new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {}
public void mouseClicked(MouseEvent e) {
}
@Override
public void mousePressed(MouseEvent e) {}
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {}
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) { applyFocusedButtonStyle(); }
public void mouseEntered(MouseEvent e) {
applyFocusedButtonStyle();
}
@Override
public void mouseExited(MouseEvent e) {
@@ -83,5 +92,4 @@ public class DefaultButton extends JButton implements AppTheme {
}
}
@@ -52,7 +52,7 @@ public class ImageInfoPanel extends InfoPanel implements AppTheme {
String category = "";
if(panelIndex == 1) {
if (panelIndex == 1) {
category = "Races";
@@ -68,7 +68,7 @@ public class ImageInfoPanel extends InfoPanel implements AppTheme {
File imagesDir;
if(OS.startsWith("Windows")) {
if (OS.startsWith("Windows")) {
imagesDir = new File("dndBuilder\\src\\Resources\\Img\\" + category + "\\" + categoryHolder[i].toLowerCase() + "\\");
@@ -125,7 +125,7 @@ public class ImageInfoPanel extends InfoPanel implements AppTheme {
}
if(Objects.isNull(finalImg)) {
if (Objects.isNull(finalImg)) {
picture = new JLabel("ERROR: Image not found.");
@@ -2,14 +2,9 @@ package Resources.CustomAssets;
import GUI.AppTheme;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Objects;
import java.util.Random;
public class InfoPanel extends JPanel implements AppTheme {
@@ -1,6 +1,6 @@
package Resources.CustomAssets;
import javax.swing.border.*;
import javax.swing.border.Border;
import java.awt.*;
public class RoundedBorder implements Border {
@@ -15,7 +15,7 @@ public class RoundedBorder implements Border {
public Insets getBorderInsets(Component c) {
return new Insets(this.radius+1, this.radius+1, this.radius+2, this.radius);
return new Insets(this.radius + 1, this.radius + 1, this.radius + 2, this.radius);
}
@@ -27,7 +27,7 @@ public class RoundedBorder implements Border {
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
g.drawRoundRect(x, y, width-1, height-1, radius, radius);
g.drawRoundRect(x, y, width - 1, height - 1, radius, radius);
}
}