Skip to content

Commit

Permalink
feature: ES2Excavator can fully import/export between DAT and JSON.
Browse files Browse the repository at this point in the history
+ refactored FileProcessor to abstract class.
+ Implements FIleProcessor per file-type.
+ Cmd line will filter args out of the args[] array before file filtering.
+ Processors will filter-greedy for their chosen file types.
  • Loading branch information
Subject9x committed Apr 11, 2024
1 parent e1f72d0 commit 9ecfab4
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package org.hercworks.extract.util;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
* Used to match incoming .JSON files against known file types for conversion to ES2 DAT binary formats.
*/
public enum FileMatch {

ARM_WEAP("ARM_WEAP"),
WEAPONS("WEAPONS"),
ARM_HERC("ARM_"),
RPR_HERC("RPR_"),
INI_HERC("INI_"),
HERCS("HERCS"),
HERC_INF("HERC_INF"),
CAREER("CAREER"),
TRAINING_HERCS("TRN_HERCS");

private String namePattern;
private static final Map<String,FileMatch> ENUM_MAP;


private FileMatch(String pattern) {
this.namePattern = pattern;
}

public String getPattern() {
return this.namePattern;
}

static {
Map<String,FileMatch> map = new HashMap<String, FileMatch>();
for (FileMatch instance : FileMatch.values()) {
map.put(instance.getPattern(),instance);
}
ENUM_MAP = Collections.unmodifiableMap(map);
}

public static FileMatch getByPattern(String file) {
for(String pattern : ENUM_MAP.keySet()) {
if(file.toUpperCase().contains(pattern)) {
return ENUM_MAP.get(pattern);
}
}
return null;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.hercworks.extract.cmd;

import org.hercworks.extract.CommandLineMain;
import org.junit.Test;


public class TestExports {

public static String[] wepDatArgs = new String[] {"-x","/UNPACK/SHELL0/GAM/WEAPONS.DAT"};
public static String[] wepJsonArgs = new String[] {"-x","/UNPACK/WEAPONS.json"};

public static String[] hercsDatArgs = new String[] {"-x","/UNPACK/SHELL0/GAM/HERCS.DAT"};
public static String[] hercsJsonArgs = new String[] {"-x","/UNPACK/HERCS.json"};

public static String[] hercInfDatArgs = new String[] {"-x","/UNPACK/SHELL0/GAM/HERC_INF.DAT"};
public static String[] hercInfJsonArgs = new String[] {"-x","/UNPACK/HERC_INF.json"};

@Test
public void testWeaponsDat() {

// CommandLineMain.main(wepDatArgs);

CommandLineMain.main(wepJsonArgs);

}

@Test
public void testHercs() {

CommandLineMain.main(hercsDatArgs);

CommandLineMain.main(hercsJsonArgs);


}

@Test
public void testHercInf() {

CommandLineMain.main(hercInfDatArgs);

CommandLineMain.main(hercInfJsonArgs);

}
}

0 comments on commit 9ecfab4

Please sign in to comment.