17 changed files with 204 additions and 166 deletions
+1
View File
@@ -35,3 +35,4 @@ out/
### VS Code ###
.vscode/
*.lst
+1
View File
@@ -26,6 +26,7 @@ repositories {
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
testImplementation("junit:junit:4.13.1")
compileOnly("org.projectlombok:lombok")
annotationProcessor("org.projectlombok:lombok")
testImplementation("org.springframework.boot:spring-boot-starter-test")
@@ -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();
}
}
@@ -13,6 +13,7 @@ import java.util.Map;
public class CharacterClass {
private String name;
private String summary;
private String primaryAbility;
private String flavorText;
private String creatingText;
private String quickBuildText;
@@ -1,5 +1,7 @@
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;
@@ -7,8 +9,108 @@ import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class LevelChanges {
private String level;
private String proficiencyBonus;
@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;
}
@@ -1,15 +0,0 @@
package org.misoenergy.hackday.kessel_run.class_definitions.class_level_changes;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.misoenergy.hackday.kessel_run.class_definitions.LevelChanges;
@Getter
@Setter
@NoArgsConstructor
public class BerserkerLevelChanges extends LevelChanges {
private String rages;
private String rageDamage;
private String berserkerInstincts;
}
@@ -1,16 +0,0 @@
package org.misoenergy.hackday.kessel_run.class_definitions.class_level_changes;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.misoenergy.hackday.kessel_run.class_definitions.LevelChanges;
@Getter
@Setter
@NoArgsConstructor
public class ConsularLevelChanges extends LevelChanges {
private String forcePowersKnown;
private String forcePoints;
private String maxPowerLevel;
private String forceEmpoweredCastingOptions;
}
@@ -1,17 +0,0 @@
package org.misoenergy.hackday.kessel_run.class_definitions.class_level_changes;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.misoenergy.hackday.kessel_run.class_definitions.LevelChanges;
@Getter
@Setter
@NoArgsConstructor
public class EngineerLevelChanges extends LevelChanges {
private String techPowersKnown;
private String techPoints;
private String maxPowerLevel;
private String potentAptitude;
private String modificationSlots;
}
@@ -1,16 +0,0 @@
package org.misoenergy.hackday.kessel_run.class_definitions.class_level_changes;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.misoenergy.hackday.kessel_run.class_definitions.LevelChanges;
@Getter
@Setter
@NoArgsConstructor
public class FighterLevelChanges extends LevelChanges {
private String maneuversKnown;
private String superiorityDiceQuantity;
private String superiorityDiceSize;
private String strategiesKnown;
}
@@ -1,18 +0,0 @@
package org.misoenergy.hackday.kessel_run.class_definitions.class_level_changes;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.misoenergy.hackday.kessel_run.class_definitions.LevelChanges;
@Getter
@Setter
@NoArgsConstructor
public class GuardianLevelChanges extends LevelChanges {
private String forcePowersKnown;
private String forcePoints;
private String maxPowerLevel;
private String focusedStrikes;
private String aurasKnown;
private String auraRadius;
}
@@ -1,16 +0,0 @@
package org.misoenergy.hackday.kessel_run.class_definitions.class_level_changes;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.misoenergy.hackday.kessel_run.class_definitions.LevelChanges;
@Getter
@Setter
@NoArgsConstructor
public class MonkLevelChanges extends LevelChanges {
private String martialArts;
private String focusPoints;
private String monasticVows;
private String unarmoredMovement;
}
@@ -1,14 +0,0 @@
package org.misoenergy.hackday.kessel_run.class_definitions.class_level_changes;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.misoenergy.hackday.kessel_run.class_definitions.LevelChanges;
@Getter
@Setter
@NoArgsConstructor
public class OperativeLevelChanges extends LevelChanges {
private String sneakAttack;
private String operativeExploits;
}
@@ -1,16 +0,0 @@
package org.misoenergy.hackday.kessel_run.class_definitions.class_level_changes;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.misoenergy.hackday.kessel_run.class_definitions.LevelChanges;
@Getter
@Setter
@NoArgsConstructor
public class ScholarLevelChanges extends LevelChanges {
private String maneuversKnown;
private String superiorityDiceQuantity;
private String superiorityDiceSize;
private String discoveries;
}
@@ -1,18 +0,0 @@
package org.misoenergy.hackday.kessel_run.class_definitions.class_level_changes;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.misoenergy.hackday.kessel_run.class_definitions.LevelChanges;
@Getter
@Setter
@NoArgsConstructor
public class ScoutLevelChanges extends LevelChanges {
private String rangersQuarry;
private String techPowersKnown;
private String techPoints;
private String maxPowerLevel;
private String routinesKnown;
private String routineRadius;
}
@@ -1,18 +0,0 @@
package org.misoenergy.hackday.kessel_run.class_definitions.class_level_changes;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.misoenergy.hackday.kessel_run.class_definitions.LevelChanges;
@Getter
@Setter
@NoArgsConstructor
public class SentinelLevelChanges extends LevelChanges {
private String forcePowersKnown;
private String forcePoints;
private String maxPowerLevel;
private String kineticCombat;
private String idealsKnown;
private String manifests;
}
@@ -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 {
@@ -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();
}
}