Initial draft implementations for stats and skills
This commit is contained in:
@@ -0,0 +1,17 @@
|
|||||||
|
# Editor configuration, see http://editorconfig.org
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
max_line_length = 80
|
||||||
|
|
||||||
|
[*.sh]
|
||||||
|
end_of_line = lf
|
||||||
|
|
||||||
|
[*.java]
|
||||||
|
indent_size = 4
|
||||||
|
max_line_length = 120
|
||||||
@@ -0,0 +1,173 @@
|
|||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>com.builder</groupId>
|
||||||
|
<artifactId>dndcharacterbuilder</artifactId>
|
||||||
|
<version>10</version>
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<junit.version>5.6.0</junit.version>
|
||||||
|
<maven-enforcer-plugin.version>3.0.0-M3</maven-enforcer-plugin.version>
|
||||||
|
<maven-checkstyle-plugin.version>3.1.2</maven-checkstyle-plugin.version>
|
||||||
|
<checkstyle.version>8.45.1</checkstyle.version>
|
||||||
|
<maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
|
||||||
|
<jacoco-maven-plugin.version>0.8.4</jacoco-maven-plugin.version>
|
||||||
|
<maven-javadoc-plugin.version>3.0.0</maven-javadoc-plugin.version>
|
||||||
|
<!-- JaCoCo thresholds. Increase gradually as you add tests. -->
|
||||||
|
<jacoco.unit-tests.limit.instruction-ratio>0%</jacoco.unit-tests.limit.instruction-ratio>
|
||||||
|
<jacoco.unit-tests.limit.branch-ratio>0%</jacoco.unit-tests.limit.branch-ratio>
|
||||||
|
<jacoco.unit-tests.limit.class-complexity>20</jacoco.unit-tests.limit.class-complexity>
|
||||||
|
<jacoco.unit-tests.limit.method-complexity>5</jacoco.unit-tests.limit.method-complexity>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-api</artifactId>
|
||||||
|
<version>${junit.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-engine</artifactId>
|
||||||
|
<version>${junit.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-enforcer-plugin</artifactId>
|
||||||
|
<version>${maven-enforcer-plugin.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>enforce</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<rules>
|
||||||
|
<requireMavenVersion>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</requireMavenVersion>
|
||||||
|
</rules>
|
||||||
|
<fail>true</fail>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
|
<version>${maven-checkstyle-plugin.version}</version>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.puppycrawl.tools</groupId>
|
||||||
|
<artifactId>checkstyle</artifactId>
|
||||||
|
<version>${checkstyle.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.ngeor</groupId>
|
||||||
|
<artifactId>checkstyle-rules</artifactId>
|
||||||
|
<version>4.9.3</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<configuration>
|
||||||
|
<configLocation>com/github/ngeor/checkstyle.xml</configLocation>
|
||||||
|
<includeTestSourceDirectory>true</includeTestSourceDirectory>
|
||||||
|
<skip>${skipTests}</skip>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>checkstyle</id>
|
||||||
|
<phase>validate</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>check</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>${maven-surefire-plugin.version}</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jacoco</groupId>
|
||||||
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
|
<version>${jacoco-maven-plugin.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>pre-unit-test</id>
|
||||||
|
<goals>
|
||||||
|
<goal>prepare-agent</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>post-unit-test</id>
|
||||||
|
<phase>test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>report</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>check-unit-test</id>
|
||||||
|
<phase>test</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>check</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<dataFile>${project.build.directory}/jacoco.exec</dataFile>
|
||||||
|
<rules>
|
||||||
|
<rule>
|
||||||
|
<element>BUNDLE</element>
|
||||||
|
<limits>
|
||||||
|
<limit>
|
||||||
|
<counter>INSTRUCTION</counter>
|
||||||
|
<value>COVEREDRATIO</value>
|
||||||
|
<minimum>${jacoco.unit-tests.limit.instruction-ratio}</minimum>
|
||||||
|
</limit>
|
||||||
|
<limit>
|
||||||
|
<counter>BRANCH</counter>
|
||||||
|
<value>COVEREDRATIO</value>
|
||||||
|
<minimum>${jacoco.unit-tests.limit.branch-ratio}</minimum>
|
||||||
|
</limit>
|
||||||
|
</limits>
|
||||||
|
</rule>
|
||||||
|
<rule>
|
||||||
|
<element>CLASS</element>
|
||||||
|
<limits>
|
||||||
|
<limit>
|
||||||
|
<counter>COMPLEXITY</counter>
|
||||||
|
<value>TOTALCOUNT</value>
|
||||||
|
<maximum>${jacoco.unit-tests.limit.class-complexity}</maximum>
|
||||||
|
</limit>
|
||||||
|
</limits>
|
||||||
|
</rule>
|
||||||
|
<rule>
|
||||||
|
<element>METHOD</element>
|
||||||
|
<limits>
|
||||||
|
<limit>
|
||||||
|
<counter>COMPLEXITY</counter>
|
||||||
|
<value>TOTALCOUNT</value>
|
||||||
|
<maximum>${jacoco.unit-tests.limit.method-complexity}</maximum>
|
||||||
|
</limit>
|
||||||
|
</limits>
|
||||||
|
</rule>
|
||||||
|
</rules>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<reporting>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
|
<version>${maven-javadoc-plugin.version}</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</reporting>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.builder;
|
||||||
|
|
||||||
|
public class Character {
|
||||||
|
|
||||||
|
public CharacterStats stats = new CharacterStats();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.builder;
|
||||||
|
|
||||||
|
public class CharacterStats {
|
||||||
|
|
||||||
|
private Stats[] stats;
|
||||||
|
|
||||||
|
public CharacterStats() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: Need to implement constructor, validates all proposed ability scores and creates new objects containing corresponding values.
|
||||||
|
public CharacterStats(Strength str, Dexterity dex, Constitution con, Intelligence intel, Wisdom wis, Charisma cha) {
|
||||||
|
|
||||||
|
this.stats = new Stats[]{str, dex, con, intel, wis, cha};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: Need to implement ability score validation.
|
||||||
|
public boolean validateAbilityScore(int abilityScore) {
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.builder;
|
||||||
|
|
||||||
|
public class Charisma extends Stats {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int getScore() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int getModifier() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
String getDescription() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int getSavingThrow() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.builder;
|
||||||
|
|
||||||
|
public class Constitution extends Stats {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int getScore() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int getModifier() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
String getDescription() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int getSavingThrow() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package com.builder;
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: Need to implement.
|
||||||
|
public String getDescription() {
|
||||||
|
|
||||||
|
return "";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
|
||||||
|
return "Ability Score: " + abilityScore + " | Modifier: " + abilityScoreModifier + " | Description: "
|
||||||
|
+ getDescription();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.builder;
|
||||||
|
|
||||||
|
public class Intelligence extends Stats{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int getScore() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int getModifier() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
String getDescription() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int getSavingThrow() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.builder;
|
||||||
|
|
||||||
|
public class Skills extends Character {
|
||||||
|
|
||||||
|
private String[] allSkillsText = {"Animal Handling", "Acrobatics", "Arcana", "Athletics", "Deception", "History", "Insight", "Intimidation", "Investigation", "Medicine", "Nature", "Perception", "Performance", "Persuasion", "Religion", "Sleight of Hand", "Stealth", "Survival"};
|
||||||
|
|
||||||
|
private int[] skills;
|
||||||
|
|
||||||
|
public Skills(int[] skills) {
|
||||||
|
|
||||||
|
this.skills = skills;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] getAllSkills() {
|
||||||
|
|
||||||
|
return skills;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package com.builder;
|
||||||
|
|
||||||
|
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:
|
||||||
|
case 21:
|
||||||
|
return 5;
|
||||||
|
case 22:
|
||||||
|
case 23:
|
||||||
|
return 6;
|
||||||
|
case 24:
|
||||||
|
case 25:
|
||||||
|
return 7;
|
||||||
|
case 26:
|
||||||
|
case 27:
|
||||||
|
return 8;
|
||||||
|
case 28:
|
||||||
|
case 29:
|
||||||
|
return 9;
|
||||||
|
case 30:
|
||||||
|
return 10;
|
||||||
|
default:
|
||||||
|
return -10;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract int getScore();
|
||||||
|
|
||||||
|
abstract int getModifier();
|
||||||
|
|
||||||
|
abstract int getSavingThrow();
|
||||||
|
|
||||||
|
abstract String getDescription();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package com.builder;
|
||||||
|
|
||||||
|
public class Strength extends Stats {
|
||||||
|
|
||||||
|
private int abilityScore;
|
||||||
|
private int abilityScoreModifier;
|
||||||
|
|
||||||
|
// FIXME: Need to implement standard constructor.
|
||||||
|
public Strength(int abilityScore) {
|
||||||
|
|
||||||
|
this.abilityScore = abilityScore;
|
||||||
|
this.abilityScoreModifier = calcSavingThrow(abilityScore);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.builder;
|
||||||
|
|
||||||
|
public class Wisdom extends Stats {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int getScore() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int getModifier() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
String getDescription() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
int getSavingThrow() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.builder;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unit test for simple App.
|
||||||
|
*/
|
||||||
|
class AppTest {
|
||||||
|
/**
|
||||||
|
* Rigorous Test.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
void testApp() {
|
||||||
|
assertEquals(1, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user