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,17 +10,17 @@ 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[]{
new Strength(str),
new Dexterity(dex),
new Constitution(con),
new Intelligence(intel),
new Wisdom(wis),
new Charisma(cha)
new Strength(str),
new Dexterity(dex),
new Constitution(con),
new Intelligence(intel),
new Wisdom(wis),
new Charisma(cha)
};
@@ -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
* @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() + " | ");
@@ -2,54 +2,54 @@ package Character.AbilityScores;
public class Charisma extends Stats {
private int abilityScore;
private int abilityScoreModifier;
private int abilityScore;
private int abilityScoreModifier;
public Charisma(int abilityScore) {
public Charisma(int abilityScore) {
this.abilityScore = abilityScore;
this.abilityScoreModifier = calcSavingThrow(abilityScore);
}
public int getScore() {
public int getScore() {
return abilityScore;
return abilityScore;
}
}
public int getModifier() {
public int getModifier() {
return abilityScoreModifier;
return abilityScoreModifier;
}
}
public int getSavingThrow() {
public int getSavingThrow() {
return getModifier();
return getModifier();
}
}
// TODO: Need description.
public String getDescription() {
// TODO: Need description.
public String getDescription() {
return "Confidence, eloquence, and leadership.";
return "Confidence, eloquence, and leadership.";
}
}
@Override
public String toString() {
@Override
public String toString() {
return "Ability Score: " + abilityScore + " | Modifier: " + abilityScoreModifier + " | Description: "
+ getDescription();
return "Ability Score: " + abilityScore + " | Modifier: " + abilityScoreModifier + " | Description: "
+ getDescription();
}
}
@Override
@Override
public void increaseScore() {
abilityScore++;
}
}
@@ -30,7 +30,7 @@ public class Constitution extends Stats {
}
// TODO: Need description.
// TODO: Need description.
public String getDescription() {
return "Health, stamina, vital force.";
@@ -49,7 +49,7 @@ public class Constitution extends Stats {
public void increaseScore() {
abilityScore++;
}
}
@@ -30,7 +30,7 @@ public class Dexterity extends Stats {
}
// TODO: Need description.
// TODO: Need description.
public String getDescription() {
return "";
@@ -49,7 +49,7 @@ public class Dexterity extends Stats {
public void increaseScore() {
abilityScore++;
}
}
@@ -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 "";
@@ -49,7 +49,7 @@ public class Intelligence extends Stats{
public void increaseScore() {
abilityScore++;
}
}
@@ -61,7 +61,7 @@ public class Strength extends Stats {
public void increaseScore() {
abilityScore++;
}
}
@@ -30,7 +30,7 @@ public class Wisdom extends Stats {
}
// TODO: Need description.
// TODO: Need description.
public String getDescription() {
return "";
@@ -49,7 +49,7 @@ public class Wisdom extends Stats {
public void increaseScore() {
abilityScore++;
}
}
+146 -147
View File
@@ -1,155 +1,154 @@
package Character;
import java.util.Arrays;
public class Background {
private String name;
private boolean[] proficientStatus;
private String[] skills;
private String feature;
private String skillProficiencies;
int backgroundIndex;
/**
* @param name
* @param feature
*/
public Background(String name, boolean[] proficientStatus, String[] skills, String feature) {
this.name = name;
this.proficientStatus = proficientStatus;
this.skills = skills;
this.feature = feature;
skillProficiencies = null;
}
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."
+ "\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(){
name = "Charlatan";
proficientStatus[4] = true;
proficientStatus[15] = true;
skillProficiencies = skills[4] + ", " + skills[15];
feature = "False Identity" + "\nYou have created a second identity that includes documentation, established acquaintances, and disguises that allow you to assume that persona. Additionally, you can forge documents including official papers and personal letters, as long as you have seen an example of the kind of document or the handwriting you are trying to copy.";
}
public void setCriminal(){
name = "Criminal";
proficientStatus[4] = true;
proficientStatus[16] = true;
skillProficiencies = skills[4] + ", " + skills[16];
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(){
name = "Spy";
proficientStatus[4] = true;
proficientStatus[16] = true;
skillProficiencies = skills[4] + ", " + skills[16];
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(){
name = "Entertainer";
proficientStatus[0] = true;
proficientStatus[12] = true;
skillProficiencies = skills[0] + ", " + skills[12];
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(){
name = "Folk Hero";
proficientStatus[1] = true;
proficientStatus[17] = true;
skillProficiencies = skills[1] + ", " + skills[17];
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(){
name = "Gladiator";
proficientStatus[0] = true;
proficientStatus[12] = true;
skillProficiencies = skills[0] + ", " + skills[12];
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(){
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.";
}
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.";
}
int backgroundIndex;
private String name;
private boolean[] proficientStatus;
private String[] skills;
private String feature;
private String skillProficiencies;
public void setGuildHermit(){
name = "Hermit";
proficientStatus[9] = true;
proficientStatus[14] = true;
skillProficiencies = skills[9] + ", " + skills[14];
feature = "Discovery" + "\nThe quiet seclusion of your extended hermitage gave you access to a unique and powerful discovery. The exact nature of this revelation depends on the nature of your seclusion. It might be a great truth about the cosmos, the deities, the powerful beings of the outer planes, or the forces of nature. It could be a site that no one else has ever seen. You might have uncovered a fact that has long been forgotten, or unearthed some relic of the past that could rewrite history. It might be information that would be damaging to the people who consigned you to exile, and hence the reason for your return to society."
+ "\nWork with your DM to determine the details of your discovery and its impact on the campaign.";
}
/**
* @param name
* @param feature
*/
public Background(String name, boolean[] proficientStatus, String[] skills, String feature) {
this.name = name;
this.proficientStatus = proficientStatus;
this.skills = skills;
this.feature = feature;
skillProficiencies = null;
}
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."
+ "\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() {
name = "Charlatan";
proficientStatus[4] = true;
proficientStatus[15] = true;
skillProficiencies = skills[4] + ", " + skills[15];
feature = "False Identity" + "\nYou have created a second identity that includes documentation, established acquaintances, and disguises that allow you to assume that persona. Additionally, you can forge documents including official papers and personal letters, as long as you have seen an example of the kind of document or the handwriting you are trying to copy.";
}
public void setCriminal() {
name = "Criminal";
proficientStatus[4] = true;
proficientStatus[16] = true;
skillProficiencies = skills[4] + ", " + skills[16];
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() {
name = "Spy";
proficientStatus[4] = true;
proficientStatus[16] = true;
skillProficiencies = skills[4] + ", " + skills[16];
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() {
name = "Entertainer";
proficientStatus[0] = true;
proficientStatus[12] = true;
skillProficiencies = skills[0] + ", " + skills[12];
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() {
name = "Folk Hero";
proficientStatus[1] = true;
proficientStatus[17] = true;
skillProficiencies = skills[1] + ", " + skills[17];
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() {
name = "Gladiator";
proficientStatus[0] = true;
proficientStatus[12] = true;
skillProficiencies = skills[0] + ", " + skills[12];
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() {
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.";
}
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.";
}
public void setGuildHermit() {
name = "Hermit";
proficientStatus[9] = true;
proficientStatus[14] = true;
skillProficiencies = skills[9] + ", " + skills[14];
feature = "Discovery" + "\nThe quiet seclusion of your extended hermitage gave you access to a unique and powerful discovery. The exact nature of this revelation depends on the nature of your seclusion. It might be a great truth about the cosmos, the deities, the powerful beings of the outer planes, or the forces of nature. It could be a site that no one else has ever seen. You might have uncovered a fact that has long been forgotten, or unearthed some relic of the past that could rewrite history. It might be information that would be damaging to the people who consigned you to exile, and hence the reason for your return to society."
+ "\nWork with your DM to determine the details of your discovery and its impact on the campaign.";
}
public void setKnight() {
name = "Knight";
proficientStatus[5] = true;
proficientStatus[11] = true;
skillProficiencies = skills[5] + ", " + skills[11];
feature = "Retainers" + "\nYou have the service of three retainers loyal to your family. These retainers can be attendants or messengers, and one might be a majordomo. Your retainers are commoners who can perform mundane tasks for you, but they do not fight for you, will not follow you into obviously dangerous areas (such as dungeons), and will leave if they are frequently endangered or abused.";
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @return the skillProficiencies
*/
public String getskillProficiences() {
return skillProficiencies;
}
/**
* @return the feature
*/
public String getDescription() {
return feature;
}
/**
* @return the proficientStatus
*/
public boolean[] getProficientStatus() {
return proficientStatus;
}
@Override
public String toString() {
return "Background: " + name + "\nSkill Proficiencies: " + skillProficiencies + "\nFeature: "
+ feature;
}
public void setKnight(){
name = "Knight";
proficientStatus[5] = true;
proficientStatus[11] = true;
skillProficiencies = skills[5] + ", " + skills[11];
feature = "Retainers" + "\nYou have the service of three retainers loyal to your family. These retainers can be attendants or messengers, and one might be a majordomo. Your retainers are commoners who can perform mundane tasks for you, but they do not fight for you, will not follow you into obviously dangerous areas (such as dungeons), and will leave if they are frequently endangered or abused.";
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @return the skillProficiencies
*/
public String getskillProficiences() {
return skillProficiencies;
}
/**
* @return the feature
*/
public String getDescription() {
return feature;
}
/**
* @return the proficientStatus
*/
public boolean[] getProficientStatus() {
return proficientStatus;
}
@Override
public String toString() {
return "Background: " + name + "\nSkill Proficiencies: " + skillProficiencies + "\nFeature: "
+ feature;
}
}
+108 -101
View File
@@ -1,114 +1,121 @@
package Character;
import Character.AbilityScores.CharacterStats;
import Character.Classes.ClassTemplate;
import Character.Races.*;
import Character.Races.Race;
import java.io.Serializable;
public class CharacterSheet implements Serializable {
private String name;
private int age;
private int heightFeet;
private int heightInch;
private int weight;
private String eye;
private String hair;
private Race race;
private String name;
private int age;
private int heightFeet;
private int heightInch;
private int weight;
private String eye;
private String hair;
private Race race;
private CharacterStats stats;
/**
* @param name
* @param age
* @param heightFeet
* @param heightInch
* @param weight
* @param eye
* @param hair
*/
public CharacterSheet(String name, int age,
int heightFeet, int heightInch,
int weight, String eye, String hair,
Race race, CharacterStats stats) {
this.name = name;
this.age = age;
this.heightFeet = heightFeet;
this.heightInch = heightInch;
this.weight = weight;
this.eye = eye;
this.hair = hair;
this.race = race;
this.stats = stats;
}
/**
* Default constructor
*/
public CharacterSheet() {
this.name = "null";
this.age = 0;
this.heightFeet = 0;
this.heightInch = 0;
this.weight = 0;
this.eye = "null";
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
*/
public String getHair() {
return hair;
}
private CharacterStats stats;
public CharacterStats getStats() {
/**
* @param name
* @param age
* @param heightFeet
* @param heightInch
* @param weight
* @param eye
* @param hair
*/
public CharacterSheet(String name, int age,
int heightFeet, int heightInch,
int weight, String eye, String hair,
Race race, CharacterStats stats) {
this.name = name;
this.age = age;
this.heightFeet = heightFeet;
this.heightInch = heightInch;
this.weight = weight;
this.eye = eye;
this.hair = hair;
this.race = race;
this.stats = stats;
}
return stats;
/**
* Default constructor
*/
public CharacterSheet() {
this.name = "null";
this.age = 0;
this.heightFeet = 0;
this.heightInch = 0;
this.weight = 0;
this.eye = "null";
this.hair = "null";
}
@Override
public String toString() {
return "name: " + name + " | age: " + age + " | height: "
+ heightFeet + "\'" + heightInch + "\" | weight: "
+ weight + " | eye: " + eye + " | hair: " + hair
+ " | race: " + race.toString() + " | stats: " + stats.toString();
}
}
/**
* @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
*/
public String getHair() {
return hair;
}
public CharacterStats getStats() {
return stats;
}
@Override
public String toString() {
return "name: " + name + " | age: " + age + " | height: "
+ heightFeet + "\'" + heightInch + "\" | weight: "
+ weight + " | eye: " + eye + " | hair: " + hair
+ " | race: " + race.toString() + " | stats: " + stats.toString();
}
}
@@ -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?
+45 -45
View File
@@ -1,72 +1,72 @@
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
public String getRace() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
@Override
public String getRace() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
@Override
public int maxAge() {
// TODO Auto-generated method stub
return maxAge;
}
@Override
public int maxAge() {
// TODO Auto-generated method stub
return maxAge;
}
@Override
public int getSpeed() {
// TODO Auto-generated method stub
return speed;
}
@Override
public int getSpeed() {
// TODO Auto-generated method stub
return speed;
}
@Override
public String[] getTraits() {
// TODO Auto-generated method stub
@Override
public String[] getTraits() {
// TODO Auto-generated method stub
return traits;
}
}
@Override
public String[] getSkills() {
// TODO Auto-generated method stub
return skills;
}
@Override
public String[] getSkills() {
// TODO Auto-generated method stub
return skills;
}
@Override
public String[] getLanguages() {
// TODO Auto-generated method stub
return languages;
}
@Override
public String[] getLanguages() {
// TODO Auto-generated method stub
return languages;
}
@Override
public String[] getProficiencies() {
// TODO Auto-generated method stub
return proficiencies;
}
@Override
public String[] getProficiencies() {
// TODO Auto-generated method stub
return proficiencies;
}
@Override
public int[] getASI() {
// TODO Auto-generated method stub
return new int[]{0,0,5};
return new int[]{0, 0, 5};
}
@Override
public String toString() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
@Override
public String toString() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
}
+45 -45
View File
@@ -1,72 +1,72 @@
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
public String getRace() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
@Override
public String getRace() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
@Override
public int maxAge() {
// TODO Auto-generated method stub
return maxAge;
}
@Override
public int maxAge() {
// TODO Auto-generated method stub
return maxAge;
}
@Override
public int getSpeed() {
// TODO Auto-generated method stub
return speed;
}
@Override
public int getSpeed() {
// TODO Auto-generated method stub
return speed;
}
@Override
public String[] getTraits() {
// TODO Auto-generated method stub
@Override
public String[] getTraits() {
// TODO Auto-generated method stub
return traits;
}
}
@Override
public String[] getSkills() {
// TODO Auto-generated method stub
return skills;
}
@Override
public String[] getSkills() {
// TODO Auto-generated method stub
return skills;
}
@Override
public String[] getLanguages() {
// TODO Auto-generated method stub
return languages;
}
@Override
public String[] getLanguages() {
// TODO Auto-generated method stub
return languages;
}
@Override
public String[] getProficiencies() {
// TODO Auto-generated method stub
return proficiencies;
}
@Override
public String[] getProficiencies() {
// TODO Auto-generated method stub
return proficiencies;
}
@Override
public int[] getASI() {
// TODO Auto-generated method stub
return new int[]{2,2};
return new int[]{2, 2};
}
@Override
public String toString() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
@Override
public String toString() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
}
+45 -45
View File
@@ -1,72 +1,72 @@
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
public String getRace() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
@Override
public String getRace() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
@Override
public int maxAge() {
// TODO Auto-generated method stub
return maxAge;
}
@Override
public int maxAge() {
// TODO Auto-generated method stub
return maxAge;
}
@Override
public int getSpeed() {
// TODO Auto-generated method stub
return speed;
}
@Override
public int getSpeed() {
// TODO Auto-generated method stub
return speed;
}
@Override
public String[] getTraits() {
// TODO Auto-generated method stub
@Override
public String[] getTraits() {
// TODO Auto-generated method stub
return traits;
}
}
@Override
public String[] getSkills() {
// TODO Auto-generated method stub
return skills;
}
@Override
public String[] getSkills() {
// TODO Auto-generated method stub
return skills;
}
@Override
public String[] getLanguages() {
// TODO Auto-generated method stub
return languages;
}
@Override
public String[] getLanguages() {
// TODO Auto-generated method stub
return languages;
}
@Override
public String[] getProficiencies() {
// TODO Auto-generated method stub
return proficiencies;
}
@Override
public String[] getProficiencies() {
// TODO Auto-generated method stub
return proficiencies;
}
@Override
public int[] getASI() {
// TODO Auto-generated method stub
return new int[]{1,1};
return new int[]{1, 1};
}
@Override
public String toString() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
@Override
public String toString() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
}
+45 -45
View File
@@ -1,72 +1,72 @@
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
public String getRace() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
@Override
public String getRace() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
@Override
public int maxAge() {
// TODO Auto-generated method stub
return maxAge;
}
@Override
public int maxAge() {
// TODO Auto-generated method stub
return maxAge;
}
@Override
public int getSpeed() {
// TODO Auto-generated method stub
return speed;
}
@Override
public int getSpeed() {
// TODO Auto-generated method stub
return speed;
}
@Override
public String[] getTraits() {
// TODO Auto-generated method stub
@Override
public String[] getTraits() {
// TODO Auto-generated method stub
return traits;
}
}
@Override
public String[] getSkills() {
// TODO Auto-generated method stub
return skills;
}
@Override
public String[] getSkills() {
// TODO Auto-generated method stub
return skills;
}
@Override
public String[] getLanguages() {
// TODO Auto-generated method stub
return languages;
}
@Override
public String[] getLanguages() {
// TODO Auto-generated method stub
return languages;
}
@Override
public String[] getProficiencies() {
// TODO Auto-generated method stub
return proficiencies;
}
@Override
public String[] getProficiencies() {
// TODO Auto-generated method stub
return proficiencies;
}
@Override
public int[] getASI() {
// TODO Auto-generated method stub
return new int[]{3,3};
return new int[]{3, 3};
}
@Override
public String toString() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
@Override
public String toString() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
}
+48 -48
View File
@@ -1,77 +1,77 @@
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;
private int chosenASI;
private int chosenASI;
//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.chosenASI = chosenASI;
this.languages = new String[]{"Common", "Elvish", chosenLanguage};
this.skills = new String[]{};
this.chosenASI = chosenASI;
}
@Override
public String getRace() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
@Override
public String getRace() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
@Override
public int maxAge() {
// TODO Auto-generated method stub
return maxAge;
}
@Override
public int maxAge() {
// TODO Auto-generated method stub
return maxAge;
}
@Override
public int getSpeed() {
// TODO Auto-generated method stub
return speed;
}
@Override
public int getSpeed() {
// TODO Auto-generated method stub
return speed;
}
@Override
public String[] getTraits() {
// TODO Auto-generated method stub
@Override
public String[] getTraits() {
// TODO Auto-generated method stub
return traits;
}
}
@Override
public String[] getSkills() {
// TODO Auto-generated method stub
return skills;
}
@Override
public String[] getSkills() {
// TODO Auto-generated method stub
return skills;
}
@Override
public String[] getLanguages() {
// TODO Auto-generated method stub
return languages;
}
@Override
public String[] getLanguages() {
// TODO Auto-generated method stub
return languages;
}
@Override
public String[] getProficiencies() {
// TODO Auto-generated method stub
return proficiencies;
}
@Override
public String[] getProficiencies() {
// TODO Auto-generated method stub
return proficiencies;
}
@Override
public int[] getASI() {
// TODO Auto-generated method stub
return new int[]{5,5, chosenASI};
return new int[]{5, 5, chosenASI};
}
@Override
public String toString() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
@Override
public String toString() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
}
+45 -45
View File
@@ -1,72 +1,72 @@
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
public String getRace() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
@Override
public String getRace() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
@Override
public int maxAge() {
// TODO Auto-generated method stub
return maxAge;
}
@Override
public int maxAge() {
// TODO Auto-generated method stub
return maxAge;
}
@Override
public int getSpeed() {
// TODO Auto-generated method stub
return speed;
}
@Override
public int getSpeed() {
// TODO Auto-generated method stub
return speed;
}
@Override
public String[] getTraits() {
// TODO Auto-generated method stub
@Override
public String[] getTraits() {
// TODO Auto-generated method stub
return traits;
}
}
@Override
public String[] getSkills() {
// TODO Auto-generated method stub
return skills;
}
@Override
public String[] getSkills() {
// TODO Auto-generated method stub
return skills;
}
@Override
public String[] getLanguages() {
// TODO Auto-generated method stub
return languages;
}
@Override
public String[] getLanguages() {
// TODO Auto-generated method stub
return languages;
}
@Override
public String[] getProficiencies() {
// TODO Auto-generated method stub
return proficiencies;
}
@Override
public String[] getProficiencies() {
// TODO Auto-generated method stub
return proficiencies;
}
@Override
public int[] getASI() {
// TODO Auto-generated method stub
return new int[]{0,0,2};
return new int[]{0, 0, 2};
}
@Override
public String toString() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
@Override
public String toString() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
}
+46 -46
View File
@@ -1,73 +1,73 @@
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[]{};
}
@Override
public String getRace() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
@Override
public String getRace() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
@Override
public int maxAge() {
// TODO Auto-generated method stub
return maxAge;
}
@Override
public int maxAge() {
// TODO Auto-generated method stub
return maxAge;
}
@Override
public int getSpeed() {
// TODO Auto-generated method stub
return speed;
}
@Override
public int getSpeed() {
// TODO Auto-generated method stub
return speed;
}
@Override
public String[] getTraits() {
// TODO Auto-generated method stub
@Override
public String[] getTraits() {
// TODO Auto-generated method stub
return traits;
}
}
@Override
public String[] getSkills() {
// TODO Auto-generated method stub
return skills;
}
@Override
public String[] getSkills() {
// TODO Auto-generated method stub
return skills;
}
@Override
public String[] getLanguages() {
// TODO Auto-generated method stub
return languages;
}
@Override
public String[] getLanguages() {
// TODO Auto-generated method stub
return languages;
}
@Override
public String[] getProficiencies() {
// TODO Auto-generated method stub
return proficiencies;
}
@Override
public String[] getProficiencies() {
// TODO Auto-generated method stub
return proficiencies;
}
@Override
public int[] getASI() {
// TODO Auto-generated method stub
return new int[]{1,1};
return new int[]{1, 1};
}
@Override
public String toString() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
@Override
public String toString() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
}
+42 -42
View File
@@ -2,62 +2,62 @@ 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[]{};
}
@Override
public String getRace() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
@Override
public String getRace() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
@Override
public int maxAge() {
// TODO Auto-generated method stub
return maxAge;
}
@Override
public int maxAge() {
// TODO Auto-generated method stub
return maxAge;
}
@Override
public int getSpeed() {
// TODO Auto-generated method stub
return speed;
}
@Override
public int getSpeed() {
// TODO Auto-generated method stub
return speed;
}
@Override
public String[] getTraits() {
// TODO Auto-generated method stub
@Override
public String[] getTraits() {
// TODO Auto-generated method stub
return traits;
}
}
@Override
public String[] getSkills() {
// TODO Auto-generated method stub
return skills;
}
@Override
public String[] getSkills() {
// TODO Auto-generated method stub
return skills;
}
@Override
public String[] getLanguages() {
// TODO Auto-generated method stub
return languages;
}
@Override
public String[] getLanguages() {
// TODO Auto-generated method stub
return languages;
}
@Override
public String[] getProficiencies() {
// TODO Auto-generated method stub
return proficiencies;
}
@Override
public String[] getProficiencies() {
// TODO Auto-generated method stub
return proficiencies;
}
@Override
public int[] getASI() {
@@ -65,10 +65,10 @@ public class Human implements Race {
return new int[]{0, 1, 2, 3, 4, 5};
}
@Override
public String toString() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
@Override
public String toString() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
}
+8 -9
View File
@@ -2,21 +2,21 @@ package Character.Races;
public interface Race {
String getRace();
String getRace();
int maxAge();
int maxAge();
int getSpeed();
int getSpeed();
String[] getTraits();
String[] getTraits();
String[] getSkills();
String[] getSkills();
String[] getLanguages();
String[] getLanguages();
String[] getProficiencies();
String[] getProficiencies();
int[] getASI();
int[] getASI();
// private ArrayList<String> traits;
// private ArrayList<String> skills;
@@ -44,5 +44,4 @@ public interface Race {
// }
}
+45 -45
View File
@@ -1,72 +1,72 @@
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
public String getRace() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
@Override
public String getRace() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
@Override
public int maxAge() {
// TODO Auto-generated method stub
return maxAge;
}
@Override
public int maxAge() {
// TODO Auto-generated method stub
return maxAge;
}
@Override
public int getSpeed() {
// TODO Auto-generated method stub
return speed;
}
@Override
public int getSpeed() {
// TODO Auto-generated method stub
return speed;
}
@Override
public String[] getTraits() {
// TODO Auto-generated method stub
@Override
public String[] getTraits() {
// TODO Auto-generated method stub
return traits;
}
}
@Override
public String[] getSkills() {
// TODO Auto-generated method stub
return skills;
}
@Override
public String[] getSkills() {
// TODO Auto-generated method stub
return skills;
}
@Override
public String[] getLanguages() {
// TODO Auto-generated method stub
return languages;
}
@Override
public String[] getLanguages() {
// TODO Auto-generated method stub
return languages;
}
@Override
public String[] getProficiencies() {
// TODO Auto-generated method stub
return proficiencies;
}
@Override
public String[] getProficiencies() {
// TODO Auto-generated method stub
return proficiencies;
}
@Override
public int[] getASI() {
// TODO Auto-generated method stub
return new int[]{3,5,5};
return new int[]{3, 5, 5};
}
@Override
public String toString() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
@Override
public String toString() {
// TODO Auto-generated method stub
return this.getClass().getSimpleName();
}
}
+12 -22
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.
*
* 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
*
* @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
*
* @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;
+18 -27
View File
@@ -4,69 +4,60 @@
*/
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());
int sizeOfDice = Integer.parseInt(diceSize.getSelectedItem().toString());
int modifier = Integer.parseInt(diceMod.getText());
int[] diceRolls = rollDice(numberOfDice, sizeOfDice);
int rollTotal = rollTotal(diceRolls, modifier);
String rollString = numberOfDice + "d" + sizeOfDice + modifierString(modifier) + "\nRolled: " + Arrays.toString(diceRolls) + "\nRoll Total";
if (modifier == 0)
rollString += ": " + rollTotal;
else
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;
}
}
+5 -5
View File
@@ -1,14 +1,14 @@
import GUI.*;
import FileManagement.*;
import FileManagement.FileManager;
import GUI.GUImanager;
public class DndCharacterBuilder {
public static void main(String[] args) {
FileManager data = new FileManager();
FileManager data = new FileManager();
GUImanager gui = new GUImanager(data.isReturninguser());
gui.setVisible(true);
GUImanager gui = new GUImanager(data.isReturninguser());
gui.setVisible(true);
}
@@ -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];
+90 -64
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;
@@ -10,17 +13,17 @@ import java.awt.*;
public class GUImanager extends JFrame {
private static JPanel[] panels;
private int lastPanel;
private int currentPanel;
private int nextPanel;
private int lastPanel;
private int currentPanel;
private int nextPanel;
private String[] raceOptions;
private String[] raceDescriptions;
private String[] classOptions;
private String[] classDescriptions;
private int raceChoice;
private int classChoice;
private int raceChoice;
private int classChoice;
private String[] statOptions;
private String[] statDescriptions;
@@ -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 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 DescriptionPanel(createNavPanel(), characteristics, alignmentOptions, alignmentDescriptions, backgroundOptions, backgroundDescriptions, "Step 4: Describe your character")
};
setupPanelInfo();
this.panels = new JPanel[]{
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(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 = 0;
this.lastPanel = currentPanel - 1;
this.nextPanel = currentPanel + 1;*/
this.currentPanel = 4;
this.lastPanel = 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,20 +157,20 @@ public class GUImanager extends JFrame {
};
statDescriptions = new String[] {
statDescriptions = new String[]{
"Strength is a thing.",
"Dexterity is a thing",
"Constitution is a thing",
"Intelligence is a thing",
"Wisdom is a thing",
"Charisma is a thing"
"Strength is a thing.",
"Dexterity is a thing",
"Constitution is a thing",
"Intelligence is a thing",
"Wisdom is a thing",
"Charisma is a thing"
};
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",
@@ -275,7 +272,7 @@ public class GUImanager extends JFrame {
private DefaultButton createBackButton() {
DefaultButton button = new DefaultButton("Back");
button.addActionListener(
button.addActionListener(
e -> {
@@ -286,7 +283,7 @@ public class GUImanager extends JFrame {
}
);
);
return button;
@@ -295,18 +292,27 @@ public class GUImanager extends JFrame {
private DefaultButton createContinueButton() {
DefaultButton button = new DefaultButton("Continue");
button.addActionListener(
button.addActionListener(
e -> {
e -> {
lastPanel++;
currentPanel++;
nextPanel++;
clearAndReset();
lastPanel++;
currentPanel++;
nextPanel++;
clearAndReset();
}
}
);
);
return button;
}
private DefaultButton createNewCharacterButton() {
DefaultButton button = createContinueButton();
button.setText("Create New Character");
return button;
@@ -322,6 +328,27 @@ public class GUImanager extends JFrame {
createRandomCharacter();
lastPanel = currentPanel;
currentPanel = 3;
nextPanel = currentPanel + 1;
clearAndReset();
}
);
return button;
}
// TODO: Need to implement with exact indices and file manager logic.
private DefaultButton createSaveButton() {
DefaultButton button = new DefaultButton("Save");
button.addActionListener(
e -> {
lastPanel = currentPanel;
currentPanel = 6;
nextPanel = currentPanel + 1;
@@ -335,20 +362,19 @@ public class GUImanager extends JFrame {
}
// TODO: Need to implement.
private DefaultButton createSaveButton() {
private DefaultButton createLoadButton() {
DefaultButton button = new DefaultButton("Save");
DefaultButton button = new DefaultButton("Load");
button.addActionListener(
e -> {
e -> {
lastPanel = currentPanel;
currentPanel = 6;
nextPanel = currentPanel + 1;
clearAndReset();
lastPanel = currentPanel;
currentPanel = 3;
nextPanel = currentPanel + 1;
clearAndReset();
}
}
);
@@ -356,10 +382,10 @@ public class GUImanager extends JFrame {
}
// TODO: Need to implement.
// TODO: Need to implement random character creation.
private void createRandomCharacter() {
System.out.println("Request to create random character. Need to implement.");
}
+72 -72
View File
@@ -1,127 +1,127 @@
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 {
private DefaultButton[] optionButtons;
private String[] options;
private ImageInfoPanel infoPanel;
private int choiceIndex;
private String panelTitle;
private DefaultButton[] optionButtons;
private String[] options;
private ImageInfoPanel infoPanel;
private int choiceIndex;
private String panelTitle;
public BasicPanel(JPanel navPanel, String[] options, String[] descriptions, String panelTitle) {
public BasicPanel(JPanel navPanel, String[] options, String[] descriptions, String panelTitle) {
super();
this.options = options;
this.panelTitle = panelTitle;
super();
this.options = options;
this.panelTitle = panelTitle;
Rectangle[] basicBounds = new Rectangle[]{
Rectangle[] basicBounds = new Rectangle[]{
new Rectangle(5, 5, 600, 400), // ImageInfo panel
new Rectangle(275, 10, 300, 35), // ImageInfo subheader
new Rectangle(275, 45, 300, 355), // ImageInfo text
new Rectangle(10, 45, 250, 355)
new Rectangle(5, 5, 600, 400), // ImageInfo panel
new Rectangle(275, 10, 300, 35), // ImageInfo subheader
new Rectangle(275, 45, 300, 355), // ImageInfo text
new Rectangle(10, 45, 250, 355)
};
};
this.infoPanel = new ImageInfoPanel(options, descriptions, basicBounds, Integer.parseInt(Character.toString(panelTitle.charAt(5))));
infoPanel.updateInfo(0); // Default start with 0th element.
this.infoPanel = new ImageInfoPanel(options, descriptions, basicBounds, Integer.parseInt(Character.toString(panelTitle.charAt(5))));
infoPanel.updateInfo(0); // Default start with 0th element.
choiceIndex = 0;
choiceIndex = 0;
panelSetup();
createMasterPanel();
add(navPanel, BorderLayout.SOUTH);
panelSetup();
createMasterPanel();
add(navPanel, BorderLayout.SOUTH);
}
}
private void panelSetup() {
private void panelSetup() {
setBackground(lightBrown);
setLayout(new BorderLayout(0, 0));
setBackground(lightBrown);
setLayout(new BorderLayout(0, 0));
}
}
private void createMasterPanel() {
private void createMasterPanel() {
JLabel title = new JLabel(panelTitle);
title.setHorizontalAlignment(SwingConstants.CENTER);
title.setFont(headerFont);
title.setForeground(darkestBrown);
add(title, BorderLayout.NORTH);
JLabel title = new JLabel(panelTitle);
title.setHorizontalAlignment(SwingConstants.CENTER);
title.setFont(headerFont);
title.setForeground(darkestBrown);
add(title, BorderLayout.NORTH);
JPanel panel = new JPanel();
panel.setOpaque(false);
panel.setLayout(null);
panel.add(infoPanel);
panel.add(createButtonPanel());
JPanel panel = new JPanel();
panel.setOpaque(false);
panel.setLayout(null);
panel.add(infoPanel);
panel.add(createButtonPanel());
add(panel);
add(panel);
}
}
private JPanel createButtonPanel() {
private JPanel createButtonPanel() {
JPanel buttonPanel = new JPanel(new GridLayout(options.length, 1, 0, 0));
buttonPanel.setBackground(lightBrown);
JPanel buttonPanel = new JPanel(new GridLayout(options.length, 1, 0, 0));
buttonPanel.setBackground(lightBrown);
buttonPanel.setBounds(585, 45, 135, 355);
buttonPanel.setBounds(585, 45, 135, 355);
optionButtons = new DefaultButton[options.length];
optionButtons = new DefaultButton[options.length];
for (int i = 0; i < optionButtons.length; i++) {
for (int i = 0; i < optionButtons.length; i++) {
optionButtons[i] = createButton(options[i], i);
optionButtons[i] = createButton(options[i], i);
if (i == 0) {
if (i == 0) {
optionButtons[i].select();
optionButtons[i].select();
}
}
}
}
for (int i = 0; i < options.length; i++) {
for (int i = 0; i < options.length; i++) {
buttonPanel.add(optionButtons[i]);
buttonPanel.add(optionButtons[i]);
}
}
return buttonPanel;
return buttonPanel;
}
}
private DefaultButton createButton(String holderName, int index) {
private DefaultButton createButton(String holderName, int index) {
DefaultButton button = new DefaultButton(holderName);
button.addActionListener(e -> updateButtons(index));
DefaultButton button = new DefaultButton(holderName);
button.addActionListener(e -> updateButtons(index));
return button;
return button;
}
}
private void updateButtons(int newIndex) {
private void updateButtons(int newIndex) {
optionButtons[choiceIndex].deSelect();
optionButtons[newIndex].select();
optionButtons[choiceIndex].deSelect();
optionButtons[newIndex].select();
choiceIndex = newIndex;
infoPanel.updateInfo(choiceIndex);
choiceIndex = newIndex;
infoPanel.updateInfo(choiceIndex);
}
}
public int getChoice() {
public int getChoice() {
return choiceIndex;
return choiceIndex;
}
}
}
@@ -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;
@@ -11,231 +11,228 @@ import java.awt.*;
public class ChooseAbilityScoresPanel extends JPanel implements AppTheme {
private DefaultButton[] statInfoButtons;
private JLabel[] statLabels;
private String[] statOptions;
private InfoPanel infoPanel;
private BasicNavPanel basicNavPanel;
private int[] selectedStats;
private int selectedStatIndex;
private DefaultButton[] statInfoButtons;
private JLabel[] statLabels;
private String[] statOptions;
private InfoPanel infoPanel;
private BasicNavPanel basicNavPanel;
private int[] selectedStats;
private int selectedStatIndex;
public ChooseAbilityScoresPanel(BasicNavPanel basicNavPanel, String[] statOptions, String[] statDescriptions, int[] selectedStats, String panelTitle) {
public ChooseAbilityScoresPanel(BasicNavPanel basicNavPanel, String[] statOptions, String[] statDescriptions, int[] selectedStats, String panelTitle) {
super();
panelSetup();
this.statOptions = statOptions;
this.selectedStats = selectedStats;
this.statInfoButtons = new DefaultButton[statOptions.length];
statLabels = new JLabel[statOptions.length];
this.basicNavPanel = basicNavPanel;
super();
panelSetup();
this.statOptions = statOptions;
this.selectedStats = selectedStats;
this.statInfoButtons = new DefaultButton[statOptions.length];
statLabels = new JLabel[statOptions.length];
this.basicNavPanel = basicNavPanel;
Rectangle[] abilityScoreBounds = {
Rectangle[] abilityScoreBounds = {
new Rectangle(520, 5, 200, 400), // ImageInfo panel
new Rectangle(5, 10, 200, 35), // ImageInfo subheader
new Rectangle(5, 45, 200, 355) // ImageInfo text
new Rectangle(520, 5, 200, 400), // ImageInfo panel
new Rectangle(5, 10, 200, 35), // ImageInfo subheader
new Rectangle(5, 45, 200, 355) // ImageInfo text
};
};
infoPanel = new InfoPanel(statOptions, statDescriptions, abilityScoreBounds, 3);
infoPanel.updateInfo(0); // Default start with 0th element.
infoPanel = new InfoPanel(statOptions, statDescriptions, abilityScoreBounds, 3);
infoPanel.updateInfo(0); // Default start with 0th element.
createMasterPanel(panelTitle);
add(basicNavPanel, BorderLayout.SOUTH);
createMasterPanel(panelTitle);
add(basicNavPanel, BorderLayout.SOUTH);
}
}
private void panelSetup() {
private void panelSetup() {
setBackground(lightBrown);
setLayout(new BorderLayout(0, 0));
setBackground(lightBrown);
setLayout(new BorderLayout(0, 0));
}
}
private void createMasterPanel(String panelTitle) {
private void createMasterPanel(String panelTitle) {
JLabel title = new JLabel(panelTitle);
title.setHorizontalAlignment(SwingConstants.CENTER);
title.setFont(headerFont);
title.setForeground(darkestBrown);
add(title, BorderLayout.NORTH);
JLabel title = new JLabel(panelTitle);
title.setHorizontalAlignment(SwingConstants.CENTER);
title.setFont(headerFont);
title.setForeground(darkestBrown);
add(title, BorderLayout.NORTH);
JPanel panel = new JPanel();
panel.setOpaque(false);
panel.setLayout(null);
panel.add(createAbilityScorePanels());
panel.add(infoPanel);
JPanel panel = new JPanel();
panel.setOpaque(false);
panel.setLayout(null);
panel.add(createAbilityScorePanels());
panel.add(infoPanel);
add(panel);
add(panel);
}
}
private JPanel createAbilityScorePanels() {
private JPanel createAbilityScorePanels() {
JPanel mainAbilityPanel = new JPanel();
mainAbilityPanel.setBounds(5, 5, 505, 405);
mainAbilityPanel.setLayout(new GridLayout(2, 3, 10, 10));
mainAbilityPanel.setBackground(lightBrown);
JPanel mainAbilityPanel = new JPanel();
mainAbilityPanel.setBounds(5, 5, 505, 405);
mainAbilityPanel.setLayout(new GridLayout(2, 3, 10, 10));
mainAbilityPanel.setBackground(lightBrown);
for (int i = 0; i < statOptions.length; i++) {
for (int i = 0; i < statOptions.length; i++) {
mainAbilityPanel.add(createAbilityPanel(statOptions[i], i));
mainAbilityPanel.add(createAbilityPanel(statOptions[i], i));
}
}
return mainAbilityPanel;
return mainAbilityPanel;
}
}
private JPanel createAbilityPanel(String ability, int statIndex) {
JPanel panel = new JPanel();
panel.setFont(paragraphFont);
panel.setBackground(medBrown);
panel.setBorder(new LineBorder(darkestBrown, 4, true));
panel.setLayout(new BorderLayout(0, 0));
private JPanel createAbilityPanel(String ability, int statIndex) {
JPanel panel = new JPanel();
panel.setFont(paragraphFont);
panel.setBackground(medBrown);
panel.setBorder(new LineBorder(darkestBrown, 4, true));
panel.setLayout(new BorderLayout(0, 0));
DefaultButton tmpButton = new DefaultButton(ability);
tmpButton.setFont(paragraphFont);
tmpButton.setHorizontalAlignment(SwingConstants.CENTER);
tmpButton.addActionListener(e -> updateButtons(statIndex));
DefaultButton tmpButton = new DefaultButton(ability);
tmpButton.setFont(paragraphFont);
tmpButton.setHorizontalAlignment(SwingConstants.CENTER);
tmpButton.addActionListener(e -> updateButtons(statIndex));
statInfoButtons[statIndex] = tmpButton;
statInfoButtons[statIndex] = tmpButton;
panel.add(statInfoButtons[statIndex], BorderLayout.NORTH);
panel.add(statInfoButtons[statIndex], BorderLayout.NORTH);
panel.add(createScorePanel(statIndex));
panel.add(createScorePanel(statIndex));
return panel;
return panel;
}
}
private JPanel createScorePanel(int statIndex) {
private JPanel createScorePanel(int statIndex) {
JPanel subPanel = new JPanel();
JPanel subPanel = new JPanel();
JLabel scoreLabel = new JLabel("" + selectedStats[statIndex]);
scoreLabel.setFont(paragraphFont);
scoreLabel.setHorizontalAlignment(SwingConstants.CENTER);
scoreLabel.setBounds(56, 50, 30, 30);
JLabel scoreLabel = new JLabel("" + selectedStats[statIndex]);
scoreLabel.setFont(paragraphFont);
scoreLabel.setHorizontalAlignment(SwingConstants.CENTER);
statLabels[statIndex] = scoreLabel;
statLabels[statIndex] = scoreLabel;
DefaultButton increaseButton = new DefaultButton("+");
increaseButton.setBounds(90, 50, 50, 50);
increaseButton.addActionListener(e -> increase(statIndex));
DefaultButton increaseButton = new DefaultButton("+");
increaseButton.addActionListener(e -> increase(statIndex));
DefaultButton decreaseButton = new DefaultButton("-");
decreaseButton.setBounds(21, 50, 50, 50);
decreaseButton.addActionListener(e -> decrease(statIndex));
DefaultButton decreaseButton = new DefaultButton("-");
decreaseButton.addActionListener(e -> decrease(statIndex));
subPanel.add(decreaseButton);
subPanel.add(scoreLabel);
subPanel.add(increaseButton);
subPanel.add(decreaseButton);
subPanel.add(scoreLabel);
subPanel.add(increaseButton);
subPanel.setBackground(lightBrown);
subPanel.setBackground(lightBrown);
return subPanel;
return subPanel;
}
}
private int statCostCalculator(int statIndex, boolean isDecreasing) {
private int statCostCalculator(int statIndex, boolean isDecreasing) {
int cost = 0;
int cost = 0;
int currentStatValue = selectedStats[statIndex];
int currentStatValue = selectedStats[statIndex];
if (isDecreasing) {
if (isDecreasing) {
if(currentStatValue <= 8) {
System.out.println("registered invalid decrease");
if (currentStatValue <= 8) {
System.out.println("registered invalid decrease");
return -1;
return -1;
}
}
if(currentStatValue < 14) {
if (currentStatValue < 14) {
cost = 1;
cost = 1;
} else if (currentStatValue == 14 || currentStatValue == 15) {
} else if (currentStatValue == 14 || currentStatValue == 15) {
cost = 2;
cost = 2;
}
}
} else {
} else {
if(currentStatValue < 13) {
if (currentStatValue < 13) {
cost = 1;
cost = 1;
} else if (currentStatValue == 13 || currentStatValue == 14) {
} else if (currentStatValue == 13 || currentStatValue == 14) {
cost = 2;
cost = 2;
} else {
System.out.println("registered invalid increase");
return -1;
} else {
System.out.println("registered invalid increase");
return -1;
}
}
}
}
return cost;
return cost;
}
}
private void increase(int statIndex) {
private void increase(int statIndex) {
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]++;
statLabels[statIndex].setText("" + selectedStats[statIndex]);
selectedStats[statIndex]++;
statLabels[statIndex].setText("" + selectedStats[statIndex]);
basicNavPanel.decreaseContinueRequirement(value);
basicNavPanel.decreaseContinueRequirement(value);
}
}
}
}
private void decrease(int statIndex) {
private void decrease(int statIndex) {
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]--;
statLabels[statIndex].setText("" + selectedStats[statIndex]);
selectedStats[statIndex]--;
statLabels[statIndex].setText("" + selectedStats[statIndex]);
basicNavPanel.increaseContinueRequirement(value);
basicNavPanel.increaseContinueRequirement(value);
}
}
}
}
private void updateButtons(int newIndex) {
private void updateButtons(int newIndex) {
statInfoButtons[selectedStatIndex].deSelect();
statInfoButtons[newIndex].select();
statInfoButtons[selectedStatIndex].deSelect();
statInfoButtons[newIndex].select();
selectedStatIndex = newIndex;
infoPanel.updateInfo(selectedStatIndex);
selectedStatIndex = newIndex;
infoPanel.updateInfo(selectedStatIndex);
}
}
}
+87 -92
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;
@@ -29,12 +28,12 @@ public class DescriptionPanel extends JPanel implements AppTheme {
public DescriptionPanel(BasicNavPanel nav, String[] characteristics, String[] alignmentOptions, String[] alignmentDescriptions, String[] backgroundOptions, String[] backgroundDescriptions, String panelTitle) {
super();
this.nav = nav;
this.characteristics = characteristics;
this.alignmentOptions = alignmentOptions;
this.alignmentDescriptions = alignmentDescriptions;
this.backgroundOptions = backgroundOptions;
this.backgroundDescriptions = backgroundDescriptions;
this.nav = nav;
this.characteristics = characteristics;
this.alignmentOptions = alignmentOptions;
this.alignmentDescriptions = alignmentDescriptions;
this.backgroundOptions = backgroundOptions;
this.backgroundDescriptions = backgroundDescriptions;
panelSetup();
@@ -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);
@@ -101,10 +99,10 @@ public class DescriptionPanel extends JPanel implements AppTheme {
private JLabel createPanelTitle(String panelTitle) {
JLabel title = new JLabel(panelTitle);
title.setHorizontalAlignment(SwingConstants.CENTER);
title.setFont(headerFont);
title.setForeground(darkestBrown);
title.setBorder(new EmptyBorder(25, 25, 25, 25));
title.setHorizontalAlignment(SwingConstants.CENTER);
title.setFont(headerFont);
title.setForeground(darkestBrown);
title.setBorder(new EmptyBorder(25, 25, 25, 25));
return title;
@@ -115,10 +113,10 @@ public class DescriptionPanel extends JPanel implements AppTheme {
GridBagConstraints c = new GridBagConstraints();
JPanel bodyPanel = new JPanel(new GridBagLayout());
bodyPanel.setOpaque(false);
bodyPanel.setOpaque(false);
bodyPanel.add(createNamePanel());
bodyPanel.add(createFooterPanel());
bodyPanel.add(createNamePanel());
bodyPanel.add(createFooterPanel());
return bodyPanel;
@@ -127,13 +125,13 @@ public class DescriptionPanel extends JPanel implements AppTheme {
private JPanel createNamePanel() {
JPanel panel = new JPanel();
panel.setBackground(medBrown);
panel.setBackground(medBrown);
for (int i = 0; i < characteristicsHolder.length; i++) {
for (int i = 0; i < characteristicsHolder.length; i++) {
panel.add(createField(i));
panel.add(createField(i));
}
}
return panel;
@@ -142,17 +140,17 @@ public class DescriptionPanel extends JPanel implements AppTheme {
private JPanel createField(int index) {
JPanel panel = new JPanel();
panel.setOpaque(false);
panel.setOpaque(false);
JLabel label = new JLabel(characteristicsHolder[index]);
label.setFont(paragraphFont);
label.setOpaque(false);
label.setForeground(darkestBrown);
JLabel label = new JLabel(characteristicsHolder[index]);
label.setFont(paragraphFont);
label.setOpaque(false);
label.setForeground(darkestBrown);
JTextField field = new JTextField(10);
field.setFont(paragraphFont);
field.setBackground(lightBrown);
field.setBorder(null);
JTextField field = new JTextField(10);
field.setFont(paragraphFont);
field.setBackground(lightBrown);
field.setBorder(null);
panel.add(label);
panel.add(field);
@@ -164,102 +162,81 @@ public class DescriptionPanel extends JPanel implements AppTheme {
private JPanel createFooterPanel() {
JPanel panel = new JPanel(new GridLayout(1, 3));
panel.setOpaque(false);
panel.add(createAlignmentPanel());
panel.add(createBackgroundPanel());
panel.add(createTextBoxPanel());
panel.setOpaque(false);
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));
innerPanel.setOpaque(false);
JPanel innerPanel;
for (int i = 0; i < alignmentOptions.length; i++) {
if(labelName.equals("Alignment")) {
alignmentButtons[i] = createButton(alignmentOptions[i], false, i);
innerPanel.add(alignmentButtons[i]);
innerPanel = new JPanel(new GridLayout(9, 1));
innerPanel.setOpaque(false);
if(i == 0) {
createButtons(alignmentOptions, alignmentButtons, labelName);
alignmentButtons[i].select();
for (int i = 0; i < alignmentButtons.length; i++) {
}
innerPanel.add(alignmentButtons[i]);
}
alignmentPanel.add(backgroundLabel, BorderLayout.NORTH);
alignmentPanel.add(innerPanel);
} else {
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;
}
private JPanel createTextBoxPanel() {
JPanel panel = new JPanel(new BorderLayout(0, 0));
panel.setOpaque(false);
panel.setOpaque(false);
JLabel label = new JLabel("Enter a Description");
label.setFont(paragraphFont);
label.setOpaque(false);
label.setForeground(darkestBrown);
JLabel label = new JLabel("Enter a Description");
label.setFont(paragraphFont);
label.setOpaque(false);
label.setForeground(darkestBrown);
JTextArea textArea = new JTextArea();
textArea.setForeground(darkestBrown);
textArea.setFont(userTextFont);
textArea.setOpaque(false);
textArea.setBorder(new LineBorder(darkestBrown, 3));
JTextArea textArea = new JTextArea();
textArea.setForeground(darkestBrown);
textArea.setFont(userTextFont);
textArea.setOpaque(false);
textArea.setBorder(new LineBorder(darkestBrown, 3));
panel.add(label);
panel.add(textArea);
panel.add(label);
panel.add(textArea);
return panel;
@@ -288,17 +265,35 @@ 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);
if (isAlignmentElseBackground) {
button.addActionListener(e -> updateAlignmentButtons(index));
button.addActionListener(e -> updateAlignmentButtons(index));
} else {
button.addActionListener(e -> updateBackgroundButtons(index));
button.addActionListener(e -> updateBackgroundButtons(index));
}
+60 -74
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));
setLayout(new BorderLayout(0, 0));
JLabel mainMenuLbl = mainMenuLbl();
add(mainMenuLbl, BorderLayout.NORTH);
JPanel controlPanel = createControlPanel();
add(controlPanel, BorderLayout.CENTER);
}
private DefaultButton newCharacter;
private DefaultButton randomCharacter;
private DefaultButton loadCharacter;
/**
* @return
*/
private JPanel createControlPanel() {
JPanel controlPanel = new JPanel();
controlPanel.setOpaque(false);
controlPanel.setLayout(null);
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);
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);
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;
}
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));
}
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 panel = new JPanel(new GridLayout(1, 2, 50, 0));
panel.setOpaque(false);
panel.setBorder(new EmptyBorder(25, 25, 25, 25));
JPanel subPanel = new JPanel(new GridLayout(2, 1, 0, 50));
subPanel.setOpaque(false);
subPanel.add(newCharacter);
subPanel.add(randomCharacter);
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;
}
}
+265 -273
View File
@@ -2,288 +2,280 @@ 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;
private JTextField heightTxtField;
private JTextField weightTxtField;
private JTextField skinTxtField;
private JTextField eyesTxtField;
private JTextField hairTxtField;
private JTextField nameTxtField;
private JTextField ageTextField;
private JTextField heightTxtField;
private JTextField weightTxtField;
private JTextField skinTxtField;
private JTextField eyesTxtField;
private JTextField hairTxtField;
/**
* Create the panel.
*/
public step4() {
createEntirePanel();
/**
* Create the panel.
*/
public step4() {
createEntirePanel();
}
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));
setLayout(new BorderLayout(0, 0));
JLabel lblNewLabel = createLbl();
add(lblNewLabel, BorderLayout.NORTH);
//Creates back and continue panel
JPanel backContPanel = createBackContinuePanel();
add(backContPanel, BorderLayout.SOUTH);
JPanel innerPanel = new JPanel();
innerPanel.setToolTipText("");
innerPanel.setOpaque(false);
add(innerPanel, BorderLayout.CENTER);
innerPanel.setLayout(null);
JPanel nameAndAlignment = new JPanel();
nameAndAlignment.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
nameAndAlignment.setBackground(new Color(210, 105, 30));
nameAndAlignment.setBounds(6, 6, 306, 114);
innerPanel.add(nameAndAlignment);
nameAndAlignment.setLayout(null);
JLabel nameLbl = new JLabel("Character Name: ");
nameLbl.setBounds(6, 6, 108, 16);
nameAndAlignment.add(nameLbl);
nameTxtField = new JTextField();
nameTxtField.setBounds(121, 1, 173, 26);
nameAndAlignment.add(nameTxtField);
nameTxtField.setColumns(10);
JLabel ageLbl = new JLabel("Age: ");
ageLbl.setBounds(6, 34, 32, 16);
nameAndAlignment.add(ageLbl);
ageTextField = new JTextField();
ageTextField.setBounds(61, 34, 64, 21);
nameAndAlignment.add(ageTextField);
ageTextField.setColumns(10);
JLabel heightLbl = new JLabel("Height: ");
heightLbl.setBounds(6, 62, 55, 16);
nameAndAlignment.add(heightLbl);
heightTxtField = new JTextField();
heightTxtField.setBounds(61, 57, 64, 26);
nameAndAlignment.add(heightTxtField);
heightTxtField.setColumns(10);
JLabel weightLbl = new JLabel("Weight:");
weightLbl.setBounds(6, 90, 61, 16);
nameAndAlignment.add(weightLbl);
weightTxtField = new JTextField();
weightTxtField.setBounds(61, 85, 64, 26);
nameAndAlignment.add(weightTxtField);
weightTxtField.setColumns(10);
JLabel skinLbl = new JLabel("Skin: ");
skinLbl.setBounds(131, 34, 35, 16);
nameAndAlignment.add(skinLbl);
skinTxtField = new JTextField();
skinTxtField.setBounds(165, 29, 130, 26);
nameAndAlignment.add(skinTxtField);
skinTxtField.setColumns(10);
JLabel eyesLbl = new JLabel("Eyes: ");
eyesLbl.setBounds(130, 62, 42, 16);
nameAndAlignment.add(eyesLbl);
eyesTxtField = new JTextField();
eyesTxtField.setBounds(164, 57, 130, 26);
nameAndAlignment.add(eyesTxtField);
eyesTxtField.setColumns(10);
JLabel hairLbl = new JLabel("Hair: ");
hairLbl.setBounds(127, 90, 39, 16);
nameAndAlignment.add(hairLbl);
hairTxtField = new JTextField();
hairTxtField.setBounds(164, 85, 130, 26);
nameAndAlignment.add(hairTxtField);
hairTxtField.setColumns(10);
JPanel alignmentPanel = new JPanel();
alignmentPanel.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
alignmentPanel.setBackground(new Color(205, 133, 63));
alignmentPanel.setBounds(324, 6, 396, 114);
innerPanel.add(alignmentPanel);
alignmentPanel.setLayout(new BorderLayout(0, 0));
JLabel alignmentLbl = new JLabel("Alignment");
alignmentLbl.setFont(new Font("Lucida Grande", Font.PLAIN, 19));
alignmentLbl.setHorizontalAlignment(SwingConstants.CENTER);
alignmentPanel.add(alignmentLbl, BorderLayout.NORTH);
JPanel alignmentInnerPanel = new JPanel();
alignmentInnerPanel.setOpaque(false);
alignmentPanel.add(alignmentInnerPanel, BorderLayout.CENTER);
alignmentInnerPanel.setLayout(new GridLayout(3, 3, 0, 0));
JButton btnLawfulGood = new JButton("Lawful Good");
alignmentInnerPanel.add(btnLawfulGood);
JButton btnNuetralGood = new JButton("Neutral Good");
alignmentInnerPanel.add(btnNuetralGood);
JButton btnChaoticGood = new JButton("Chaotic Good");
alignmentInnerPanel.add(btnChaoticGood);
JButton btnLawfulNeutral = new JButton("Lawful Neutral");
alignmentInnerPanel.add(btnLawfulNeutral);
JButton btnTrueNeutral = new JButton("True Neutral");
alignmentInnerPanel.add(btnTrueNeutral);
JButton btnChaoticNeutral = new JButton("Chaotic Neutral");
alignmentInnerPanel.add(btnChaoticNeutral);
JButton btnLawfulEvil = new JButton("Lawful Evil");
alignmentInnerPanel.add(btnLawfulEvil);
JButton btnNeutralEvil = new JButton("Neutral Evil");
alignmentInnerPanel.add(btnNeutralEvil);
JButton btnChaoticEvil = new JButton("Chaotic Evil");
alignmentInnerPanel.add(btnChaoticEvil);
JPanel backgroundPanel = new JPanel();
backgroundPanel.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
backgroundPanel.setBackground(new Color(210, 105, 30));
backgroundPanel.setBounds(6, 132, 306, 264);
innerPanel.add(backgroundPanel);
backgroundPanel.setLayout(new BorderLayout(0, 0));
JLabel backgroundLbl = new JLabel("Background");
backgroundLbl.setFont(new Font("Dialog", Font.PLAIN, 20));
backgroundLbl.setHorizontalAlignment(SwingConstants.CENTER);
backgroundPanel.add(backgroundLbl, BorderLayout.NORTH);
JPanel backgroundInnerPanel = new JPanel();
backgroundInnerPanel.setOpaque(false);
backgroundPanel.add(backgroundInnerPanel, BorderLayout.CENTER);
backgroundInnerPanel.setLayout(new GridLayout(9, 2, 0, 0));
JButton btnAcolyte = new JButton("Acolyte");
backgroundInnerPanel.add(btnAcolyte);
JButton btnCharlatan = new JButton("Charlatan");
backgroundInnerPanel.add(btnCharlatan);
JButton btnCriminal = new JButton("Criminal");
backgroundInnerPanel.add(btnCriminal);
JButton btnEntertainer = new JButton("Entertainer");
backgroundInnerPanel.add(btnEntertainer);
JButton btnFolkHero = new JButton("Folk Hero");
backgroundInnerPanel.add(btnFolkHero);
JButton btnGladiator = new JButton("Gladiator");
backgroundInnerPanel.add(btnGladiator);
JButton btnGuildArtisan = new JButton("Guild Artisan");
backgroundInnerPanel.add(btnGuildArtisan);
JButton btnGuildMerchant = new JButton("Guild Merchant");
backgroundInnerPanel.add(btnGuildMerchant);
JButton btnHermit = new JButton("Hermit");
backgroundInnerPanel.add(btnHermit);
JButton btnKnight = new JButton("Knight");
backgroundInnerPanel.add(btnKnight);
JButton btnNoble = new JButton("Noble");
backgroundInnerPanel.add(btnNoble);
JButton btnOutlander = new JButton("Outlander");
backgroundInnerPanel.add(btnOutlander);
JButton btnPirate = new JButton("Pirate");
backgroundInnerPanel.add(btnPirate);
JButton btnSage = new JButton("Sage");
backgroundInnerPanel.add(btnSage);
JButton btnSailor = new JButton("Sailor");
backgroundInnerPanel.add(btnSailor);
JButton btnSoldier = new JButton("Soldier");
backgroundInnerPanel.add(btnSoldier);
JButton btnSpy = new JButton("Spy");
backgroundInnerPanel.add(btnSpy);
JButton btnUrchin = new JButton("Urchin");
backgroundInnerPanel.add(btnUrchin);
JPanel panel = new JPanel();
panel.setBackground(new Color(205, 133, 63));
panel.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
panel.setBounds(324, 132, 396, 264);
panel.setLayout(new BorderLayout(0, 0));
JLabel lblDescription = new JLabel("Description");
lblDescription.setFont(new Font("Lucida Grande", Font.PLAIN, 20));
lblDescription.setHorizontalAlignment(SwingConstants.CENTER);
JTextArea textArea = new JTextArea();
textArea.setBackground(new Color(238, 232, 170));
}
panel.add(lblDescription, BorderLayout.NORTH);
panel.add(textArea, BorderLayout.CENTER);
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));
setLayout(new BorderLayout(0, 0));
innerPanel.add(panel);
JLabel lblNewLabel = createLbl();
add(lblNewLabel, BorderLayout.NORTH);
//Creates back and continue panel
JPanel backContPanel = createBackContinuePanel();
add(backContPanel, BorderLayout.SOUTH);
}
JPanel innerPanel = new JPanel();
innerPanel.setToolTipText("");
innerPanel.setOpaque(false);
add(innerPanel, BorderLayout.CENTER);
innerPanel.setLayout(null);
private JPanel createBackContinuePanel() {
JPanel backContPanel = new JPanel();
backContPanel.setBackground(new Color(205, 133, 63));
JButton backBtn = new JButton("<--- Back ");
backBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
backContPanel.add(backBtn);
JButton continueBtn = new JButton("Continue --->");
continueBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
backContPanel.add(continueBtn);
return backContPanel;
}
/**
* @return
*/
private JLabel createLbl() {
JLabel titleLbl = new JLabel("Step 4: Description");
titleLbl.setHorizontalAlignment(SwingConstants.CENTER);
titleLbl.setFont(new Font("Bodoni 72 Oldstyle", Font.PLAIN, 33));
return titleLbl;
}
JPanel nameAndAlignment = new JPanel();
nameAndAlignment.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
nameAndAlignment.setBackground(new Color(210, 105, 30));
nameAndAlignment.setBounds(6, 6, 306, 114);
innerPanel.add(nameAndAlignment);
nameAndAlignment.setLayout(null);
JLabel nameLbl = new JLabel("Character Name: ");
nameLbl.setBounds(6, 6, 108, 16);
nameAndAlignment.add(nameLbl);
nameTxtField = new JTextField();
nameTxtField.setBounds(121, 1, 173, 26);
nameAndAlignment.add(nameTxtField);
nameTxtField.setColumns(10);
JLabel ageLbl = new JLabel("Age: ");
ageLbl.setBounds(6, 34, 32, 16);
nameAndAlignment.add(ageLbl);
ageTextField = new JTextField();
ageTextField.setBounds(61, 34, 64, 21);
nameAndAlignment.add(ageTextField);
ageTextField.setColumns(10);
JLabel heightLbl = new JLabel("Height: ");
heightLbl.setBounds(6, 62, 55, 16);
nameAndAlignment.add(heightLbl);
heightTxtField = new JTextField();
heightTxtField.setBounds(61, 57, 64, 26);
nameAndAlignment.add(heightTxtField);
heightTxtField.setColumns(10);
JLabel weightLbl = new JLabel("Weight:");
weightLbl.setBounds(6, 90, 61, 16);
nameAndAlignment.add(weightLbl);
weightTxtField = new JTextField();
weightTxtField.setBounds(61, 85, 64, 26);
nameAndAlignment.add(weightTxtField);
weightTxtField.setColumns(10);
JLabel skinLbl = new JLabel("Skin: ");
skinLbl.setBounds(131, 34, 35, 16);
nameAndAlignment.add(skinLbl);
skinTxtField = new JTextField();
skinTxtField.setBounds(165, 29, 130, 26);
nameAndAlignment.add(skinTxtField);
skinTxtField.setColumns(10);
JLabel eyesLbl = new JLabel("Eyes: ");
eyesLbl.setBounds(130, 62, 42, 16);
nameAndAlignment.add(eyesLbl);
eyesTxtField = new JTextField();
eyesTxtField.setBounds(164, 57, 130, 26);
nameAndAlignment.add(eyesTxtField);
eyesTxtField.setColumns(10);
JLabel hairLbl = new JLabel("Hair: ");
hairLbl.setBounds(127, 90, 39, 16);
nameAndAlignment.add(hairLbl);
hairTxtField = new JTextField();
hairTxtField.setBounds(164, 85, 130, 26);
nameAndAlignment.add(hairTxtField);
hairTxtField.setColumns(10);
JPanel alignmentPanel = new JPanel();
alignmentPanel.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
alignmentPanel.setBackground(new Color(205, 133, 63));
alignmentPanel.setBounds(324, 6, 396, 114);
innerPanel.add(alignmentPanel);
alignmentPanel.setLayout(new BorderLayout(0, 0));
JLabel alignmentLbl = new JLabel("Alignment");
alignmentLbl.setFont(new Font("Lucida Grande", Font.PLAIN, 19));
alignmentLbl.setHorizontalAlignment(SwingConstants.CENTER);
alignmentPanel.add(alignmentLbl, BorderLayout.NORTH);
JPanel alignmentInnerPanel = new JPanel();
alignmentInnerPanel.setOpaque(false);
alignmentPanel.add(alignmentInnerPanel, BorderLayout.CENTER);
alignmentInnerPanel.setLayout(new GridLayout(3, 3, 0, 0));
JButton btnLawfulGood = new JButton("Lawful Good");
alignmentInnerPanel.add(btnLawfulGood);
JButton btnNuetralGood = new JButton("Neutral Good");
alignmentInnerPanel.add(btnNuetralGood);
JButton btnChaoticGood = new JButton("Chaotic Good");
alignmentInnerPanel.add(btnChaoticGood);
JButton btnLawfulNeutral = new JButton("Lawful Neutral");
alignmentInnerPanel.add(btnLawfulNeutral);
JButton btnTrueNeutral = new JButton("True Neutral");
alignmentInnerPanel.add(btnTrueNeutral);
JButton btnChaoticNeutral = new JButton("Chaotic Neutral");
alignmentInnerPanel.add(btnChaoticNeutral);
JButton btnLawfulEvil = new JButton("Lawful Evil");
alignmentInnerPanel.add(btnLawfulEvil);
JButton btnNeutralEvil = new JButton("Neutral Evil");
alignmentInnerPanel.add(btnNeutralEvil);
JButton btnChaoticEvil = new JButton("Chaotic Evil");
alignmentInnerPanel.add(btnChaoticEvil);
JPanel backgroundPanel = new JPanel();
backgroundPanel.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
backgroundPanel.setBackground(new Color(210, 105, 30));
backgroundPanel.setBounds(6, 132, 306, 264);
innerPanel.add(backgroundPanel);
backgroundPanel.setLayout(new BorderLayout(0, 0));
JLabel backgroundLbl = new JLabel("Background");
backgroundLbl.setFont(new Font("Dialog", Font.PLAIN, 20));
backgroundLbl.setHorizontalAlignment(SwingConstants.CENTER);
backgroundPanel.add(backgroundLbl, BorderLayout.NORTH);
JPanel backgroundInnerPanel = new JPanel();
backgroundInnerPanel.setOpaque(false);
backgroundPanel.add(backgroundInnerPanel, BorderLayout.CENTER);
backgroundInnerPanel.setLayout(new GridLayout(9, 2, 0, 0));
JButton btnAcolyte = new JButton("Acolyte");
backgroundInnerPanel.add(btnAcolyte);
JButton btnCharlatan = new JButton("Charlatan");
backgroundInnerPanel.add(btnCharlatan);
JButton btnCriminal = new JButton("Criminal");
backgroundInnerPanel.add(btnCriminal);
JButton btnEntertainer = new JButton("Entertainer");
backgroundInnerPanel.add(btnEntertainer);
JButton btnFolkHero = new JButton("Folk Hero");
backgroundInnerPanel.add(btnFolkHero);
JButton btnGladiator = new JButton("Gladiator");
backgroundInnerPanel.add(btnGladiator);
JButton btnGuildArtisan = new JButton("Guild Artisan");
backgroundInnerPanel.add(btnGuildArtisan);
JButton btnGuildMerchant = new JButton("Guild Merchant");
backgroundInnerPanel.add(btnGuildMerchant);
JButton btnHermit = new JButton("Hermit");
backgroundInnerPanel.add(btnHermit);
JButton btnKnight = new JButton("Knight");
backgroundInnerPanel.add(btnKnight);
JButton btnNoble = new JButton("Noble");
backgroundInnerPanel.add(btnNoble);
JButton btnOutlander = new JButton("Outlander");
backgroundInnerPanel.add(btnOutlander);
JButton btnPirate = new JButton("Pirate");
backgroundInnerPanel.add(btnPirate);
JButton btnSage = new JButton("Sage");
backgroundInnerPanel.add(btnSage);
JButton btnSailor = new JButton("Sailor");
backgroundInnerPanel.add(btnSailor);
JButton btnSoldier = new JButton("Soldier");
backgroundInnerPanel.add(btnSoldier);
JButton btnSpy = new JButton("Spy");
backgroundInnerPanel.add(btnSpy);
JButton btnUrchin = new JButton("Urchin");
backgroundInnerPanel.add(btnUrchin);
JPanel panel = new JPanel();
panel.setBackground(new Color(205, 133, 63));
panel.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null, null));
panel.setBounds(324, 132, 396, 264);
panel.setLayout(new BorderLayout(0, 0));
JLabel lblDescription = new JLabel("Description");
lblDescription.setFont(new Font("Lucida Grande", Font.PLAIN, 20));
lblDescription.setHorizontalAlignment(SwingConstants.CENTER);
JTextArea textArea = new JTextArea();
textArea.setBackground(new Color(238, 232, 170));
panel.add(lblDescription, BorderLayout.NORTH);
panel.add(textArea, BorderLayout.CENTER);
innerPanel.add(panel);
}
private JPanel createBackContinuePanel() {
JPanel backContPanel = new JPanel();
backContPanel.setBackground(new Color(205, 133, 63));
JButton backBtn = new JButton("<--- Back ");
backBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
backContPanel.add(backBtn);
JButton continueBtn = new JButton("Continue --->");
continueBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
}
});
backContPanel.add(continueBtn);
return backContPanel;
}
/**
* @return
*/
private JLabel createLbl() {
JLabel titleLbl = new JLabel("Step 4: Description");
titleLbl.setHorizontalAlignment(SwingConstants.CENTER);
titleLbl.setFont(new Font("Bodoni 72 Oldstyle", Font.PLAIN, 33));
return titleLbl;
}
}
@@ -16,11 +16,11 @@ public class BasicNavPanel extends JPanel implements AppTheme {
public BasicNavPanel(DefaultButton backButton, DefaultButton continueButton, int continueRequirement) {
super(new GridLayout(1, 2, 30, 0));
this.backButton = backButton;
this.continueButton = continueButton;
this.backButton = backButton;
this.continueButton = continueButton;
this.continueRequirement = continueRequirement;
createNavPanel();
this.continueRequirement = continueRequirement;
createNavPanel();
}
@@ -58,17 +58,17 @@ public class BasicNavPanel extends JPanel implements AppTheme {
setBorder(new EmptyBorder(15, 150, 15, 150));
add(backButton);
if(continueRequirement == 0) {
if (continueRequirement == 0) {
add(continueButton);
} else {
DefaultButton requiredStepsNeeds = new DefaultButton(Integer.toString(continueRequirement) + " Points Left");
requiredStepsNeeds.select();
requiredStepsNeeds.setBorder(new LineBorder(lightAccent, 1));
requiredStepsNeeds.setBorderPainted(true);
requiredStepsNeeds.setEnabled(false);
requiredStepsNeeds.select();
requiredStepsNeeds.setBorder(new LineBorder(lightAccent, 1));
requiredStepsNeeds.setBorderPainted(true);
requiredStepsNeeds.setEnabled(false);
add(requiredStepsNeeds);
}
@@ -14,8 +14,8 @@ public class DefaultButton extends JButton implements AppTheme {
public DefaultButton(String buttonLabel) {
super(buttonLabel);
applyDefaultButtonStyle();
applyCommon();
applyDefaultButtonStyle();
applyCommon();
}
@@ -42,23 +42,32 @@ public class DefaultButton extends JButton implements AppTheme {
private void applyFocusedButtonStyle() {
setBackground(darkestBrown);
setForeground(lightAccent);
setBackground(darkestBrown);
setForeground(lightAccent);
}
private void applyCommon() {
addMouseListener(
new MouseListener() {
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 {
}
}
@@ -42,7 +42,7 @@ public class ImageInfoPanel extends InfoPanel implements AppTheme {
}*/
lastIndex = newIndex;
lastIndex = newIndex;
return newIndex;
@@ -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() + "\\");
@@ -78,7 +78,7 @@ public class ImageInfoPanel extends InfoPanel implements AppTheme {
} else if (OS.startsWith("Linux")) {
imagesDir = new File("dndBuilder/src/Resources/Img/" + category + "/" + categoryHolder[i].toLowerCase() + "/");
imagesDir = new File("dndBuilder/src/Resources/Img/" + category + "/" + categoryHolder[i].toLowerCase() + "/");
} else {
@@ -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 {
@@ -22,14 +17,14 @@ public class InfoPanel extends JPanel implements AppTheme {
public InfoPanel(String[] categoryHolder, String[] holderDescriptions, Rectangle[] bounds, int panelIndex) {
super();
this.categoryHolder = categoryHolder;
this.holderDescriptions = holderDescriptions;
this.bounds = bounds;
this.panelIndex = panelIndex;
this.categoryHolder = categoryHolder;
this.holderDescriptions = holderDescriptions;
this.bounds = bounds;
this.panelIndex = panelIndex;
panelSetup();
panelSetup();
createDescriptions();
createDescriptions();
}
@@ -63,13 +58,13 @@ public class InfoPanel extends JPanel implements AppTheme {
setLayout(null);
JLabel subHeader = new JLabel("Description");
subHeader.setFont(subHeaderFont);
subHeader.setHorizontalAlignment(SwingConstants.LEFT);
subHeader.setBounds(bounds[1]);
subHeader.setForeground(darkestBrown);
subHeader.setFont(subHeaderFont);
subHeader.setHorizontalAlignment(SwingConstants.LEFT);
subHeader.setBounds(bounds[1]);
subHeader.setForeground(darkestBrown);
add(subHeader);
}
private void createDescriptions() {
@@ -79,17 +74,17 @@ public class InfoPanel extends JPanel implements AppTheme {
for (int i = 0; i < holderDescriptions.length; i++) {
JTextArea tmpDesc = new JTextArea();
tmpDesc.setText(holderDescriptions[i]);
tmpDesc.setWrapStyleWord(true);
tmpDesc.setLineWrap(true);
tmpDesc.setOpaque(true);
tmpDesc.setEditable(false);
tmpDesc.setFocusable(false);
tmpDesc.setFont(paragraphFont);
tmpDesc.setBounds(bounds[2]);
tmpDesc.setBorder(new EmptyBorder(5, 5, 5, 5));
tmpDesc.setBackground(medBrown);
tmpDesc.setForeground(darkestBrown);
tmpDesc.setText(holderDescriptions[i]);
tmpDesc.setWrapStyleWord(true);
tmpDesc.setLineWrap(true);
tmpDesc.setOpaque(true);
tmpDesc.setEditable(false);
tmpDesc.setFocusable(false);
tmpDesc.setFont(paragraphFont);
tmpDesc.setBounds(bounds[2]);
tmpDesc.setBorder(new EmptyBorder(5, 5, 5, 5));
tmpDesc.setBackground(medBrown);
tmpDesc.setForeground(darkestBrown);
descriptions[i] = tmpDesc;
@@ -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);
}
}
+1 -1
View File
@@ -3,7 +3,7 @@ package Tests;
public class dndTestClient {
// Antiquated test, need to refactor for new project setup.
// Antiquated test, need to refactor for new project setup.
/* public static void main(String[] args) {
// TODO Auto-generated method stub