Refactoring and comments.
This commit is contained in:
parent
7f821d7723
commit
05a97e072a
18 changed files with 333 additions and 277 deletions
|
|
@ -1,4 +1,6 @@
|
|||
package net.halfheart.ventricleengine;
|
||||
import net.halfheart.ventricleengine.objects.Armor;
|
||||
import net.halfheart.lonesomeroad.ID;
|
||||
import org.json.*;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
|
|
@ -12,7 +14,8 @@ import java.util.Objects;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
public class ArmorsHandler {
|
||||
private static Armor constructArmor(String armorName) {
|
||||
// Creates Armor object by parsing JSON
|
||||
public static Armor constructArmor(String armorName) {
|
||||
String filename = "/armors.json";
|
||||
try (InputStream inputStream = WeaponsHandler.class.getResourceAsStream(filename)) {
|
||||
String jsonText = new BufferedReader(
|
||||
|
|
@ -49,48 +52,29 @@ public class ArmorsHandler {
|
|||
}
|
||||
}
|
||||
|
||||
// Returns Armor from String of name
|
||||
public static Armor findArmor(String armorName) {
|
||||
return switch (armorName) {
|
||||
case "Nothing" -> NOTHING;
|
||||
case "Leather Armor" -> LEATHERARMOR;
|
||||
case "Sturdy Leather Armor" -> STURDYLEATHERARMOR;
|
||||
case "Raider Armor" -> RAIDERARMOR;
|
||||
case "Metal Armor" -> METALARMOR;
|
||||
case "Combat Armor" -> COMBATARMOR;
|
||||
case "Centurion Armor" -> CENTURIONARMOR;
|
||||
case "NCR Ranger Armor" -> NCRRANGERARMOR;
|
||||
case "T-45 Power Armor" -> T45POWERARMOR;
|
||||
case "T-60 Power Armor" -> T60POWERARMOR;
|
||||
case "T-65 Power Armor" -> T65POWERARMOR;
|
||||
case "X-01 Power Armor" -> X01POWERARMOR;
|
||||
case "APA MkI Power Armor" -> APAMKIORPOWERARMOR;
|
||||
case "APA MkII Power Armor" -> APAMKIIPOWERARMOR;
|
||||
case "Raider Power Armor" -> RAIDERPOWERARMOR;
|
||||
case "Ultracite Power Armor" -> ULTRACITEPOWERARMOR;
|
||||
case "T-51 Power Armor" -> T51POWERARMOR;
|
||||
case "Enclave Uniform" -> ENCLAVEUNIFORM;
|
||||
case "Excavator Power Armor" -> EXCAVATORPOWERARMOR;
|
||||
case "Nothing" -> ID.NOTHING;
|
||||
case "Leather Armor" -> ID.LEATHERARMOR;
|
||||
case "Sturdy Leather Armor" -> ID.STURDYLEATHERARMOR;
|
||||
case "Raider Armor" -> ID.RAIDERARMOR;
|
||||
case "Metal Armor" -> ID.METALARMOR;
|
||||
case "Combat Armor" -> ID.COMBATARMOR;
|
||||
case "Centurion Armor" -> ID.CENTURIONARMOR;
|
||||
case "NCR Ranger Armor" -> ID.NCRRANGERARMOR;
|
||||
case "T-45 Power Armor" -> ID.T45POWERARMOR;
|
||||
case "T-60 Power Armor" -> ID.T60POWERARMOR;
|
||||
case "T-65 Power Armor" -> ID.T65POWERARMOR;
|
||||
case "X-01 Power Armor" -> ID.X01POWERARMOR;
|
||||
case "APA MkI Power Armor" -> ID.APAMKIORPOWERARMOR;
|
||||
case "APA MkII Power Armor" -> ID.APAMKIIPOWERARMOR;
|
||||
case "Raider Power Armor" -> ID.RAIDERPOWERARMOR;
|
||||
case "Ultracite Power Armor" -> ID.ULTRACITEPOWERARMOR;
|
||||
case "T-51 Power Armor" -> ID.T51POWERARMOR;
|
||||
case "Enclave Uniform" -> ID.ENCLAVEUNIFORM;
|
||||
case "Excavator Power Armor" -> ID.EXCAVATORPOWERARMOR;
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
public static Armor NOTHING = constructArmor("Nothing");
|
||||
public static Armor LEATHERARMOR = constructArmor("Leather Armor");
|
||||
public static Armor STURDYLEATHERARMOR = constructArmor("Sturdy Leather Armor");
|
||||
public static Armor RAIDERARMOR = constructArmor("Raider Armor");
|
||||
public static Armor METALARMOR = constructArmor("Metal Armor");
|
||||
public static Armor COMBATARMOR = constructArmor("Combat Armor");
|
||||
public static Armor CENTURIONARMOR = constructArmor("Centurion Armor");
|
||||
public static Armor NCRRANGERARMOR = constructArmor("NCR Ranger Armor");
|
||||
public static Armor T45POWERARMOR = constructArmor("T-45 Power Armor");
|
||||
public static Armor T60POWERARMOR = constructArmor("T-60 Power Armor");
|
||||
public static Armor T65POWERARMOR = constructArmor("T-65 Power Armor");
|
||||
public static Armor X01POWERARMOR = constructArmor("X-01 Power Armor");
|
||||
public static Armor APAMKIORPOWERARMOR = constructArmor("APA MkI Power Armor");
|
||||
public static Armor APAMKIIPOWERARMOR = constructArmor("APA MkII Power Armor");
|
||||
public static Armor RAIDERPOWERARMOR = constructArmor("Raider Power Armor");
|
||||
public static Armor ULTRACITEPOWERARMOR = constructArmor("Ultracite Power Armor");
|
||||
public static Armor T51POWERARMOR = constructArmor("T-51 Power Armor");
|
||||
public static Armor ENCLAVEUNIFORM = constructArmor("Enclave Uniform");
|
||||
public static Armor EXCAVATORPOWERARMOR = constructArmor("Excavator Power Armor");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue