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) { public CharacterStats(int str, int dex, int con, int intel, int wis, int cha) {
this.stats = new Stats[]{ 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) { public boolean validateAbilityScore(int abilityScore) {
return false; return false;
@@ -46,12 +46,10 @@ public class CharacterStats {
} }
/** /**
*
* Allows for access to a particular stat. * Allows for access to a particular stat.
* *
* @param index * @param index
* @return a specific stat * @return a specific stat
*
*/ */
public Stats getStats(int index) { public Stats getStats(int index) {
@@ -70,7 +68,7 @@ public class CharacterStats {
String statsString = ""; 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() + " | "); 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() { public String getDescription() {
return "Confidence, eloquence, and leadership."; return "Confidence, eloquence, and leadership.";
@@ -30,7 +30,7 @@ public class Constitution extends Stats {
} }
// TODO: Need description. // TODO: Need description.
public String getDescription() { public String getDescription() {
return "Health, stamina, vital force."; return "Health, stamina, vital force.";
@@ -30,7 +30,7 @@ public class Dexterity extends Stats {
} }
// TODO: Need description. // TODO: Need description.
public String getDescription() { public String getDescription() {
return ""; return "";
@@ -1,6 +1,6 @@
package Character.AbilityScores; package Character.AbilityScores;
public class Intelligence extends Stats{ public class Intelligence extends Stats {
private int abilityScore; private int abilityScore;
private int abilityScoreModifier; private int abilityScoreModifier;
@@ -30,7 +30,7 @@ public class Intelligence extends Stats{
} }
// TODO: Need description. // TODO: Need description.
public String getDescription() { public String getDescription() {
return ""; return "";
@@ -30,7 +30,7 @@ public class Wisdom extends Stats {
} }
// TODO: Need description. // TODO: Need description.
public String getDescription() { public String getDescription() {
return ""; return "";
+19 -20
View File
@@ -1,15 +1,13 @@
package Character; package Character;
import java.util.Arrays;
public class Background { public class Background {
int backgroundIndex;
private String name; private String name;
private boolean[] proficientStatus; private boolean[] proficientStatus;
private String[] skills; private String[] skills;
private String feature; private String feature;
private String skillProficiencies; private String skillProficiencies;
int backgroundIndex;
/** /**
* @param name * @param name
@@ -23,16 +21,16 @@ public class Background {
skillProficiencies = null; skillProficiencies = null;
} }
public void setAcolyte(){ public void setAcolyte() {
name = "Acolyte"; name = "Acolyte";
proficientStatus[5] = true; proficientStatus[5] = true;
proficientStatus[14] = true; proficientStatus[14] = true;
skillProficiencies = skills[5] + ", " + skills[14]; 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."; + "\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"; name = "Charlatan";
proficientStatus[4] = true; proficientStatus[4] = true;
proficientStatus[15] = true; proficientStatus[15] = true;
@@ -41,7 +39,7 @@ public class Background {
} }
public void setCriminal(){ public void setCriminal() {
name = "Criminal"; name = "Criminal";
proficientStatus[4] = true; proficientStatus[4] = true;
proficientStatus[16] = 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."; 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"; name = "Spy";
proficientStatus[4] = true; proficientStatus[4] = true;
proficientStatus[16] = 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."; 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"; name = "Entertainer";
proficientStatus[0] = true; proficientStatus[0] = true;
proficientStatus[12] = 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."; 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"; name = "Folk Hero";
proficientStatus[1] = true; proficientStatus[1] = true;
proficientStatus[17] = 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."; 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"; name = "Gladiator";
proficientStatus[0] = true; proficientStatus[0] = true;
proficientStatus[12] = 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."; 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"; name = "Guild Artisan";
proficientStatus[6] = true; proficientStatus[6] = true;
proficientStatus[13] = true; proficientStatus[13] = true;
skillProficiencies = skills[6] + ", " + skills[13]; 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." 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." + "\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."; + "\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"; name = "Guild Merchant";
proficientStatus[6] = true; proficientStatus[6] = true;
proficientStatus[13] = true; proficientStatus[13] = true;
skillProficiencies = skills[6] + ", " + skills[13]; 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." 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." + "\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."; + "\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"; name = "Hermit";
proficientStatus[9] = true; proficientStatus[9] = true;
proficientStatus[14] = 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."; + "\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"; name = "Knight";
proficientStatus[5] = true; proficientStatus[5] = true;
proficientStatus[11] = true; proficientStatus[11] = true;
@@ -124,12 +122,14 @@ public class Background {
public String getName() { public String getName() {
return name; return name;
} }
/** /**
* @return the skillProficiencies * @return the skillProficiencies
*/ */
public String getskillProficiences() { public String getskillProficiences() {
return skillProficiencies; return skillProficiencies;
} }
/** /**
* @return the feature * @return the feature
*/ */
@@ -151,5 +151,4 @@ public class Background {
} }
} }
+9 -2
View File
@@ -1,8 +1,7 @@
package Character; package Character;
import Character.AbilityScores.CharacterStats; import Character.AbilityScores.CharacterStats;
import Character.Classes.ClassTemplate; import Character.Races.Race;
import Character.Races.*;
import java.io.Serializable; import java.io.Serializable;
@@ -41,6 +40,7 @@ public class CharacterSheet implements Serializable {
this.race = race; this.race = race;
this.stats = stats; this.stats = stats;
} }
/** /**
* Default constructor * Default constructor
*/ */
@@ -54,42 +54,49 @@ public class CharacterSheet implements Serializable {
this.hair = "null"; this.hair = "null";
} }
/** /**
* @return the name * @return the name
*/ */
public String getName() { public String getName() {
return name; return name;
} }
/** /**
* @return the age * @return the age
*/ */
public int getAge() { public int getAge() {
return age; return age;
} }
/** /**
* @return the heightFeet * @return the heightFeet
*/ */
public int getHeightFeet() { public int getHeightFeet() {
return heightFeet; return heightFeet;
} }
/** /**
* @return the heightInch * @return the heightInch
*/ */
public int getHeightInch() { public int getHeightInch() {
return heightInch; return heightInch;
} }
/** /**
* @return the weigth * @return the weigth
*/ */
public int getWeight() { public int getWeight() {
return weight; return weight;
} }
/** /**
* @return the eye * @return the eye
*/ */
public String getEye() { public String getEye() {
return eye; return eye;
} }
/** /**
* @return the hair * @return the hair
*/ */
@@ -1,6 +1,6 @@
package Character.Classes; package Character.Classes;
import Character.AbilityScores.*; import Character.AbilityScores.Stats;
public interface ClassTemplate { public interface ClassTemplate {
+2 -3
View File
@@ -1,6 +1,6 @@
package Character.Classes; package Character.Classes;
import Character.AbilityScores.*; import Character.AbilityScores.Stats;
public class Cleric implements ClassTemplate { public class Cleric implements ClassTemplate {
@@ -8,13 +8,12 @@ public class Cleric implements ClassTemplate {
private int level; private int level;
// TODO: This should be the type of die. // TODO: This should be the type of die.
private int hitDie; private int hitDie;
public Cleric(Stats[] stats, int level) { 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? // 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; package Character.Classes;
import Character.AbilityScores.*; import Character.AbilityScores.Stats;
public class Fighter implements ClassTemplate { public class Fighter implements ClassTemplate {
@@ -8,13 +8,12 @@ public class Fighter implements ClassTemplate {
private int level; private int level;
// TODO: This should be the type of die. // TODO: This should be the type of die.
private int hitDie; private int hitDie;
public Fighter(Stats[] stats, int level) { 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? // 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; package Character.Classes;
import Character.AbilityScores.*; import Character.AbilityScores.Stats;
public class Wizard implements ClassTemplate { public class Wizard implements ClassTemplate {
private int HP; private int HP;
private int level; private int level;
// TODO: This should be the type of die. // TODO: This should be the type of die.
private int hitDie; private int hitDie;
public Wizard(Stats[] stats, int level) { 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? // 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; package Character.Races;
public class Dragonborn implements Race{ public class Dragonborn implements Race {
private String[] traits;
private final int speed = 30; private final int speed = 30;
private final int maxAge = 80; private final int maxAge = 80;
private String[] traits;
private String[] skills; private String[] skills;
private String[] languages; private String[] languages;
private String[] proficiencies; private String[] proficiencies;
public Dragonborn() { public Dragonborn() {
this.languages = new String[] {"Common", "Draconic"}; this.languages = new String[]{"Common", "Draconic"};
this.skills = new String[] {}; this.skills = new String[]{};
} }
@Override @Override
@@ -60,7 +60,7 @@ public class Dragonborn implements Race{
@Override @Override
public int[] getASI() { public int[] getASI() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return new int[]{0,0,5}; return new int[]{0, 0, 5};
} }
@Override @Override
+5 -5
View File
@@ -1,17 +1,17 @@
package Character.Races; package Character.Races;
public class Dwarf implements Race{ public class Dwarf implements Race {
private String[] traits;
private final int speed = 25; private final int speed = 25;
private final int maxAge = 350; private final int maxAge = 350;
private String[] traits;
private String[] skills; private String[] skills;
private String[] languages; private String[] languages;
private String[] proficiencies; private String[] proficiencies;
public Dwarf() { public Dwarf() {
this.languages = new String[] {"Common", "Dwarvish"}; this.languages = new String[]{"Common", "Dwarvish"};
this.skills = new String[] {}; this.skills = new String[]{};
} }
@Override @Override
@@ -60,7 +60,7 @@ public class Dwarf implements Race{
@Override @Override
public int[] getASI() { public int[] getASI() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return new int[]{2,2}; return new int[]{2, 2};
} }
@Override @Override
+5 -5
View File
@@ -1,17 +1,17 @@
package Character.Races; package Character.Races;
public class Elf implements Race{ public class Elf implements Race {
private String[] traits;
private final int speed = 30; private final int speed = 30;
private final int maxAge = 750; private final int maxAge = 750;
private String[] traits;
private String[] skills; private String[] skills;
private String[] languages; private String[] languages;
private String[] proficiencies; private String[] proficiencies;
public Elf() { public Elf() {
this.languages = new String[] {"Common", "Elvish"}; this.languages = new String[]{"Common", "Elvish"};
this.skills = new String[] {}; this.skills = new String[]{};
} }
@Override @Override
@@ -60,7 +60,7 @@ public class Elf implements Race{
@Override @Override
public int[] getASI() { public int[] getASI() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return new int[]{1,1}; return new int[]{1, 1};
} }
@Override @Override
+5 -5
View File
@@ -1,17 +1,17 @@
package Character.Races; package Character.Races;
public class Gnome implements Race{ public class Gnome implements Race {
private String[] traits;
private final int speed = 25; private final int speed = 25;
private final int maxAge = 500; private final int maxAge = 500;
private String[] traits;
private String[] skills; private String[] skills;
private String[] languages; private String[] languages;
private String[] proficiencies; private String[] proficiencies;
public Gnome() { public Gnome() {
this.languages = new String[] {"Common", "Gnomish"}; this.languages = new String[]{"Common", "Gnomish"};
this.skills = new String[] {}; this.skills = new String[]{};
} }
@Override @Override
@@ -60,7 +60,7 @@ public class Gnome implements Race{
@Override @Override
public int[] getASI() { public int[] getASI() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return new int[]{3,3}; return new int[]{3, 3};
} }
@Override @Override
+5 -5
View File
@@ -1,9 +1,9 @@
package Character.Races; package Character.Races;
public class HalfElf implements Race{ public class HalfElf implements Race {
private String[] traits;
private final int speed = 30; private final int speed = 30;
private final int maxAge = 180; private final int maxAge = 180;
private String[] traits;
private String[] skills; private String[] skills;
private String[] languages; private String[] languages;
private String[] proficiencies; 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. //TODO HalfElf get's to increase 1 ASI of their choice to increase.
public HalfElf(String chosenLanguage, int chosenASI) { public HalfElf(String chosenLanguage, int chosenASI) {
this.languages = new String[] {"Common", "Elvish", chosenLanguage }; this.languages = new String[]{"Common", "Elvish", chosenLanguage};
this.skills = new String[] {}; this.skills = new String[]{};
this.chosenASI = chosenASI; this.chosenASI = chosenASI;
} }
@@ -64,7 +64,7 @@ public class HalfElf implements Race{
@Override @Override
public int[] getASI() { public int[] getASI() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return new int[]{5,5, chosenASI}; return new int[]{5, 5, chosenASI};
} }
@Override @Override
+5 -5
View File
@@ -1,17 +1,17 @@
package Character.Races; package Character.Races;
public class HalfOrc implements Race{ public class HalfOrc implements Race {
private String[] traits;
private final int speed = 30; private final int speed = 30;
private final int maxAge = 75; private final int maxAge = 75;
private String[] traits;
private String[] skills; private String[] skills;
private String[] languages; private String[] languages;
private String[] proficiencies; private String[] proficiencies;
public HalfOrc() { public HalfOrc() {
this.languages = new String[] {"Common", "Orc"}; this.languages = new String[]{"Common", "Orc"};
this.skills = new String[] {}; this.skills = new String[]{};
} }
@Override @Override
@@ -60,7 +60,7 @@ public class HalfOrc implements Race{
@Override @Override
public int[] getASI() { public int[] getASI() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return new int[]{0,0,2}; return new int[]{0, 0, 2};
} }
@Override @Override
+5 -5
View File
@@ -1,17 +1,17 @@
package Character.Races; package Character.Races;
public class Halfling implements Race{ public class Halfling implements Race {
private String[] traits;
private final int speed = 30; private final int speed = 30;
private final int maxAge = 750; private final int maxAge = 750;
private String[] traits;
private String[] skills; private String[] skills;
private String[] languages; private String[] languages;
private String[] proficiencies; private String[] proficiencies;
public Halfling() { public Halfling() {
this.languages = new String[] {"Common", "Elvish"}; this.languages = new String[]{"Common", "Elvish"};
this.skills = new String[] {}; this.skills = new String[]{};
} }
@@ -61,7 +61,7 @@ public class Halfling implements Race{
@Override @Override
public int[] getASI() { public int[] getASI() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return new int[]{1,1}; return new int[]{1, 1};
} }
@Override @Override
+3 -3
View File
@@ -2,17 +2,17 @@ package Character.Races;
public class Human implements Race { public class Human implements Race {
private String[] traits;
private final int speed = 30; private final int speed = 30;
private final int maxAge = 80; private final int maxAge = 80;
private String[] traits;
private String[] skills; private String[] skills;
private String[] languages; private String[] languages;
private String[] proficiencies; private String[] proficiencies;
public Human(String chosenLanguage) { public Human(String chosenLanguage) {
this.languages = new String[] {"Common", chosenLanguage}; this.languages = new String[]{"Common", chosenLanguage};
this.skills = new String[] {}; 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; package Character.Races;
public class Tiefling implements Race{ public class Tiefling implements Race {
private String[] traits;
private final int speed = 30; private final int speed = 30;
private final int maxAge = 85; private final int maxAge = 85;
private String[] traits;
private String[] skills; private String[] skills;
private String[] languages; private String[] languages;
private String[] proficiencies; private String[] proficiencies;
public Tiefling() { public Tiefling() {
this.languages = new String[] {"Common", "Infernal"}; this.languages = new String[]{"Common", "Infernal"};
this.skills = new String[] {}; this.skills = new String[]{};
} }
@Override @Override
@@ -60,7 +60,7 @@ public class Tiefling implements Race{
@Override @Override
public int[] getASI() { public int[] getASI() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return new int[]{3,5,5}; return new int[]{3, 5, 5};
} }
@Override @Override
+8 -18
View File
@@ -1,33 +1,27 @@
package Character; 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 * 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. * which adds any proficiency bonus to each skill and then adds the ability score modifier to each skill.
*
*/ */
public class Skills { public class Skills {
// TODO: Need to verify skills are in correct order. // TODO: Prof bonus comes from the class, changes upon certain level thresholds.
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.
private final int profBonus = 5; 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 Stats[] stats;
private int[] skills; 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. * 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 skills
* @param stats * @param stats
*
*/ */
public Skills(int[] skills, Stats[] 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. * Adds proficiency bonus to each element of the skills array, and then adds the corresponding AS modifier to each skill.
*
*/ */
private void setSkills() { private void setSkills() {
// TODO: Need to verify these are the correct ability scores for each skill. // 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; skills[i] = profBonus;
@@ -64,11 +56,9 @@ public class Skills {
} }
/** /**
*
* Returns the value of each skill's score. * Returns the value of each skill's score.
* *
* @return int[] skills * @return int[] skills
*
*/ */
public int[] getSkills() { 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) { public int getSkill(String skill) {
return 0; return 0;
+12 -21
View File
@@ -4,25 +4,21 @@
*/ */
package DieRoller; package DieRoller;
import javax.swing.*;
import java.util.Arrays; 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 diceNum = new JTextField();
JTextField diceMod = 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); JComboBox diceSize = new JComboBox(diceTypes);
Object[] fields = {"Number of dice", diceNum, "Type of dice", diceSize, "Modifier", diceMod}; 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()); int numberOfDice = Integer.parseInt(diceNum.getText());
@@ -36,37 +32,32 @@ public class DiceRoller
rollString += ": " + rollTotal; rollString += ": " + rollTotal;
else else
rollString += " with " + modifierString(modifier) + " modifier: " + rollTotal; 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]; 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; diceRolls[rolledDice] = (int) (Math.random() * sizeOfDice) + 1;
} }
return diceRolls; return diceRolls;
} }
public static int rollTotal(int[] diceRolls, int modifier) public static int rollTotal(int[] diceRolls, int modifier) {
{
int rollTotal = 0; int rollTotal = 0;
for (int index = 0; index < diceRolls.length; index++) for (int index = 0; index < diceRolls.length; index++) {
{
rollTotal += diceRolls[index]; rollTotal += diceRolls[index];
} }
rollTotal += modifier; rollTotal += modifier;
return rollTotal; return rollTotal;
} }
public static String modifierString(int modifier) public static String modifierString(int modifier) {
{
String modifierString = ""; String modifierString = "";
if (modifier < 0) if (modifier < 0)
modifierString += modifier; modifierString += modifier;
if (modifier > 0) if (modifier > 0)
modifierString+= "+" + modifier; modifierString += "+" + modifier;
return modifierString; return modifierString;
} }
} }
+2 -2
View File
@@ -1,5 +1,5 @@
import GUI.*; import FileManagement.FileManager;
import FileManagement.*; import GUI.GUImanager;
public class DndCharacterBuilder { public class DndCharacterBuilder {
@@ -5,7 +5,6 @@ public class ExportPDF {
public ExportPDF() { public ExportPDF() {
} }
} }
@@ -1,10 +1,9 @@
package FileManagement; package FileManagement;
import Character.CharacterSheet;
import java.awt.*; import java.awt.*;
import java.io.*; import java.io.*;
import java.util.Arrays;
import Character.*;
public class FileManager { public class FileManager {
@@ -24,7 +23,7 @@ public class FileManager {
GraphicsEnvironment ge = GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsEnvironment.getLocalGraphicsEnvironment();
ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, new File("dndBuilder/src/Resources/Fonts/SanSalvi.ttf"))); 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 //Handle exception
System.out.println("Error finding font."); System.out.println("Error finding font.");
} }
@@ -33,7 +32,7 @@ public class FileManager {
public boolean isReturninguser() { public boolean isReturninguser() {
if(savedCharacters == null) { if (savedCharacters == null) {
return false; return false;
@@ -70,7 +69,7 @@ public class FileManager {
} }
public void saveCharacter (CharacterSheet completedCharacter) { public void saveCharacter(CharacterSheet completedCharacter) {
try { try {
@@ -97,7 +96,7 @@ public class FileManager {
for (int i = 0; i < savedCharacters.length; i++) { for (int i = 0; i < savedCharacters.length; i++) {
if(i != index) { if (i != index) {
tmp[i] = savedCharacters[i]; tmp[i] = savedCharacters[i];
+55 -29
View File
@@ -1,6 +1,9 @@
package GUI; 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.BasicNavPanel;
import Resources.CustomAssets.DefaultButton; import Resources.CustomAssets.DefaultButton;
@@ -32,28 +35,23 @@ public class GUImanager extends JFrame {
private int[] selectedStats; private int[] selectedStats;
public GUImanager(boolean returningUser) {
public GUImanager (boolean returningUser) {
super("D&D Character Builder"); super("D&D Character Builder");
frameSetup(); frameSetup();
setupPanelInfo(); setupPanelInfo();
this.panels = new JPanel[]{ 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(), raceOptions, raceDescriptions, "Step 1: Choose Your Race"), // To choose Race.
new BasicPanel(createNavPanel(), classOptions, classDescriptions, "Step 2: Choose Your Class"), // To choose Class. 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") new DescriptionPanel(createNavPanel(), characteristics, alignmentOptions, alignmentDescriptions, backgroundOptions, backgroundDescriptions, "Step 4: Describe your character")
}; };
/*
this.currentPanel = 4; this.currentPanel = 0;
this.lastPanel = currentPanel - 1; this.lastPanel = currentPanel - 1;
this.nextPanel = currentPanel + 1; this.nextPanel = currentPanel + 1;*/
/* this.lastPanel = 0; if (returningUser) {
this.currentPanel = 1;
this.nextPanel = 2;*/
/* if (returningUser) {
this.currentPanel = 0; this.currentPanel = 0;
@@ -62,7 +60,6 @@ public class GUImanager extends JFrame {
this.currentPanel = 1; this.currentPanel = 1;
} }
*/
add(panels[currentPanel]); add(panels[currentPanel]);
@@ -72,13 +69,13 @@ public class GUImanager extends JFrame {
setDefaultCloseOperation(EXIT_ON_CLOSE); setDefaultCloseOperation(EXIT_ON_CLOSE);
setLayout(new BorderLayout()); setLayout(new BorderLayout());
setPreferredSize(new Dimension(750,550)); setPreferredSize(new Dimension(750, 550));
setSize(getPreferredSize()); setSize(getPreferredSize());
// setResizable(false); // setResizable(false);
setLocationRelativeTo(null); setLocationRelativeTo(null);
try { try {
UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName() ); UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
} catch (Exception e) { } catch (Exception e) {
System.out.println("Error with cross platform look/feel in frameSetup()."); 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", "Artificer",
"Barbarian", "Barbarian",
@@ -149,7 +146,7 @@ public class GUImanager extends JFrame {
}; };
statOptions = new String[] { statOptions = new String[]{
"Strength", "Strength",
"Dexterity", "Dexterity",
@@ -160,7 +157,7 @@ public class GUImanager extends JFrame {
}; };
statDescriptions = new String[] { statDescriptions = new String[]{
"Strength is a thing.", "Strength is a thing.",
"Dexterity 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", "Name",
"Age", "Age",
@@ -184,7 +181,7 @@ public class GUImanager extends JFrame {
}; };
alignmentOptions = new String[] { alignmentOptions = new String[]{
"Lawful Good", "Lawful Good",
"Neutral Good", "Neutral Good",
@@ -198,7 +195,7 @@ public class GUImanager extends JFrame {
}; };
alignmentDescriptions = new String[] { alignmentDescriptions = new String[]{
"LG - need description", "LG - need description",
"NG - need description", "NG - need description",
@@ -212,7 +209,7 @@ public class GUImanager extends JFrame {
}; };
backgroundOptions = new String[] { backgroundOptions = new String[]{
"Acolyte", "Acolyte",
"Charlatan", "Charlatan",
@@ -235,7 +232,7 @@ public class GUImanager extends JFrame {
}; };
backgroundDescriptions = new String[] { backgroundDescriptions = new String[]{
"Acolyte - need description", "Acolyte - need description",
"Charlatan - 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. // TODO: Need to implement.
private DefaultButton createRandomCharacterButton() { private DefaultButton createRandomCharacterButton() {
@@ -323,7 +329,7 @@ public class GUImanager extends JFrame {
createRandomCharacter(); createRandomCharacter();
lastPanel = currentPanel; lastPanel = currentPanel;
currentPanel = 6; currentPanel = 3;
nextPanel = currentPanel + 1; nextPanel = currentPanel + 1;
clearAndReset(); 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() { private DefaultButton createSaveButton() {
DefaultButton button = new DefaultButton("Save"); 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() { 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; package GUI.Panels;
import GUI.AppTheme; import GUI.AppTheme;
import Resources.CustomAssets.*; import Resources.CustomAssets.DefaultButton;
import Resources.CustomAssets.ImageInfoPanel;
import java.awt.*;
import javax.swing.*; import javax.swing.*;
import java.awt.*;
public class BasicPanel extends JPanel implements AppTheme { public class BasicPanel extends JPanel implements AppTheme {
@@ -1,9 +1,9 @@
package GUI.Panels; package GUI.Panels;
import GUI.AppTheme; import GUI.AppTheme;
import Resources.CustomAssets.InfoPanel;
import Resources.CustomAssets.BasicNavPanel; import Resources.CustomAssets.BasicNavPanel;
import Resources.CustomAssets.DefaultButton; import Resources.CustomAssets.DefaultButton;
import Resources.CustomAssets.InfoPanel;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.LineBorder; import javax.swing.border.LineBorder;
@@ -116,17 +116,14 @@ public class ChooseAbilityScoresPanel extends JPanel implements AppTheme {
JLabel scoreLabel = new JLabel("" + selectedStats[statIndex]); JLabel scoreLabel = new JLabel("" + selectedStats[statIndex]);
scoreLabel.setFont(paragraphFont); scoreLabel.setFont(paragraphFont);
scoreLabel.setHorizontalAlignment(SwingConstants.CENTER); scoreLabel.setHorizontalAlignment(SwingConstants.CENTER);
scoreLabel.setBounds(56, 50, 30, 30);
statLabels[statIndex] = scoreLabel; statLabels[statIndex] = scoreLabel;
DefaultButton increaseButton = new DefaultButton("+"); DefaultButton increaseButton = new DefaultButton("+");
increaseButton.setBounds(90, 50, 50, 50);
increaseButton.addActionListener(e -> increase(statIndex)); increaseButton.addActionListener(e -> increase(statIndex));
DefaultButton decreaseButton = new DefaultButton("-"); DefaultButton decreaseButton = new DefaultButton("-");
decreaseButton.setBounds(21, 50, 50, 50);
decreaseButton.addActionListener(e -> decrease(statIndex)); decreaseButton.addActionListener(e -> decrease(statIndex));
subPanel.add(decreaseButton); subPanel.add(decreaseButton);
@@ -147,14 +144,14 @@ public class ChooseAbilityScoresPanel extends JPanel implements AppTheme {
if (isDecreasing) { if (isDecreasing) {
if(currentStatValue <= 8) { if (currentStatValue <= 8) {
System.out.println("registered invalid decrease"); System.out.println("registered invalid decrease");
return -1; return -1;
} }
if(currentStatValue < 14) { if (currentStatValue < 14) {
cost = 1; cost = 1;
@@ -166,7 +163,7 @@ public class ChooseAbilityScoresPanel extends JPanel implements AppTheme {
} else { } else {
if(currentStatValue < 13) { if (currentStatValue < 13) {
cost = 1; cost = 1;
@@ -190,13 +187,13 @@ public class ChooseAbilityScoresPanel extends JPanel implements AppTheme {
int value = statCostCalculator(statIndex, false); int value = statCostCalculator(statIndex, false);
if(value == -1) { if (value == -1) {
return; return;
} }
if(basicNavPanel.getContinueRequirement() - value >= 0) { if (basicNavPanel.getContinueRequirement() - value >= 0) {
selectedStats[statIndex]++; selectedStats[statIndex]++;
statLabels[statIndex].setText("" + selectedStats[statIndex]); statLabels[statIndex].setText("" + selectedStats[statIndex]);
@@ -211,13 +208,13 @@ public class ChooseAbilityScoresPanel extends JPanel implements AppTheme {
int value = statCostCalculator(statIndex, true); int value = statCostCalculator(statIndex, true);
if(value == -1) { if (value == -1) {
return; return;
} }
if(basicNavPanel.getContinueRequirement() + value <= 27) { if (basicNavPanel.getContinueRequirement() + value <= 27) {
selectedStats[statIndex]--; selectedStats[statIndex]--;
statLabels[statIndex].setText("" + selectedStats[statIndex]); statLabels[statIndex].setText("" + selectedStats[statIndex]);
+45 -50
View File
@@ -3,7 +3,6 @@ package GUI.Panels;
import GUI.AppTheme; import GUI.AppTheme;
import Resources.CustomAssets.BasicNavPanel; import Resources.CustomAssets.BasicNavPanel;
import Resources.CustomAssets.DefaultButton; import Resources.CustomAssets.DefaultButton;
import Resources.CustomAssets.InfoPanel;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
@@ -71,7 +70,7 @@ public class DescriptionPanel extends JPanel implements AppTheme {
alignmentButtons = new DefaultButton[alignmentOptions.length]; alignmentButtons = new DefaultButton[alignmentOptions.length];
backgroundButtons = new DefaultButton[backgroundOptions.length]; backgroundButtons = new DefaultButton[backgroundOptions.length];
characteristicsHolder = new String[] { characteristicsHolder = new String[]{
"Name: ", "Name: ",
"Age: ", "Age: ",
@@ -87,7 +86,6 @@ public class DescriptionPanel extends JPanel implements AppTheme {
} }
private void createPanel(String panelTitle, BasicNavPanel nav) { private void createPanel(String panelTitle, BasicNavPanel nav) {
add(createPanelTitle(panelTitle), BorderLayout.NORTH); add(createPanelTitle(panelTitle), BorderLayout.NORTH);
@@ -165,80 +163,59 @@ public class DescriptionPanel extends JPanel implements AppTheme {
JPanel panel = new JPanel(new GridLayout(1, 3)); JPanel panel = new JPanel(new GridLayout(1, 3));
panel.setOpaque(false); panel.setOpaque(false);
panel.add(createAlignmentPanel()); panel.add(createSubPanel("Alignment"));
panel.add(createBackgroundPanel()); panel.add(createSubPanel("Background"));
panel.add(createTextBoxPanel()); panel.add(createTextBoxPanel());
return panel; return panel;
} }
private JPanel createAlignmentPanel() { private JPanel createSubPanel(String labelName) {
JPanel alignmentPanel = new JPanel(new BorderLayout(0, 0)); JPanel panel = new JPanel(new BorderLayout(0, 0));
alignmentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); panel.setBorder(new EmptyBorder(5, 5, 5, 5));
alignmentPanel.setOpaque(false); panel.setOpaque(false);
JLabel backgroundLabel = new JLabel("Alignment"); JLabel label = new JLabel(labelName);
backgroundLabel.setForeground(darkestBrown); label.setForeground(darkestBrown);
backgroundLabel.setFont(subHeaderFont); label.setFont(subHeaderFont);
backgroundLabel.setHorizontalAlignment(SwingConstants.CENTER); 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); 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]); innerPanel.add(alignmentButtons[i]);
if(i == 0) {
alignmentButtons[i].select();
} }
} } else {
alignmentPanel.add(backgroundLabel, BorderLayout.NORTH); innerPanel = new JPanel(new GridLayout(9, 2));
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.setOpaque(false); 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]); 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) { private DefaultButton createButton(String name, boolean isAlignmentElseBackground, int index) {
DefaultButton button = new DefaultButton(name); DefaultButton button = new DefaultButton(name);
+52 -66
View File
@@ -1,83 +1,69 @@
package GUI.Panels; package GUI.Panels;
import javax.swing.JPanel; import GUI.AppTheme;
import java.awt.BorderLayout; import Resources.CustomAssets.DefaultButton;
import javax.swing.JLabel;
import javax.swing.SwingConstants; import javax.swing.*;
import java.awt.Font;
import java.awt.Color;
import javax.swing.border.BevelBorder; import javax.swing.border.BevelBorder;
import javax.swing.JButton; import javax.swing.border.EmptyBorder;
import java.awt.event.ActionListener; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class MainMenuPanel extends JPanel { public class MainMenuPanel extends JPanel implements AppTheme {
/** private DefaultButton newCharacter;
* Create the panel. private DefaultButton randomCharacter;
*/ private DefaultButton loadCharacter;
public MainMenuPanel() {
setBackground(new Color(222, 184, 135)); public MainMenuPanel(DefaultButton newCharacter, DefaultButton randomCharacter, DefaultButton loadCharacter) {
setBorder(new BevelBorder(BevelBorder.RAISED, new Color(160, 82, 45), new Color(165, 42, 42), new Color(0, 0, 0), null));
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)); setLayout(new BorderLayout(0, 0));
JLabel mainMenuLbl = mainMenuLbl();
add(mainMenuLbl, BorderLayout.NORTH);
JPanel controlPanel = createControlPanel();
add(controlPanel, BorderLayout.CENTER);
} }
/** private JLabel createLabel() {
* @return
*/ 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() { private JPanel createControlPanel() {
JPanel controlPanel = new JPanel(); JPanel panel = new JPanel(new GridLayout(1, 2, 50, 0));
controlPanel.setOpaque(false); panel.setOpaque(false);
controlPanel.setLayout(null); panel.setBorder(new EmptyBorder(25, 25, 25, 25));
JButton newCharBtn = new JButton("New \nCharacter"); JPanel subPanel = new JPanel(new GridLayout(2, 1, 0, 50));
newCharBtn.addActionListener(new ActionListener() { subPanel.setOpaque(false);
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);
JButton randCharacterBtn = new JButton("Random Character"); subPanel.add(newCharacter);
randCharacterBtn.addActionListener(new ActionListener() { subPanel.add(randomCharacter);
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);
JButton loadCharacter = new JButton("Load Character"); panel.add(subPanel);
loadCharacter.addActionListener(new ActionListener() { panel.add(loadCharacter);
public void actionPerformed(ActionEvent e) {
} return panel;
});
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;
} }
/**
* @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 GUI.AppTheme;
import java.awt.BorderLayout; import javax.swing.*;
import java.awt.Color; import javax.swing.border.BevelBorder;
import java.awt.Font; import java.awt.*;
import java.awt.GridLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; 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 { public class step4 extends JPanel implements AppTheme {
private JTextField nameTxtField; private JTextField nameTxtField;
private JTextField ageTextField; private JTextField ageTextField;
@@ -34,6 +25,7 @@ public class step4 extends JPanel implements AppTheme {
} }
private void createEntirePanel() { private void createEntirePanel() {
setBackground(new Color(222, 184, 135)); 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)); 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)); setBorder(new EmptyBorder(15, 150, 15, 150));
add(backButton); add(backButton);
if(continueRequirement == 0) { if (continueRequirement == 0) {
add(continueButton); add(continueButton);
@@ -52,13 +52,22 @@ public class DefaultButton extends JButton implements AppTheme {
addMouseListener( addMouseListener(
new MouseListener() { new MouseListener() {
@Override @Override
public void mouseClicked(MouseEvent e) {} public void mouseClicked(MouseEvent e) {
}
@Override @Override
public void mousePressed(MouseEvent e) {} public void mousePressed(MouseEvent e) {
}
@Override @Override
public void mouseReleased(MouseEvent e) {} public void mouseReleased(MouseEvent e) {
}
@Override @Override
public void mouseEntered(MouseEvent e) { applyFocusedButtonStyle(); } public void mouseEntered(MouseEvent e) {
applyFocusedButtonStyle();
}
@Override @Override
public void mouseExited(MouseEvent e) { 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 = ""; String category = "";
if(panelIndex == 1) { if (panelIndex == 1) {
category = "Races"; category = "Races";
@@ -68,7 +68,7 @@ public class ImageInfoPanel extends InfoPanel implements AppTheme {
File imagesDir; File imagesDir;
if(OS.startsWith("Windows")) { if (OS.startsWith("Windows")) {
imagesDir = new File("dndBuilder\\src\\Resources\\Img\\" + category + "\\" + categoryHolder[i].toLowerCase() + "\\"); 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."); picture = new JLabel("ERROR: Image not found.");
@@ -2,14 +2,9 @@ package Resources.CustomAssets;
import GUI.AppTheme; import GUI.AppTheme;
import javax.imageio.ImageIO;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import java.awt.*; 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 { public class InfoPanel extends JPanel implements AppTheme {
@@ -1,6 +1,6 @@
package Resources.CustomAssets; package Resources.CustomAssets;
import javax.swing.border.*; import javax.swing.border.Border;
import java.awt.*; import java.awt.*;
public class RoundedBorder implements Border { public class RoundedBorder implements Border {
@@ -15,7 +15,7 @@ public class RoundedBorder implements Border {
public Insets getBorderInsets(Component c) { 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) { 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);
} }
} }