diff --git a/.gitignore b/.gitignore index c2065bc..25cd7c3 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,4 @@ out/ ### VS Code ### .vscode/ +*.lst diff --git a/build.gradle.kts b/build.gradle.kts index 1a2ae5d..4f63638 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -20,6 +20,7 @@ configurations { } repositories { +// Will need to change this to non miso nexus once outside hackday maven("https://nexus.misoenergy.org/repository/public/") } @@ -27,6 +28,7 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter-web") implementation("org.springframework.boot:spring-boot-starter-webflux") implementation("org.jsonschema2pojo:jsonschema2pojo-core:1.1.1") + testImplementation("junit:junit:4.13.1") compileOnly("org.projectlombok:lombok") annotationProcessor("org.projectlombok:lombok") testImplementation("org.springframework.boot:spring-boot-starter-test") diff --git a/src/main/java/org/misoenergy/hackday/kessel_run/PCGenExporter.java b/src/main/java/org/misoenergy/hackday/kessel_run/PCGenExporter.java new file mode 100644 index 0000000..2058b62 --- /dev/null +++ b/src/main/java/org/misoenergy/hackday/kessel_run/PCGenExporter.java @@ -0,0 +1,33 @@ +package org.misoenergy.hackday.kessel_run; + +import java.io.File; +import java.io.IOException; + +public class PCGenExporter { + + public PCGenExporter() { + } + + public void export(File file) { + try { + createOutputFile(file); + } catch (IOException e) { + handleFailedOutput(e); + } + } + + private void createOutputFile(File file) throws IOException { + if (file.createNewFile()) { + System.out.println("File created: " + file.getName()); + } else { + System.out.println("File already exists. Deleting and re-running"); + file.delete(); + createOutputFile(file); + } + } + + private void handleFailedOutput(Exception e) { + System.out.println("An error occurred."); + e.printStackTrace(); + } +} diff --git a/src/main/java/org/misoenergy/hackday/kessel_run/class_definitions/CharacterClass.java b/src/main/java/org/misoenergy/hackday/kessel_run/class_definitions/CharacterClass.java new file mode 100644 index 0000000..bfc45da --- /dev/null +++ b/src/main/java/org/misoenergy/hackday/kessel_run/class_definitions/CharacterClass.java @@ -0,0 +1,52 @@ +package org.misoenergy.hackday.kessel_run.class_definitions; + +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.util.List; +import java.util.Map; + +@Getter +@Setter +@NoArgsConstructor +public class CharacterClass { + private String name; + private String summary; + private String primaryAbility; + private String flavorText; + private String creatingText; + private String quickBuildText; + private Map levelChanges; // ignoring levelChangesJson + private int hitDiceDieType; // I don't think we need the enum one as well + private String hitPointsAtFirstLevel; + private String hitPointsAtHigherLevels; + private int hitPointsAtFirstLevelNumber; + private int hitPointsAtHigherLevelsNumber; + private List armorProficiencies; // ignoring armorProficienciesJson + private List weaponProficiencies; // ignoring weaponProficienciesJson + private List toolProficiencies; // ignoring toolProficienciesJson + private List toolProficienciesList; // ignoring toolProficienciesListJson + private List savingThrows; // ignoring savingThrowsJson + private String skillChoices; + private int numSkillChoices; + private List skillChoicesList; // ignoring skillChoicesListJson + private List equipmentLines; // ignoring equipmentLinesJson + private String startingWealthVariant; + private String classFeatureText; + private String classFeatureText2; + private String archetypeFlavorText; + private String archetypeFlavorName; + private String archetypes; // TODO unsure if this is a string or a separate type + private List imageUrls; // ignoring imageUrlsJson + private long casterRatio; + private String casterType; // ignoring casterTypeEnum + private List multiClassProficiencies; // ignoring multiClassProficienciesJson + private String features; // TODO unsure if this is a string or a separate type + private String featureRowKeys; // ignoring featureRowKeysJson + private String contentType; // ignoring contentTypeEnum + private String contentSource; // ignoring contentSourceEnum + private String partitionKey; + private String rowKey; + // ignoring timestamp and eTag +} diff --git a/src/main/java/org/misoenergy/hackday/kessel_run/class_definitions/LevelChanges.java b/src/main/java/org/misoenergy/hackday/kessel_run/class_definitions/LevelChanges.java new file mode 100644 index 0000000..2325625 --- /dev/null +++ b/src/main/java/org/misoenergy/hackday/kessel_run/class_definitions/LevelChanges.java @@ -0,0 +1,116 @@ +package org.misoenergy.hackday.kessel_run.class_definitions; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@NoArgsConstructor +@JsonIgnoreProperties(ignoreUnknown = true) +public class LevelChanges { + + @JsonProperty("Aura Radius") + private String auraRadius; + + @JsonProperty("Auras Known") + private String aurasKnown; + + @JsonProperty("Berserker Instincts") + private String berserkerInstincts; + + @JsonProperty("Discoveries") + private String discoveries; + + @JsonProperty("Features") + private String features; + + @JsonProperty("Focus Points") + private String focusPoints; + + @JsonProperty("Focused Strikes") + private String focusedStrikes; + + @JsonProperty("Force-Empowered Casting Options") + private String forceEmpoweredCastingOptions; + + @JsonProperty("Force Points") + private String forcePoints; + + @JsonProperty("Force Powers Known") + private String forcePowersKnown; + + @JsonProperty("Ideal Manifests") + private String idealManifests; + + @JsonProperty("Ideals Known") + private String idealsKnown; + + @JsonProperty("Kinetic Combat") + private String kineticCombat; + + @JsonProperty("Level") + private String level; + + @JsonProperty("Maneuvers Known") + private String maneuversKnown; + + @JsonProperty("Martial Arts") + private String martialArts; + + @JsonProperty("Max Power Level") + private String maxPowerLevel; + + @JsonProperty("Modification Slots") + private String modificationSlots; + + @JsonProperty("Monastic Vows") + private String monasticVows; + + @JsonProperty("Operative Exploits") + private String operativeExploits; + + @JsonProperty("Potent Aptitude") + private String potentAptitude; + + @JsonProperty("Proficiency Bonus") + private String proficiencyBonus; + + @JsonProperty("Rage Damage") + private String rageDamage; + + @JsonProperty("Rages") + private String rages; + + @JsonProperty("Ranger's Quarry") + private String rangersQuarry; + + @JsonProperty("Routine Radius") + private String routineRadius; + + @JsonProperty("Routines Known") + private String routinesKnown; + + @JsonProperty("Sneak Attack") + private String sneakAttack; + + @JsonProperty("Strategies Known") + private String strategiesKnown; + + @JsonProperty("Superiority Dice Quantity") + private String superiorityDiceQuantity; + + @JsonProperty("Superiority Dice Size") + private String superiorityDiceSize; + + @JsonProperty("Tech Points") + private String techPoints; + + @JsonProperty("Tech Powers Known") + private String techPowersKnown; + + @JsonProperty("Unarmored Movement") + private String unarmoredMovement; +} diff --git a/src/test/java/org/misoenergy/hackday/kessel_run/KesselRunApplicationTests.java b/src/test/java/org/misoenergy/hackday/kessel_run/KesselRunApplicationTests.java index 34df502..1802d7f 100644 --- a/src/test/java/org/misoenergy/hackday/kessel_run/KesselRunApplicationTests.java +++ b/src/test/java/org/misoenergy/hackday/kessel_run/KesselRunApplicationTests.java @@ -3,6 +3,12 @@ package org.misoenergy.hackday.kessel_run; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; +import java.io.File; +import java.io.IOException; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.internal.verification.VerificationModeFactory.times; + @SpringBootTest class KesselRunApplicationTests { diff --git a/src/test/java/org/misoenergy/hackday/kessel_run/PCGenExporterTest.java b/src/test/java/org/misoenergy/hackday/kessel_run/PCGenExporterTest.java new file mode 100644 index 0000000..770ca62 --- /dev/null +++ b/src/test/java/org/misoenergy/hackday/kessel_run/PCGenExporterTest.java @@ -0,0 +1,58 @@ +package org.misoenergy.hackday.kessel_run; + +import org.junit.jupiter.api.Test; +import org.junit.runner.RunWith; +import org.mockito.junit.MockitoJUnitRunner; + +import java.io.*; + +import static org.junit.jupiter.api.Assertions.assertTrue; + + +@RunWith(MockitoJUnitRunner.class) +public class PCGenExporterTest { + + + PCGenExporter exporter; + + @Test + void exporterExists() { + exporter = new PCGenExporter(); + } + + @Test + void exporterCreatesFileWhenNoneExists() { + exporter = new PCGenExporter(); + File file = new File("sw5eClasses.lst"); + deleteFileIfExists(file); + exporter.export(file); + assertTrue(file.isFile()); + } + + @Test + void exporterRecreatesFileWhenExists() throws IOException { + exporter = new PCGenExporter(); + File file = new File("sw5eClasses.lst"); + + deleteFileIfExists(file); + createFileWithData(file); + + exporter.export(file); + BufferedReader reader = new BufferedReader(new FileReader(file)); + + assertTrue(reader.readLine() == null); + + } + + void deleteFileIfExists(File file) { + if(!file.exists()) { + file.delete(); + } + } + + void createFileWithData(File file) throws IOException { + FileWriter writer = new FileWriter(file); + writer.write("If this exists when tested, Fail!"); + writer.close(); + } +}