Skip to content
Snippets Groups Projects
Commit 7b1062c3 authored by pr1n19's avatar pr1n19
Browse files

Updated Abilities to use hashmap<String, Integer>

parent 1b95956d
No related branches found
No related tags found
No related merge requests found
...@@ -8,13 +8,13 @@ ...@@ -8,13 +8,13 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" /> <excludeFolder url="file://$MODULE_DIR$/target" />
</content> </content>
<orderEntry type="jdk" jdkName="openjdk-16" jdkType="JavaSDK" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.openjfx:javafx-controls:15.0.1" level="project" /> <orderEntry type="library" name="Maven: org.openjfx:javafx-controls:15.0.1" level="project" />
<orderEntry type="library" name="Maven: org.openjfx:javafx-controls:win:15.0.1" level="project" /> <orderEntry type="library" name="Maven: org.openjfx:javafx-controls:linux:15.0.1" level="project" />
<orderEntry type="library" name="Maven: org.openjfx:javafx-graphics:15.0.1" level="project" /> <orderEntry type="library" name="Maven: org.openjfx:javafx-graphics:15.0.1" level="project" />
<orderEntry type="library" name="Maven: org.openjfx:javafx-graphics:win:15.0.1" level="project" /> <orderEntry type="library" name="Maven: org.openjfx:javafx-graphics:linux:15.0.1" level="project" />
<orderEntry type="library" name="Maven: org.openjfx:javafx-base:15.0.1" level="project" /> <orderEntry type="library" name="Maven: org.openjfx:javafx-base:15.0.1" level="project" />
<orderEntry type="library" name="Maven: org.openjfx:javafx-base:win:15.0.1" level="project" /> <orderEntry type="library" name="Maven: org.openjfx:javafx-base:linux:15.0.1" level="project" />
</component> </component>
</module> </module>
\ No newline at end of file
package Character; package Character;
import java.util.HashMap;
public class Abilities { public class Abilities {
//Lists of names of abilities //Lists of names of abilities
private final String[] warAbilityNames = new String[]{"Archery", "Athletics", "Awareness", "Dodge", "Integrity", "Martial Arts", "Melee", "Resistance", "Thrown", "War"}; private final String[] warAbilityNames = new String[]{"Archery", "Athletics", "Awareness", "Dodge", "Integrity", "Martial Arts", "Melee", "Resistance", "Thrown", "War"};
...@@ -7,18 +9,25 @@ public class Abilities { ...@@ -7,18 +9,25 @@ public class Abilities {
private final String[] wisdomAbilityNames = new String[]{"Bureaucracy", "Investigation", "Lore", "Occult", "Medicine"}; private final String[] wisdomAbilityNames = new String[]{"Bureaucracy", "Investigation", "Lore", "Occult", "Medicine"};
//Lists of values of abilities //Lists of values of abilities
private final int[] warAbilities; private final HashMap<String, Integer> allAbilities = new HashMap<>();
private final int[] lifeAbilities;
private final int[] wisdomAbilities;
/** /**
* Manage abilities as on the character sheet * Manage abilities as on the character sheet
*/ */
public Abilities(int[] war, int[] life, int[] wisdom) { public Abilities(int[] war, int[] life, int[] wisdom) {
//Set abilities //Create all abilities list
warAbilities = war; int i0 = 0;
lifeAbilities = life; for(String ability: warAbilityNames) {
wisdomAbilities = wisdom; allAbilities.put(ability, war[i0++]);
}
int i1 = 0;
for(String ability: lifeAbilityNames) {
allAbilities.put(ability, life[i1++]);
}
int i2 = 0;
for(String ability: wisdomAbilityNames) {
allAbilities.put(ability, wisdom[i2++]);
}
} }
/** /**
...@@ -35,28 +44,16 @@ public class Abilities { ...@@ -35,28 +44,16 @@ public class Abilities {
} }
/** /**
* Return ability of given number * Return value of given ability
*/ */
public int getWarAbility(int selector) { public int getAbility(String ability) {
return warAbilities[selector]; return allAbilities.get(ability);
}
public int getLifeAbility(int selector) {
return lifeAbilities[selector];
}
public int getWisdomAbility(int selector) {
return wisdomAbilities[selector];
} }
/** /**
* Set value of given numbered ability * Set value of given numbered ability
*/ */
public void setWarAbility(int selector, int value) { public void setAbility(String selector, int value) {
warAbilities[selector] = value; allAbilities.put(selector, value);
}
public void setLifeAbility(int selector, int value) {
lifeAbilities[selector] = value;
}
public void setWisdomAbility(int selector, int value) {
wisdomAbilities[selector] = value;
} }
} }
...@@ -2,23 +2,37 @@ package UI; ...@@ -2,23 +2,37 @@ package UI;
import javafx.scene.control.ScrollPane; import javafx.scene.control.ScrollPane;
import javafx.scene.layout.HBox; import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane; import javafx.scene.layout.StackPane;
import javafx.scene.text.Text; import javafx.scene.text.Text;
import Character.Abilities;
import Character.CharacterInterface;
public class AbilitiesList extends ScrollPane { public class AbilitiesList extends ScrollPane {
private final Sheet sheet; private final Sheet sheet;
private final Abilities abilities;
private final HBox container; private final HBox container;
public AbilitiesList(Sheet sheet) { public AbilitiesList(Sheet sheet) {
//Set sheet //Set sheet
this.sheet = sheet; this.sheet = sheet;
abilities = CharacterInterface.getAbilities();
//Set HBox into scroll pane to hold Names & values //Set HBox into scroll pane to hold Names & values
container = new HBox(); container = new HBox();
this.getChildren().add(container); this.getChildren().add(container);
//Set War title & ability listings
addTitle("War");
int start = createAbilityListings(abilities.getWarNames(), 0);
//Set Life title & ability listings
addTitle("Life");
start = createAbilityListings(abilities.getLifeNames(), start);
//Set Wisdom title & ability listings
addTitle("Wisdom");
createAbilityListings(abilities.getWisdomNames(), start);
} }
/** /**
...@@ -31,4 +45,30 @@ public class AbilitiesList extends ScrollPane { ...@@ -31,4 +45,30 @@ public class AbilitiesList extends ScrollPane {
pane.getChildren().add(text); pane.getChildren().add(text);
} }
/**
* Loop through given list and create pane for each
*/
private int createAbilityListings(String[] list, int startAt) {
int i = startAt;
for(String ability: list) {
StackPane pane = new StackPane();
}
return i;
}
/**
* Take pane & show listing
*/
private void showAbility(StackPane pane, int selector) {
}
/**
* Takes pane & shows input screen
*/
private void takeInput() {
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment