diff --git a/src/App.java b/src/App.java new file mode 100644 index 0000000..2f5ae8d --- /dev/null +++ b/src/App.java @@ -0,0 +1,12 @@ +public class App { + + public static void main(String[] args) { + + FileManager data = new FileManager(); + + GUImanager gui = new GUImanager(data.isReturninguser()); + gui.setVisible(true); + + } + +} diff --git a/src/AppTheme.java b/src/AppTheme.java new file mode 100644 index 0000000..51e336f --- /dev/null +++ b/src/AppTheme.java @@ -0,0 +1,28 @@ +import java.awt.*; + +public interface AppTheme { + + public Color lightAccent = Color.decode("#EAF0CE"); + public Color lightBrown = Color.decode("#EBBE9B"); + public Color medBrown = Color.decode("#E4A677"); + + public Color darkBrown = Color.decode("#502419"); + + public Color darkestBrown = Color.decode("#1F0E0A"); + + public Color black = Color.BLACK; + + public Color confirmationBlue = Color.decode("#296EB4"); + + public Color rejectionRed = Color.decode("#A23E48"); + + public Font headerFont = new Font("SanSalvi", Font.BOLD, 45); + public Font subHeaderFont = new Font("SanSalvi", Font.PLAIN, 35); + + public Font paragraphFont = new Font("SanSalvi", Font.PLAIN, 20); + public Font userTextFont = new Font("SanSalvi", Font.PLAIN, 15); + public Font buttonFont = new Font("SanSalvi", Font.PLAIN, 15); + + public String OS = System.getProperty("os.name"); + +} diff --git a/src/Background.java b/src/Background.java new file mode 100644 index 0000000..4126352 --- /dev/null +++ b/src/Background.java @@ -0,0 +1,152 @@ +public class Background { + + int backgroundIndex; + private String name; + private boolean[] proficientStatus; + private String[] skills; + private String feature; + private String skillProficiencies; + + /** + * @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 guild’s 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 guild’s 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 guild’s 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 guild’s 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; + } + + +} diff --git a/src/BasicNavPanel.java b/src/BasicNavPanel.java new file mode 100644 index 0000000..f0b2414 --- /dev/null +++ b/src/BasicNavPanel.java @@ -0,0 +1,74 @@ +import javax.swing.*; +import javax.swing.border.EmptyBorder; +import javax.swing.border.LineBorder; +import java.awt.*; + +public class BasicNavPanel extends JPanel implements AppTheme { + + private DefaultButton backButton; + private DefaultButton continueButton; + private int continueRequirement; + + public BasicNavPanel(DefaultButton backButton, DefaultButton continueButton, int continueRequirement) { + + super(new GridLayout(1, 2, 30, 0)); + this.backButton = backButton; + this.continueButton = continueButton; + + this.continueRequirement = continueRequirement; + createNavPanel(); + + } + + public int getContinueRequirement() { + + return continueRequirement; + + } + + public void decreaseContinueRequirement(int value) { + + continueRequirement -= value; + updateContinueRequirement(); + + } + + public void increaseContinueRequirement(int value) { + + continueRequirement += value; + updateContinueRequirement(); + + } + + private void updateContinueRequirement() { + + removeAll(); + + createNavPanel(); + + } + + private void createNavPanel() { + + setBackground(darkestBrown); + setBorder(new EmptyBorder(15, 150, 15, 150)); + add(backButton); + + 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); + add(requiredStepsNeeds); + + } + + } + +} diff --git a/src/BasicPanel.java b/src/BasicPanel.java new file mode 100644 index 0000000..93ef3b6 --- /dev/null +++ b/src/BasicPanel.java @@ -0,0 +1,121 @@ +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; + + public BasicPanel(JPanel navPanel, String[] options, String[] descriptions, String panelTitle) { + + super(); + this.options = options; + this.panelTitle = panelTitle; + + 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) + + }; + + this.infoPanel = new ImageInfoPanel(options, descriptions, basicBounds, Integer.parseInt(Character.toString(panelTitle.charAt(5)))); + infoPanel.updateInfo(0); // Default start with 0th element. + + choiceIndex = 0; + + panelSetup(); + createMasterPanel(); + add(navPanel, BorderLayout.SOUTH); + + } + + private void panelSetup() { + + setBackground(lightBrown); + setLayout(new BorderLayout(0, 0)); + + } + + private void createMasterPanel() { + + 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()); + + add(panel); + + } + + private JPanel createButtonPanel() { + + JPanel buttonPanel = new JPanel(new GridLayout(options.length, 1, 0, 0)); + buttonPanel.setBackground(lightBrown); + + buttonPanel.setBounds(585, 45, 135, 355); + + optionButtons = new DefaultButton[options.length]; + + + for (int i = 0; i < optionButtons.length; i++) { + + optionButtons[i] = createButton(options[i], i); + + if (i == 0) { + + optionButtons[i].select(); + + } + + } + + + for (int i = 0; i < options.length; i++) { + + buttonPanel.add(optionButtons[i]); + + } + + return buttonPanel; + + } + + private DefaultButton createButton(String holderName, int index) { + + DefaultButton button = new DefaultButton(holderName); + button.addActionListener(e -> updateButtons(index)); + + return button; + + } + + private void updateButtons(int newIndex) { + + optionButtons[choiceIndex].deSelect(); + optionButtons[newIndex].select(); + + choiceIndex = newIndex; + infoPanel.updateInfo(choiceIndex); + + } + + public int getChoice() { + + return choiceIndex; + + } + +} diff --git a/src/CharacterSheet.java b/src/CharacterSheet.java new file mode 100644 index 0000000..8690f9b --- /dev/null +++ b/src/CharacterSheet.java @@ -0,0 +1,116 @@ +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 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; + } + + 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(); + } + +} diff --git a/src/CharacterStats.java b/src/CharacterStats.java new file mode 100644 index 0000000..4c12ef7 --- /dev/null +++ b/src/CharacterStats.java @@ -0,0 +1,79 @@ +public class CharacterStats { + + private Stats[] stats; + + public CharacterStats() { + + stats = new Stats[]{}; + + } + + // 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) + + }; + + } + + public CharacterStats(Strength str, Dexterity dex, Constitution con, Intelligence intel, Wisdom wis, Charisma cha) { + + this.stats = new Stats[]{str, dex, con, intel, wis, cha}; + + } + + // TODO: Need to implement ability score validation. + public boolean validateAbilityScore(int abilityScore) { + + return false; + + } + + public Stats[] getStats() { + + return stats; + + } + + /** + * Allows for access to a particular stat. + * + * @param index + * @return a specific stat + */ + public Stats getStats(int index) { + + return stats[index]; + + } + + public void increaseStat(int targetStat) { + + stats[targetStat].increaseScore(); + + } + + @Override + public String toString() { + + String statsString = ""; + + for (int i = 0; i < stats.length; i++) { + + statsString = statsString.concat(stats[i].getClass().getSimpleName() + ": " + stats[i].getScore() + " | "); + + } + + return statsString; + + } + +} diff --git a/src/Charisma.java b/src/Charisma.java new file mode 100644 index 0000000..c9dde3a --- /dev/null +++ b/src/Charisma.java @@ -0,0 +1,53 @@ +public class Charisma extends Stats { + + private int abilityScore; + private int abilityScoreModifier; + + public Charisma(int abilityScore) { + + this.abilityScore = abilityScore; + this.abilityScoreModifier = calcSavingThrow(abilityScore); + + } + + public int getScore() { + + return abilityScore; + + } + + public int getModifier() { + + return abilityScoreModifier; + + } + + public int getSavingThrow() { + + return getModifier(); + + } + + // TODO: Need description. + public String getDescription() { + + return "Confidence, eloquence, and leadership."; + + } + + @Override + public String toString() { + + return "Ability Score: " + abilityScore + " | Modifier: " + abilityScoreModifier + " | Description: " + + getDescription(); + + } + + @Override + public void increaseScore() { + + abilityScore++; + + } + +} diff --git a/src/ChooseAbilityScoresPanel.java b/src/ChooseAbilityScoresPanel.java new file mode 100644 index 0000000..b43375f --- /dev/null +++ b/src/ChooseAbilityScoresPanel.java @@ -0,0 +1,231 @@ +import javax.swing.*; +import javax.swing.border.LineBorder; +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; + + 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; + + 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 + + }; + + infoPanel = new InfoPanel(statOptions, statDescriptions, abilityScoreBounds, 3); + infoPanel.updateInfo(0); // Default start with 0th element. + + createMasterPanel(panelTitle); + add(basicNavPanel, BorderLayout.SOUTH); + + } + + private void panelSetup() { + + setBackground(lightBrown); + setLayout(new BorderLayout(0, 0)); + + } + + private void createMasterPanel(String panelTitle) { + + 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); + + add(panel); + + } + + private JPanel createAbilityScorePanels() { + + 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++) { + + mainAbilityPanel.add(createAbilityPanel(statOptions[i], i)); + + } + + 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)); + + DefaultButton tmpButton = new DefaultButton(ability); + tmpButton.setFont(paragraphFont); + tmpButton.setHorizontalAlignment(SwingConstants.CENTER); + tmpButton.addActionListener(e -> updateButtons(statIndex)); + + statInfoButtons[statIndex] = tmpButton; + + panel.add(statInfoButtons[statIndex], BorderLayout.NORTH); + + panel.add(createScorePanel(statIndex)); + + return panel; + + } + + private JPanel createScorePanel(int statIndex) { + + JPanel subPanel = new JPanel(); + + JLabel scoreLabel = new JLabel("" + selectedStats[statIndex]); + scoreLabel.setFont(paragraphFont); + scoreLabel.setHorizontalAlignment(SwingConstants.CENTER); + + statLabels[statIndex] = scoreLabel; + + + DefaultButton increaseButton = new DefaultButton("+"); + increaseButton.addActionListener(e -> increase(statIndex)); + + DefaultButton decreaseButton = new DefaultButton("-"); + decreaseButton.addActionListener(e -> decrease(statIndex)); + + subPanel.add(decreaseButton); + subPanel.add(scoreLabel); + subPanel.add(increaseButton); + + subPanel.setBackground(lightBrown); + + return subPanel; + + } + + private int statCostCalculator(int statIndex, boolean isDecreasing) { + + int cost = 0; + + int currentStatValue = selectedStats[statIndex]; + + if (isDecreasing) { + + if (currentStatValue <= 8) { + System.out.println("registered invalid decrease"); + + return -1; + + } + + if (currentStatValue < 14) { + + cost = 1; + + } else if (currentStatValue == 14 || currentStatValue == 15) { + + cost = 2; + + } + + } else { + + if (currentStatValue < 13) { + + cost = 1; + + } else if (currentStatValue == 13 || currentStatValue == 14) { + + cost = 2; + + } else { + System.out.println("registered invalid increase"); + return -1; + + } + + } + + return cost; + + } + + private void increase(int statIndex) { + + int value = statCostCalculator(statIndex, false); + + if (value == -1) { + + return; + + } + + if (basicNavPanel.getContinueRequirement() - value >= 0) { + + selectedStats[statIndex]++; + statLabels[statIndex].setText("" + selectedStats[statIndex]); + + basicNavPanel.decreaseContinueRequirement(value); + + } + + } + + private void decrease(int statIndex) { + + int value = statCostCalculator(statIndex, true); + + if (value == -1) { + + return; + + } + + if (basicNavPanel.getContinueRequirement() + value <= 27) { + + selectedStats[statIndex]--; + statLabels[statIndex].setText("" + selectedStats[statIndex]); + + basicNavPanel.increaseContinueRequirement(value); + + } + + } + + private void updateButtons(int newIndex) { + + statInfoButtons[selectedStatIndex].deSelect(); + statInfoButtons[newIndex].select(); + + selectedStatIndex = newIndex; + infoPanel.updateInfo(selectedStatIndex); + + } + +} diff --git a/src/ClassTemplate.java b/src/ClassTemplate.java new file mode 100644 index 0000000..c71be82 --- /dev/null +++ b/src/ClassTemplate.java @@ -0,0 +1,35 @@ +public interface ClassTemplate { + + abstract String getDescription(); + + abstract String[] getProgression(); + + abstract String[] getClassFeatures(); + + abstract String getHitDie(); + + abstract int getHPatLv1(); + + abstract int getHPpastLv1(); + + abstract String[] getArmorProf(); + + abstract String[] getWeaponProf(); + + abstract String[] getToolProf(); + + abstract String[] getSavingThrows(); + +// TODO: Need to refresh on how saving throws work and how the character's class may impact a saving throw. + + abstract String[] availableSkills(); + + abstract String[] startingEquipChoices(); + + abstract boolean advantageCheck(Stats abilityScore); + + abstract boolean disadvantageCheck(Stats abilityScore); + +// TODO: Spells and shit. + +} diff --git a/src/Cleric.java b/src/Cleric.java new file mode 100644 index 0000000..03ecb36 --- /dev/null +++ b/src/Cleric.java @@ -0,0 +1,88 @@ +public class Cleric implements ClassTemplate { + + private int HP; + + private int level; + + // 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? + + public String getDescription() { + // TODO Auto-generated method stub + return null; + } + + public String[] getProgression() { + // TODO Auto-generated method stub + return null; + } + + public String[] getClassFeatures() { + // TODO Auto-generated method stub + return null; + } + + public String getHitDie() { + // TODO Auto-generated method stub + return null; + } + + public int getHPatLv1() { + // TODO Auto-generated method stub + return 0; + } + + public int getHPpastLv1() { + // TODO Auto-generated method stub + return 0; + } + + public String[] getArmorProf() { + // TODO Auto-generated method stub + return null; + } + + public String[] getWeaponProf() { + // TODO Auto-generated method stub + return null; + } + + public String[] getToolProf() { + // TODO Auto-generated method stub + return null; + } + + public String[] availableSkills() { + // TODO Auto-generated method stub + return null; + } + + public String[] startingEquipChoices() { + // TODO Auto-generated method stub + return null; + } + + public boolean advantageCheck(Stats abilityScore) { + // TODO Auto-generated method stub + return false; + } + + public boolean disadvantageCheck(Stats abilityScore) { + // TODO Auto-generated method stub + return false; + } + + @Override + public String[] getSavingThrows() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/Constitution.java b/src/Constitution.java new file mode 100644 index 0000000..36db985 --- /dev/null +++ b/src/Constitution.java @@ -0,0 +1,53 @@ +public class Constitution extends Stats { + + private int abilityScore; + private int abilityScoreModifier; + + public Constitution(int abilityScore) { + + this.abilityScore = abilityScore; + this.abilityScoreModifier = calcSavingThrow(abilityScore); + + } + + public int getScore() { + + return abilityScore; + + } + + public int getModifier() { + + return abilityScoreModifier; + + } + + public int getSavingThrow() { + + return getModifier(); + + } + + // TODO: Need description. + public String getDescription() { + + return "Health, stamina, vital force."; + + } + + @Override + public String toString() { + + return "Ability Score: " + abilityScore + " | Modifier: " + abilityScoreModifier + " | Description: " + + getDescription(); + + } + + @Override + public void increaseScore() { + + abilityScore++; + + } + +} diff --git a/src/CustomTheme.java b/src/CustomTheme.java new file mode 100644 index 0000000..208d23a --- /dev/null +++ b/src/CustomTheme.java @@ -0,0 +1,12 @@ +import java.awt.*; + +public interface CustomTheme { + + public Color background = null; + public Color foreground = null; + + Color getBackground(); + + Color getForeground(); + +} diff --git a/src/DefaultButton.java b/src/DefaultButton.java new file mode 100644 index 0000000..70cec50 --- /dev/null +++ b/src/DefaultButton.java @@ -0,0 +1,91 @@ +import javax.swing.*; +import javax.swing.border.EmptyBorder; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; + +public class DefaultButton extends JButton implements AppTheme { + + private boolean selected; + + public DefaultButton(String buttonLabel) { + + super(buttonLabel); + applyDefaultButtonStyle(); + applyCommon(); + + } + + public void deSelect() { + + selected = false; + applyDefaultButtonStyle(); + + } + + public void select() { + + selected = true; + applyFocusedButtonStyle(); + + } + + private void applyDefaultButtonStyle() { + + setBackground(medBrown); + setForeground(darkestBrown); + + } + + private void applyFocusedButtonStyle() { + + setBackground(darkestBrown); + setForeground(lightAccent); + + } + + private void applyCommon() { + + addMouseListener( + new MouseListener() { + @Override + public void mouseClicked(MouseEvent e) { + } + + @Override + public void mousePressed(MouseEvent e) { + } + + @Override + public void mouseReleased(MouseEvent e) { + } + + @Override + public void mouseEntered(MouseEvent e) { + applyFocusedButtonStyle(); + } + + @Override + public void mouseExited(MouseEvent e) { + + if (!selected) { + + applyDefaultButtonStyle(); + + } + + } + } + + ); + + setFocusPainted(false); + setFont(buttonFont); + setBorder(new EmptyBorder(3, 3, 3, 3)); + + repaint(); + revalidate(); + + } + + +} diff --git a/src/DescriptionPanel.java b/src/DescriptionPanel.java new file mode 100644 index 0000000..83d296f --- /dev/null +++ b/src/DescriptionPanel.java @@ -0,0 +1,298 @@ +import javax.swing.*; +import javax.swing.border.EmptyBorder; +import javax.swing.border.LineBorder; +import java.awt.*; + +public class DescriptionPanel extends JPanel implements AppTheme { + + private BasicNavPanel nav; + private String[] characteristics; + private String[] characteristicsHolder; + private String[] alignmentOptions; + private String[] alignmentDescriptions; + private String[] backgroundOptions; + private String[] backgroundDescriptions; + private String userBackground; + private DefaultButton[] alignmentButtons; + private DefaultButton[] backgroundButtons; + private int alignmentChoice; + private int backgroundChoice; + + + 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; + + panelSetup(); + + createPanel(panelTitle, nav); + + } + + public String[] getCharacteristics() { + + return characteristics; + + } + + public int getAlignmentChoice() { + + return alignmentChoice; + + } + + public int getBackgroundChoice() { + + return backgroundChoice; + + } + + private void panelSetup() { + + setBackground(lightBrown); + setLayout(new BorderLayout(0, 0)); + + alignmentChoice = 0; + backgroundChoice = 0; + + alignmentButtons = new DefaultButton[alignmentOptions.length]; + backgroundButtons = new DefaultButton[backgroundOptions.length]; + + characteristicsHolder = new String[]{ + + "Name: ", + "Age: ", + "Height: ", + "Weight: ", + "Eyes: ", + "Hair: " + + }; + + userBackground = ""; + + } + + + private void createPanel(String panelTitle, BasicNavPanel nav) { + + add(createPanelTitle(panelTitle), BorderLayout.NORTH); + + add(createBodyPanel(), BorderLayout.CENTER); + + add(nav, BorderLayout.SOUTH); + + } + + 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)); + + return title; + + } + + private JPanel createBodyPanel() { + + GridBagConstraints c = new GridBagConstraints(); + + JPanel bodyPanel = new JPanel(new GridBagLayout()); + bodyPanel.setOpaque(false); + + bodyPanel.add(createNamePanel()); + bodyPanel.add(createFooterPanel()); + + return bodyPanel; + + } + + private JPanel createNamePanel() { + + JPanel panel = new JPanel(); + panel.setBackground(medBrown); + + for (int i = 0; i < characteristicsHolder.length; i++) { + + panel.add(createField(i)); + + } + + return panel; + + } + + private JPanel createField(int index) { + + JPanel panel = new JPanel(); + panel.setOpaque(false); + + 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); + + panel.add(label); + panel.add(field); + + return panel; + + } + + private JPanel createFooterPanel() { + + JPanel panel = new JPanel(new GridLayout(1, 3)); + panel.setOpaque(false); + panel.add(createSubPanel("Alignment")); + panel.add(createSubPanel("Background")); + panel.add(createTextBoxPanel()); + + return panel; + + } + + private JPanel createSubPanel(String labelName) { + + JPanel panel = new JPanel(new BorderLayout(0, 0)); + panel.setBorder(new EmptyBorder(5, 5, 5, 5)); + panel.setOpaque(false); + + JLabel label = new JLabel(labelName); + label.setForeground(darkestBrown); + label.setFont(subHeaderFont); + label.setHorizontalAlignment(SwingConstants.CENTER); + + JPanel innerPanel; + + if(labelName.equals("Alignment")) { + + innerPanel = new JPanel(new GridLayout(9, 1)); + innerPanel.setOpaque(false); + + createButtons(alignmentOptions, alignmentButtons, labelName); + + for (int i = 0; i < alignmentButtons.length; i++) { + + innerPanel.add(alignmentButtons[i]); + + } + + } else { + + innerPanel = new JPanel(new GridLayout(9, 2)); + innerPanel.setOpaque(false); + + createButtons(backgroundOptions, backgroundButtons, labelName); + + for (int i = 0; i < backgroundButtons.length; i++) { + + innerPanel.add(backgroundButtons[i]); + + } + + } + + panel.add(label); + panel.add(innerPanel); + + return panel; + + } + + private JPanel createTextBoxPanel() { + + JPanel panel = new JPanel(new BorderLayout(0, 0)); + panel.setOpaque(false); + + 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)); + + panel.add(label); + panel.add(textArea); + + return panel; + + } + + private void updateAlignmentButtons(int newIndex) { + + alignmentButtons[alignmentChoice].deSelect(); + alignmentButtons[newIndex].select(); + + alignmentChoice = newIndex; + + System.out.println("Updating alignment to index " + newIndex + ", " + alignmentOptions[newIndex]); + + } + + private void updateBackgroundButtons(int newIndex) { + + backgroundButtons[backgroundChoice].deSelect(); + backgroundButtons[newIndex].select(); + + backgroundChoice = newIndex; + + System.out.println("Updating background to index " + newIndex + ", " + backgroundOptions[newIndex]); + + + } + + 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)); + + } else { + + button.addActionListener(e -> updateBackgroundButtons(index)); + + } + + return button; + + } + +} diff --git a/src/Dexterity.java b/src/Dexterity.java new file mode 100644 index 0000000..404e452 --- /dev/null +++ b/src/Dexterity.java @@ -0,0 +1,53 @@ +public class Dexterity extends Stats { + + private int abilityScore; + private int abilityScoreModifier; + + public Dexterity(int abilityScore) { + + this.abilityScore = abilityScore; + this.abilityScoreModifier = calcSavingThrow(abilityScore); + + } + + public int getScore() { + + return abilityScore; + + } + + public int getModifier() { + + return abilityScoreModifier; + + } + + public int getSavingThrow() { + + return getModifier(); + + } + + // TODO: Need description. + public String getDescription() { + + return ""; + + } + + @Override + public String toString() { + + return "Ability Score: " + abilityScore + " | Modifier: " + abilityScoreModifier + " | Description: " + + getDescription(); + + } + + @Override + public void increaseScore() { + + abilityScore++; + + } + +} diff --git a/src/Dragonborn.java b/src/Dragonborn.java new file mode 100644 index 0000000..9e4413a --- /dev/null +++ b/src/Dragonborn.java @@ -0,0 +1,70 @@ +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[]{}; + } + + @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 getSpeed() { + // TODO Auto-generated method stub + return speed; + } + + @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[] getLanguages() { + // TODO Auto-generated method stub + return languages; + } + + @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}; + } + + @Override + public String toString() { + // TODO Auto-generated method stub + return this.getClass().getSimpleName(); + } + +} diff --git a/src/Dwarf.java b/src/Dwarf.java new file mode 100644 index 0000000..84e2ab7 --- /dev/null +++ b/src/Dwarf.java @@ -0,0 +1,70 @@ +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[]{}; + } + + @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 getSpeed() { + // TODO Auto-generated method stub + return speed; + } + + @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[] getLanguages() { + // TODO Auto-generated method stub + return languages; + } + + @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}; + } + + @Override + public String toString() { + // TODO Auto-generated method stub + return this.getClass().getSimpleName(); + } + +} diff --git a/src/Elf.java b/src/Elf.java new file mode 100644 index 0000000..1373504 --- /dev/null +++ b/src/Elf.java @@ -0,0 +1,70 @@ +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[]{}; + } + + @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 getSpeed() { + // TODO Auto-generated method stub + return speed; + } + + @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[] getLanguages() { + // TODO Auto-generated method stub + return languages; + } + + @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}; + } + + @Override + public String toString() { + // TODO Auto-generated method stub + return this.getClass().getSimpleName(); + } + +} diff --git a/src/ExportPDF.java b/src/ExportPDF.java new file mode 100644 index 0000000..373f857 --- /dev/null +++ b/src/ExportPDF.java @@ -0,0 +1,8 @@ +public class ExportPDF { + + public ExportPDF() { + + + } + +} diff --git a/src/Fighter.java b/src/Fighter.java new file mode 100644 index 0000000..f8c7ce5 --- /dev/null +++ b/src/Fighter.java @@ -0,0 +1,88 @@ +public class Fighter implements ClassTemplate { + + private int HP; + + private int level; + + // 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? + + public String getDescription() { + // TODO Auto-generated method stub + return null; + } + + public String[] getProgression() { + // TODO Auto-generated method stub + return null; + } + + public String[] getClassFeatures() { + // TODO Auto-generated method stub + return null; + } + + public String getHitDie() { + // TODO Auto-generated method stub + return null; + } + + public int getHPatLv1() { + // TODO Auto-generated method stub + return 0; + } + + public int getHPpastLv1() { + // TODO Auto-generated method stub + return 0; + } + + public String[] getArmorProf() { + // TODO Auto-generated method stub + return null; + } + + public String[] getWeaponProf() { + // TODO Auto-generated method stub + return null; + } + + public String[] getToolProf() { + // TODO Auto-generated method stub + return null; + } + + public String[] availableSkills() { + // TODO Auto-generated method stub + return null; + } + + public String[] startingEquipChoices() { + // TODO Auto-generated method stub + return null; + } + + public boolean advantageCheck(Stats abilityScore) { + // TODO Auto-generated method stub + return false; + } + + public boolean disadvantageCheck(Stats abilityScore) { + // TODO Auto-generated method stub + return false; + } + + @Override + public String[] getSavingThrows() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/FileManager.java b/src/FileManager.java new file mode 100644 index 0000000..75be41b --- /dev/null +++ b/src/FileManager.java @@ -0,0 +1,115 @@ +import java.awt.*; +import java.io.*; + +public class FileManager { + + private File[] savedCharacters; + + public FileManager() { + + findSavedCharacters(); + + loadFonts(); + + } + + private void loadFonts() { + + try { + GraphicsEnvironment ge = + GraphicsEnvironment.getLocalGraphicsEnvironment(); + ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, new File("SanSalvi.ttf"))); + } catch (IOException | FontFormatException e) { + //Handle exception + System.out.println("Error finding font."); + } + + } + + public boolean isReturninguser() { + + if (savedCharacters == null) { + + return false; + + } + + return savedCharacters.length > 0; + + } + + public CharacterSheet readCharacter(int index) { + + CharacterSheet sheet = null; + + try { + + FileInputStream fileIn = new FileInputStream("/dndBuilder/" + savedCharacters[index].getPath() + ".dnd"); + ObjectInputStream in = new ObjectInputStream(fileIn); + sheet = (CharacterSheet) in.readObject(); + in.close(); + fileIn.close(); + + } catch (IOException i) { + + i.printStackTrace(); + + } catch (ClassNotFoundException c) { + + System.out.println("Saved characters not found"); + c.printStackTrace(); + + } + + return sheet; + + } + + public void saveCharacter(CharacterSheet completedCharacter) { + + try { + + FileOutputStream fileOut = + new FileOutputStream("/dndBuilder/" + completedCharacter.getName().hashCode() + ".dnd"); + ObjectOutputStream out = new ObjectOutputStream(fileOut); + out.writeObject(completedCharacter); + out.close(); + fileOut.close(); + + } catch (IOException i) { + + i.printStackTrace(); + + } + + findSavedCharacters(); + + } + + public void deleteCharacter(int index) { + + File[] tmp = new File[savedCharacters.length - 1]; + + for (int i = 0; i < savedCharacters.length; i++) { + + if (i != index) { + + tmp[i] = savedCharacters[i]; + + } + + } + + savedCharacters = tmp; + + findSavedCharacters(); + + } + + private void findSavedCharacters() { + + savedCharacters = new File("/dndBuilder").listFiles(); + + } + +} diff --git a/src/GUImanager.java b/src/GUImanager.java new file mode 100644 index 0000000..8455776 --- /dev/null +++ b/src/GUImanager.java @@ -0,0 +1,395 @@ +import javax.swing.*; +import java.awt.*; + +public class GUImanager extends JFrame { + + private static JPanel[] panels; + 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 String[] statOptions; + private String[] statDescriptions; + private String[] characteristics; + private String[] alignmentOptions; + private String[] alignmentDescriptions; + private String[] backgroundOptions; + private String[] backgroundDescriptions; + private int[] selectedStats; + + + public GUImanager(boolean returningUser) { + super("D&D Character Builder"); + frameSetup(); + 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;*/ + + if (returningUser) { + + this.currentPanel = 0; + + } else { + + this.currentPanel = 1; + + } + + add(panels[currentPanel]); + + } + + private void frameSetup() { + + setDefaultCloseOperation(EXIT_ON_CLOSE); + setLayout(new BorderLayout()); + setPreferredSize(new Dimension(750, 550)); + setSize(getPreferredSize()); +// setResizable(false); + setLocationRelativeTo(null); + + try { + UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); + } catch (Exception e) { + System.out.println("Error with cross platform look/feel in frameSetup()."); + } + + } + + private void setupPanelInfo() { + + raceOptions = new String[]{ + "Dragonborn", + "Dwarf", + "Elf", + "Gnome", + "HalfElf", + "Halfling", + "Halforc", + "Human", + "Tiefling" + }; + + raceDescriptions = new String[]{ + + "Born of dragons, as their name proclaims, the dragonborn walk proudly through a world that greets them with fearful incomprehension." + "Shaped by draconic gods or the dragons themselves, dragonborn originally hatched from dragon eggs as a unique race, combining the best attributes of dragons and humanoids." + "Some dragonborn are faithful servants to true dragons, others form the ranks of soldiers in great wars, and still others find themselves adrift, with no clear calling in life.", + "By the numbers, dwarves are one of the best races in the Player’s Handbook. " + "" + "Their ability score increases are good, and their other racial traits make them durable and flexible enough to succeed in several classes.", + "A staple of fantasy fiction and folklore, Elves are a simple yet effective base race with subraces which are numerous and diverse enough that elves are usable in a variety of builds and character concepts. " + "Unfortunately, because the subraces differentiate the Elf’s traits so much, it’s rare for more than one subrace to be viable in the same class unless you’re using the Customizing Your Origins optional rules presented in Tasha’s Cauldron of Everything.", + "Gnomes have changed a lot throughout the history of Dungeons and Dragons. " + "At times they’ve been monsters. " + "At times they’ve been fey. " + "In general, DnD has always had trouble pinning down gnomes thematically in a way that distinguishes them from halflings, but I think 5th edition may have done the best job of any edition to date. " + "Gnomes have subraces which are very distinct from one another, and their traits offer some unique an interesting options.", + "The Half-Elf is among the most powerful races in the core rules. " + "It’s a top-tier race option for several classes, and even for classes where the Half-Elf isn’t a perfect fit it’s at least workable. " + "Two flexible ability increases and two free skill proficiencies are useful on essentially any character, plus you get Darkvision and a +2 Charisma increase.", + "Half-orcs are an easily-overlooked race. " + "Their racial traits tend to pigeon-hole them into simple martial builds, and in most official settings and works of fiction outside of D&D orcs have historically been portrayed barbaric savages, so even characters’ backstories tend to be forced into an incredibly narrow set of options. " + "Half-orcs don’t get subraces, and unlike the half-elf we haven’t seen variants of any kind, so the race offers little flexibility.", + "Halflings are perhaps the most iconic small race in Dungeons and Dragons, dating back to its earliest editions. " + "Their mechanics have changed as much as any race, but they have consistently remained a staple option for players who enjoy playing thieves, rogues, or other stealthy characters.", + "Human come in two flavors: the standard human and the “variant” human. " + "The standard human receives +1 increases to each ability score, making it easy to fit into any build. " + "However, it lacks any other racial traits, which makes the standard human extremely bland. " + "It also lacks the numerical appeal of a +2 ability increase, so more focused races will frequently outpace the standard human in nearly every case.", + "Thanks to the variants presented in Sword Coast Adventurer’s Guide and the subraces presented in Mordenkainen’s Tome of Foes, the Tiefling has the longest list of subrace options of any published race, totaling an impressive 14 individual subraces and variants. " + "These options make tieflings diverse, flexible, and viable in an impressively large number of builds." + + }; + + classOptions = new String[]{ + + "Artificer", + "Barbarian", + "Bard", + "Cleric", + "Druid", + "Fighter", + "Monk", + "Paladin", + "Ranger", + "Rogue", + "Sorcerer", + "Warlock", + "Wizard" + + }; + + classDescriptions = new String[]{ + + "The Artificer is a class with a tool for every job and a solution to every problem. " + "They excel as a Support character, but make decent Defenders, Healers, and Strikers, too. " + "With the right infusions and spells, they can fill nearly any role in the party, making the Artificer’s versatility rival that of the Bard.", + "Barbarians are all about getting angry and dealing damage. " + "They have a ton of hit points, resistance to damage, and Rage gives a wonderful bonus to damage. " + "Barbarians don’t get much in the way of skills, so generally they’re stuck as combat monsters, but they function equally well as a Defender and a Striker, and certain character options can even expand them into a limited Support role.", + "The Bard is fantastically versatile. " + "With access to every skill, expertise, full casting, and a decent set of proficiencies, the Bard can fill essentially every role in the party. " + "Subclasses like College of Lore are more of the classic supportive Bard, with improved magical options and support abilities, while College of Swords and College of Valor can serve as front-line melee characters who can bring their spellcasting and support capabilities into the heat of battle.", + "Clerics are among the most diverse and interesting classes in 5e DnD. " + "Because your choice of Divine Domain so greatly affects your capabilities, Clerics can fit a variety of roles and play styles. " + "More generally, Clerics are the best healers in the game, and have among the best support, utility, and divination options in the game. " + "However, they are by no means limited to healing and support roles. " + "Clerics have abundant offensive options, and can even be effective with weapons.", + "Druids are a very versatile class. " + "Between their available archetypes, they’re able to serve mixes roles as scouts, strikers, blaster, support casters, and controllers. " + "Their spell list has a lot of unique options. " + "There is a strong emphasis on area control spells, and most of the Druid’s best spells require Concentration.", + "The Fighter is a fantastic addition to any party. " + "While their skill and tool proficiencies are extremely limited, Fighters excel in combat. " + "They are durable, have great armor, and provide plenty of damage output. " + "Fighters get more Ability Score Increases than any other class, allowing them to easily explore feats without sacrificing crucial ability scores. " + "They also notably get more attacks than any other class, which can be a lot of fun.", + "The Monk is the iconic martial-artist, popular among those who prefer to punch things rather than stabbing them or setting them on fire (though stabbing things and setting them on fire is still a possibility for the Monk). " + "Monks are excellent Defenders and Strikers, and typically fill a role in party as a Fighter-equivalent or Rogue-equivalent depending on your subclass and proficiencies.", + "Paladins are the most durable, survivable, and self-sufficient class in the game. " + "As such, they both make excellent solo characters and are excellent additions to nearly any party regardless of existing capabilities. " + "In a party, they serve as a Defender, Face, and Striker. " + "They do have some healing and utility options, but not enough to replace a full spellcaster in most parties.", + "The Ranger is an interesting mix of Druid-style spellcasting, Fighter-style combat capabilities, and Rogue-style skills. " + "Themed around nature and exploration, the Ranger is a welcome asset in parties exploring untamed lands above or below ground. " + "The Ranger can fill the role of either a Fighter-equivalent or a Rogue-equivalent (sometimes both), and works well as a Scout and Striker, but trades the Fighter’s durability for better skills and improved damage output.", + "Rogues are the quintessential Face, Scout and Striker. " + "Sneak Attack allows them to do a huge pile of damage in a single attack, and their pile of skills allows them to easily handle locks, traps, guards, and many other challenges. " + "While a party can function just fine without a Rogue, it’s hard to compete with the sheer number of important skill and tool proficiencies offered by the Rogue.", + "Sorcerers are a challenge, but at the same time they can be less complex than most spellcasting classes. " + "The Sorcerer’s spell list allows them to serve as a Blaster, Controller, Striker, and Utility Caster, and sorcerers make one of the easiest Faces in the game due to their skill list and their dependence on Charisma.", + "The Warlock is likely the easiest of any spellcaster to play. " + "You get only a handful of spell slots at a time, and never have to juggle multiple spell slot levels. " + "Warlocks learn spells permanently, so you don’t need to worry about changing your spells on a daily basis. " + "Warlocks also get the most powerful damage cantrip in the game, giving them a solid, reliable option for damage output in between your big spells.", + "The Wizard is the iconic arcane spellcaster, capable of doing all manner of fantastic tricks, and generally limited only by their spellbook and their spell slots. " + "A Wizard with a comprehensive spellbook can do essentially anything in the game, often as well as or better than a non-magical character who is built to do that thing. " + "A Wizard with Invisibility is as stealthy as a Rogue." + + }; + + statOptions = new String[]{ + + "Strength", + "Dexterity", + "Constitution", + "Intelligence", + "Wisdom", + "Charisma" + + }; + + 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" + + }; + + selectedStats = new int[]{8, 8, 8, 8, 8, 8}; + + characteristics = new String[]{ + + "Name", + "Age", + "Height", + "Weight", + "Eyes", + "Hair" + + }; + + alignmentOptions = new String[]{ + + "Lawful Good", + "Neutral Good", + "Chaotic Good", + "Lawful Neutral", + "True Neutral", + "Chaotic Neutral", + "Lawful Evil", + "Neutral Evil", + "Chaotic Evil" + + }; + + alignmentDescriptions = new String[]{ + + "LG - need description", + "NG - need description", + "cg - need description", + "ln - need description", + "tn - need description", + "cn - need description", + "le - need description", + "ne - need description", + "ce - need description" + + }; + + backgroundOptions = new String[]{ + + "Acolyte", + "Charlatan", + "Criminal", + "Entertainer", + "Folk Hero", + "Gladiator", + "Guild Artisan", + "Guild Merchant", + "Hermit", + "Knight", + "Noble", + "Outlander", + "Pirate", + "Sage", + "Sailor", + "Soldier", + "Spy", + "Urchin" + + }; + + backgroundDescriptions = new String[]{ + + "Acolyte - need description", + "Charlatan - need description", + "Criminal - need description", + "Entertainer - need description", + "Folk Hero - need description", + "Gladiator - need description", + "Guild Artisan - need description", + "Guild Merchant - need description", + "Hermit - need description", + "Knight - need description", + "Noble - need description", + "Outlander - need description", + "Pirate - need description", + "Sage - need description", + "Sailor - need description", + "Soldier - need description", + "Spy - need description", + "Urchin - need description" + + }; + + } + + private BasicNavPanel createNavPanel() { + + return new BasicNavPanel(createBackButton(), createContinueButton(), 0); + + } + + private BasicNavPanel createNavPanel(int continueRequirement) { + + return new BasicNavPanel(createBackButton(), createContinueButton(), continueRequirement); + + } + + private DefaultButton createBackButton() { + + DefaultButton button = new DefaultButton("Back"); + button.addActionListener( + + e -> { + + lastPanel--; + currentPanel--; + nextPanel--; + clearAndReset(); + + } + + ); + + return button; + + } + + private DefaultButton createContinueButton() { + + DefaultButton button = new DefaultButton("Continue"); + button.addActionListener( + + e -> { + + lastPanel++; + currentPanel++; + nextPanel++; + clearAndReset(); + + } + + ); + + return button; + + } + + private DefaultButton createNewCharacterButton() { + + DefaultButton button = createContinueButton(); + button.setText("Create New Character"); + + return button; + + } + + // TODO: Need to implement. + private DefaultButton createRandomCharacterButton() { + + DefaultButton button = new DefaultButton("Create Random Character"); + button.addActionListener( + + e -> { + + 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; + clearAndReset(); + + } + + ); + + return button; + + } + + private DefaultButton createLoadButton() { + + DefaultButton button = new DefaultButton("Load"); + button.addActionListener( + + e -> { + + lastPanel = currentPanel; + currentPanel = 3; + nextPanel = currentPanel + 1; + clearAndReset(); + + } + + ); + + return button; + + } + + // TODO: Need to implement random character creation. + private void createRandomCharacter() { + + System.out.println("Request to create random character. Need to implement."); + + } + + private void clearAndReset() { + + getContentPane().removeAll(); + + add(panels[currentPanel]); + + repaint(); + revalidate(); + pack(); + + } + +} diff --git a/src/Gnome.java b/src/Gnome.java new file mode 100644 index 0000000..409c106 --- /dev/null +++ b/src/Gnome.java @@ -0,0 +1,70 @@ +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[]{}; + } + + @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 getSpeed() { + // TODO Auto-generated method stub + return speed; + } + + @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[] getLanguages() { + // TODO Auto-generated method stub + return languages; + } + + @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}; + } + + @Override + public String toString() { + // TODO Auto-generated method stub + return this.getClass().getSimpleName(); + } + +} diff --git a/src/HalfElf.java b/src/HalfElf.java new file mode 100644 index 0000000..6da8ae6 --- /dev/null +++ b/src/HalfElf.java @@ -0,0 +1,75 @@ +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; + + //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; + + } + + @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 getSpeed() { + // TODO Auto-generated method stub + return speed; + } + + @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[] getLanguages() { + // TODO Auto-generated method stub + return languages; + } + + @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}; + } + + @Override + public String toString() { + // TODO Auto-generated method stub + return this.getClass().getSimpleName(); + } + +} + diff --git a/src/HalfOrc.java b/src/HalfOrc.java new file mode 100644 index 0000000..22adb2a --- /dev/null +++ b/src/HalfOrc.java @@ -0,0 +1,70 @@ +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[]{}; + } + + @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 getSpeed() { + // TODO Auto-generated method stub + return speed; + } + + @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[] getLanguages() { + // TODO Auto-generated method stub + return languages; + } + + @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}; + } + + @Override + public String toString() { + // TODO Auto-generated method stub + return this.getClass().getSimpleName(); + } + +} diff --git a/src/Halfling.java b/src/Halfling.java new file mode 100644 index 0000000..b311644 --- /dev/null +++ b/src/Halfling.java @@ -0,0 +1,71 @@ +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[]{}; + + } + + @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 getSpeed() { + // TODO Auto-generated method stub + return speed; + } + + @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[] getLanguages() { + // TODO Auto-generated method stub + return languages; + } + + @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}; + } + + @Override + public String toString() { + // TODO Auto-generated method stub + return this.getClass().getSimpleName(); + } + +} diff --git a/src/Human.java b/src/Human.java new file mode 100644 index 0000000..8945a60 --- /dev/null +++ b/src/Human.java @@ -0,0 +1,72 @@ +public class Human 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 Human(String chosenLanguage) { + + 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 int maxAge() { + // TODO Auto-generated method stub + return maxAge; + } + + @Override + public int getSpeed() { + // TODO Auto-generated method stub + return speed; + } + + @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[] getLanguages() { + // TODO Auto-generated method stub + return languages; + } + + @Override + public String[] getProficiencies() { + // TODO Auto-generated method stub + return proficiencies; + } + + @Override + public int[] getASI() { + // TODO Auto-generated method stub + return new int[]{0, 1, 2, 3, 4, 5}; + } + + @Override + public String toString() { + // TODO Auto-generated method stub + return this.getClass().getSimpleName(); + } + +} diff --git a/src/ImageInfoPanel.java b/src/ImageInfoPanel.java new file mode 100644 index 0000000..fb301ad --- /dev/null +++ b/src/ImageInfoPanel.java @@ -0,0 +1,136 @@ +import javax.imageio.ImageIO; +import javax.swing.*; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.File; +import java.util.Objects; +import java.util.Random; + +public class ImageInfoPanel extends InfoPanel implements AppTheme { + + private JLabel[][] portraits; + private int lastIndex; + + public ImageInfoPanel(String[] categoryHolder, String[] holderDescriptions, Rectangle[] bounds, int panelIndex) { + + super(categoryHolder, holderDescriptions, bounds, panelIndex); + createPortraits(); + + } + + @Override + public void updateInfo(int holderIndex) { + + super.updateInfo(holderIndex, portraits[holderIndex][getNextPortrait(holderIndex)]); + + } + + private int getNextPortrait(int holderIndex) { + + Random ran = new Random(); + int bound = portraits[holderIndex].length; + int newIndex = ran.nextInt(bound); + +/* while(newIndex == lastIndex) { + + newIndex = ran.nextInt(bound); + + }*/ + + lastIndex = newIndex; + + return newIndex; + + } + + private void createPortraits() { + + String category = ""; + + if (panelIndex == 1) { + + category = "Races"; + + } else if (panelIndex == 2) { + + category = "Classes"; + + } + + portraits = new JLabel[categoryHolder.length][]; + + for (int i = 0; i < categoryHolder.length; i++) { + + File imagesDir; + + if (OS.startsWith("Windows")) { + + imagesDir = new File("dndBuilder\\src\\Resources\\Img\\" + category + "\\" + categoryHolder[i].toLowerCase() + "\\"); + + } else if (OS.startsWith("Mac")) { + + imagesDir = new File("dndBuilder/src/Resources/Img/" + category + "/" + categoryHolder[i].toLowerCase() + "/"); + + } else if (OS.startsWith("Linux")) { + imagesDir = new File("Img/" + category + "/" + categoryHolder[i].toLowerCase()); + + } else { + + System.out.println("Unable to detect operating system."); + return; + + } + + File[] dir = imagesDir.listFiles(); + portraits[i] = new JLabel[dir.length]; + int index = 0; + + for (File file : dir) { + portraits[i][index] = image(file); + portraits[i][index].setOpaque(true); + portraits[i][index].setBackground(lightBrown); + portraits[i][index].setBounds(bounds[3]); + + index++; + } + + + } + + + } + + private JLabel image(File file) { + + BufferedImage img; + Image finalImg; + JLabel picture; + + try { + + img = ImageIO.read(file); + finalImg = img.getScaledInstance(250, 375, Image.SCALE_SMOOTH); + + } catch (Exception e) { + + System.out.println("Error reading file."); + img = null; + finalImg = null; + + } + + if (Objects.isNull(finalImg)) { + + picture = new JLabel("ERROR: Image not found."); + + } else { + + picture = new JLabel(new ImageIcon(finalImg)); + + } + + return picture; + + } + +} diff --git a/src/InfoPanel.java b/src/InfoPanel.java new file mode 100644 index 0000000..64168dd --- /dev/null +++ b/src/InfoPanel.java @@ -0,0 +1,91 @@ +import javax.swing.*; +import javax.swing.border.EmptyBorder; +import java.awt.*; + +public class InfoPanel extends JPanel implements AppTheme { + + protected JTextArea[] descriptions; + protected Rectangle[] bounds; + protected String[] holderDescriptions; + protected String[] categoryHolder; + protected int panelIndex; + + public InfoPanel(String[] categoryHolder, String[] holderDescriptions, Rectangle[] bounds, int panelIndex) { + + super(); + this.categoryHolder = categoryHolder; + this.holderDescriptions = holderDescriptions; + this.bounds = bounds; + this.panelIndex = panelIndex; + + panelSetup(); + + createDescriptions(); + + } + + public void updateInfo(int holderIndex) { + removeAll(); + panelSetup(); + + add(descriptions[holderIndex]); + + repaint(); + revalidate(); + + } + + protected void updateInfo(int holderIndex, JLabel portrait) { + removeAll(); + panelSetup(); + + add(descriptions[holderIndex]); + add(portrait); + + repaint(); + revalidate(); + + } + + private void panelSetup() { + + setOpaque(false); + setBounds(bounds[0]); + setLayout(null); + + JLabel subHeader = new JLabel("Description"); + subHeader.setFont(subHeaderFont); + subHeader.setHorizontalAlignment(SwingConstants.LEFT); + subHeader.setBounds(bounds[1]); + subHeader.setForeground(darkestBrown); + + add(subHeader); + + } + + private void createDescriptions() { + + descriptions = new JTextArea[holderDescriptions.length]; + + 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); + + descriptions[i] = tmpDesc; + + } + + } + +} diff --git a/src/Intelligence.java b/src/Intelligence.java new file mode 100644 index 0000000..2fb6560 --- /dev/null +++ b/src/Intelligence.java @@ -0,0 +1,53 @@ +public class Intelligence extends Stats { + + private int abilityScore; + private int abilityScoreModifier; + + public Intelligence(int abilityScore) { + + this.abilityScore = abilityScore; + this.abilityScoreModifier = calcSavingThrow(abilityScore); + + } + + public int getScore() { + + return abilityScore; + + } + + public int getModifier() { + + return abilityScoreModifier; + + } + + public int getSavingThrow() { + + return getModifier(); + + } + + // TODO: Need description. + public String getDescription() { + + return ""; + + } + + @Override + public String toString() { + + return "Ability Score: " + abilityScore + " | Modifier: " + abilityScoreModifier + " | Description: " + + getDescription(); + + } + + @Override + public void increaseScore() { + + abilityScore++; + + } + +} diff --git a/src/LoadCharacterPanel.java b/src/LoadCharacterPanel.java new file mode 100644 index 0000000..22ff42d --- /dev/null +++ b/src/LoadCharacterPanel.java @@ -0,0 +1,2 @@ +public class LoadCharacterPanel { +} diff --git a/src/MainMenuPanel.java b/src/MainMenuPanel.java new file mode 100644 index 0000000..c030fba --- /dev/null +++ b/src/MainMenuPanel.java @@ -0,0 +1,64 @@ +import javax.swing.*; +import javax.swing.border.BevelBorder; +import javax.swing.border.EmptyBorder; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class MainMenuPanel extends JPanel implements AppTheme { + + private DefaultButton newCharacter; + private DefaultButton randomCharacter; + private DefaultButton loadCharacter; + + public MainMenuPanel(DefaultButton newCharacter, DefaultButton randomCharacter, DefaultButton loadCharacter) { + + super(); + panelSetup(); + this.newCharacter = newCharacter; + this.randomCharacter = randomCharacter; + this.loadCharacter = loadCharacter; + + add(createLabel(), BorderLayout.NORTH); + + add(createControlPanel(), BorderLayout.CENTER); + } + + private void panelSetup() { + + setBackground(lightBrown); + setLayout(new BorderLayout(0, 0)); + + } + + 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; + } + +} diff --git a/src/PreviewCharacterSheet.java b/src/PreviewCharacterSheet.java new file mode 100644 index 0000000..3340459 --- /dev/null +++ b/src/PreviewCharacterSheet.java @@ -0,0 +1,2 @@ +public class PreviewCharacterSheet { +} diff --git a/src/Race.java b/src/Race.java new file mode 100644 index 0000000..b31daf3 --- /dev/null +++ b/src/Race.java @@ -0,0 +1,45 @@ +public interface Race { + + String getRace(); + + int maxAge(); + + int getSpeed(); + + String[] getTraits(); + + String[] getSkills(); + + String[] getLanguages(); + + String[] getProficiencies(); + + int[] getASI(); + +// private ArrayList traits; +// private ArrayList skills; +// private ArrayList laugnuage; +// //private Subrace subrase; +// private ArrayList proficiencies; +// /** +// * @param raceName +// * @param ageRange +// * @param speed +// * @param traits +// * @param skills +// * @param laugnuage +// * @param proficiencies +// */ +// public Race(String raceName, String ageRange, int speed, ArrayList traits, ArrayList skills, +// ArrayList laugnuage, ArrayList proficiencies) { +// this.raceName = raceName; +// this.ageRange = ageRange; +// this.speed = speed; +// this.traits = traits; +// this.skills = skills; +// this.laugnuage = laugnuage; +// this.proficiencies = proficiencies; +// } + + +} diff --git a/src/Skills.java b/src/Skills.java new file mode 100644 index 0000000..2affa16 --- /dev/null +++ b/src/Skills.java @@ -0,0 +1,72 @@ +/** + * Object stores information about a character's skills arrays. Firstly, the name of each skill, and secondly the value of each skill. When constructed, a private method is called + * which adds any proficiency bonus to each skill and then adds the ability score modifier to each skill. + */ +public class Skills { + + // TODO: Prof bonus comes from the class, changes upon certain level thresholds. + private final int profBonus = 5; + // TODO: Need to verify skills are in correct order. + private String[] allSkillsText = {"Acrobatics", "Animal Handling", "Arcana", "Athletics", "Deception", "History", "Insight", "Intimidation", "Investigation", "Medicine", "Nature", "Perception", "Performance", "Persuasion", "Religion", "Sleight of Hand", "Stealth", "Survival"}; + private Stats[] stats; + + private int[] skills; + + + /** + * Default constructor for the Skills class. Should be constructed AFTER the user has generated their stats and chosen the skills they are proficient in. + * + * @param skills + * @param stats + */ + public Skills(int[] skills, Stats[] stats) { + + this.skills = skills; + + this.stats = stats; + + setSkills(); + + } + + /** + * 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}; + + for (int i = 0; i < allSkillsText.length; i++) { + + if (skills[i] == 1) { + + skills[i] = profBonus; + + } + + skills[i] += stats[skillsAbilities[i]].getModifier(); + + } + + } + + /** + * Returns the value of each skill's score. + * + * @return int[] skills + */ + public int[] getSkills() { + + return skills; + + } + + // TODO: Need to implement overloaded method to return one specific skill. + public int getSkill(String skill) { + + return 0; + + } + +} diff --git a/src/Stats.java b/src/Stats.java new file mode 100644 index 0000000..9273cba --- /dev/null +++ b/src/Stats.java @@ -0,0 +1,54 @@ +public abstract class Stats { + + public int calcSavingThrow(int abilityScore) { + + switch (abilityScore) { + case 1: + return -5; + case 2: + case 3: + return -4; + case 4: + case 5: + return -3; + case 6: + case 7: + return -2; + case 8: + case 9: + return -1; + case 10: + case 11: + return 0; + case 12: + case 13: + return 1; + case 14: + case 15: + return 2; + case 16: + case 17: + return 3; + case 18: + case 19: + return 4; + case 20: + return 5; + default: + return -42; + + } + + } + + public abstract void increaseScore(); + + abstract int getScore(); + + abstract int getModifier(); + + abstract int getSavingThrow(); + + abstract String getDescription(); + +} diff --git a/src/Strength.java b/src/Strength.java new file mode 100644 index 0000000..5845f20 --- /dev/null +++ b/src/Strength.java @@ -0,0 +1,65 @@ +public class Strength extends Stats { + + private int abilityScore; + private int abilityScoreModifier; + + public Strength(int abilityScore) { + + this.abilityScore = abilityScore; + this.abilityScoreModifier = calcSavingThrow(abilityScore); + + } + + public Strength(Strength str) { + + this.abilityScore = str.getScore(); + this.abilityScoreModifier = str.getModifier(); + + } + + public int getScore() { + + return abilityScore; + + } + + public int getModifier() { + + return abilityScoreModifier; + + } + + public int getSavingThrow() { + + return getModifier(); + + } + + public String getDescription() { + + return "Natural athleticism and bodily power."; + + } + + public int getMaxCarryWeight() { + + return abilityScore * 15; + + } + + @Override + public String toString() { + + return "Ability Score: " + abilityScore + " | Modifier: " + abilityScoreModifier + " | Description: " + + getDescription(); + + } + + @Override + public void increaseScore() { + + abilityScore++; + + } + +} diff --git a/src/Tiefling.java b/src/Tiefling.java new file mode 100644 index 0000000..4b6107a --- /dev/null +++ b/src/Tiefling.java @@ -0,0 +1,70 @@ +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[]{}; + } + + @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 getSpeed() { + // TODO Auto-generated method stub + return speed; + } + + @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[] getLanguages() { + // TODO Auto-generated method stub + return languages; + } + + @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}; + } + + @Override + public String toString() { + // TODO Auto-generated method stub + return this.getClass().getSimpleName(); + } + +} diff --git a/src/Wisdom.java b/src/Wisdom.java new file mode 100644 index 0000000..73532f2 --- /dev/null +++ b/src/Wisdom.java @@ -0,0 +1,53 @@ +public class Wisdom extends Stats { + + private int abilityScore; + private int abilityScoreModifier; + + public Wisdom(int abilityScore) { + + this.abilityScore = abilityScore; + this.abilityScoreModifier = calcSavingThrow(abilityScore); + + } + + public int getScore() { + + return abilityScore; + + } + + public int getModifier() { + + return abilityScoreModifier; + + } + + public int getSavingThrow() { + + return getModifier(); + + } + + // TODO: Need description. + public String getDescription() { + + return ""; + + } + + @Override + public String toString() { + + return "Ability Score: " + abilityScore + " | Modifier: " + abilityScoreModifier + " | Description: " + + getDescription(); + + } + + @Override + public void increaseScore() { + + abilityScore++; + + } + +} diff --git a/src/Wizard.java b/src/Wizard.java new file mode 100644 index 0000000..2e61af6 --- /dev/null +++ b/src/Wizard.java @@ -0,0 +1,88 @@ +public class Wizard implements ClassTemplate { + + private int HP; + + private int level; + + // 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? + + public String getDescription() { + // TODO Auto-generated method stub + return null; + } + + public String[] getProgression() { + // TODO Auto-generated method stub + return null; + } + + public String[] getClassFeatures() { + // TODO Auto-generated method stub + return null; + } + + public String getHitDie() { + // TODO Auto-generated method stub + return null; + } + + public int getHPatLv1() { + // TODO Auto-generated method stub + return 0; + } + + public int getHPpastLv1() { + // TODO Auto-generated method stub + return 0; + } + + public String[] getArmorProf() { + // TODO Auto-generated method stub + return null; + } + + public String[] getWeaponProf() { + // TODO Auto-generated method stub + return null; + } + + public String[] getToolProf() { + // TODO Auto-generated method stub + return null; + } + + public String[] availableSkills() { + // TODO Auto-generated method stub + return null; + } + + public String[] startingEquipChoices() { + // TODO Auto-generated method stub + return null; + } + + public boolean advantageCheck(Stats abilityScore) { + // TODO Auto-generated method stub + return false; + } + + public boolean disadvantageCheck(Stats abilityScore) { + // TODO Auto-generated method stub + return false; + } + + @Override + public String[] getSavingThrows() { + // TODO Auto-generated method stub + return null; + } + +} diff --git a/src/step4.java b/src/step4.java new file mode 100644 index 0000000..a002ad3 --- /dev/null +++ b/src/step4.java @@ -0,0 +1,277 @@ +import javax.swing.*; +import javax.swing.border.BevelBorder; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +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; + + /** + * 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); + + 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; + } +}