Merge branch 'main' into compilingAddingApiCall

This commit is contained in:
navneetkhanuja
2024-09-11 09:58:09 -04:00
committed by GitHub
7 changed files with 268 additions and 0 deletions
+1
View File
@@ -35,3 +35,4 @@ out/
### VS Code ###
.vscode/
*.lst
+2
View File
@@ -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")
@@ -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();
}
}
@@ -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<Integer, LevelChanges> 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<String> armorProficiencies; // ignoring armorProficienciesJson
private List<String> weaponProficiencies; // ignoring weaponProficienciesJson
private List<String> toolProficiencies; // ignoring toolProficienciesJson
private List<String> toolProficienciesList; // ignoring toolProficienciesListJson
private List<String> savingThrows; // ignoring savingThrowsJson
private String skillChoices;
private int numSkillChoices;
private List<String> skillChoicesList; // ignoring skillChoicesListJson
private List<String> 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<String> imageUrls; // ignoring imageUrlsJson
private long casterRatio;
private String casterType; // ignoring casterTypeEnum
private List<String> 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
}
@@ -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;
}
@@ -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();
}
}