diff options
| author | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2020-12-29 19:06:25 -0400 |
|---|---|---|
| committer | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2020-12-29 19:06:25 -0400 |
| commit | 4808d411b3b6e4e237f7a7c336c751419e763d2b (patch) | |
| tree | 99fb8bf966d117e0b1b7e18fc660af7b7a87258d /src/main/java | |
| parent | eeaf62f7a2ac1d23c2a9876ad0c86795edf804ae (diff) | |
General update
Diffstat (limited to 'src/main/java')
| -rw-r--r-- | src/main/java/tlIItools/Affix.java | 280 | ||||
| -rw-r--r-- | src/main/java/tlIItools/AffixGroup.java | 11 | ||||
| -rw-r--r-- | src/main/java/tlIItools/AffixLister.java | 198 | ||||
| -rw-r--r-- | src/main/java/tlIItools/AffixSet.java | 36 | ||||
| -rw-r--r-- | src/main/java/tlIItools/Effect.java | 205 | ||||
| -rw-r--r-- | src/main/java/tlIItools/EffectRepo.java | 85 | ||||
| -rw-r--r-- | src/main/java/tlIItools/Main.java | 13 | ||||
| -rw-r--r-- | src/main/java/tlIItools/NameFileReader.java | 136 | ||||
| -rw-r--r-- | src/main/java/tlIItools/ReplPair.java | 173 |
9 files changed, 395 insertions, 742 deletions
diff --git a/src/main/java/tlIItools/Affix.java b/src/main/java/tlIItools/Affix.java index d90c0108..b147ab0b 100644 --- a/src/main/java/tlIItools/Affix.java +++ b/src/main/java/tlIItools/Affix.java @@ -1,112 +1,78 @@ package tlIItools; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.Scanner; +import java.util.*; -/** - * Represents a Torchlight II affix. +/** Represents a Torchlight II affix. + * + * @author Ben Culkin */ public class Affix { - /** - * Whether or not to record timing info. - */ + /** Whether or not to record timing info. */ public static boolean doTiming; - /** - * Internal name of the affix. - */ + /** Internal name of the affix. */ public String intName; - /* - * The prefix/suffix attached to the affix. + /* The prefix/suffix attached to the affix. * * In general, only one of these is set for a given affix. * * NOTE: Some affixes have a mis-set suffix/prefix ordering, and may need to be - * changed in their files. - */ - /** - * The 'suffix name' attached to this affix. + * changed in their files. */ + + /** The 'suffix name' attached to this affix. * * Include the word [ITEM] to indicate where the item name should go. * * Note that it is not guaranteed that this is actually a suffix; it could be a - * prefix. - */ + * prefix. */ public String affixSuffix; - /** - * The 'prefix name' attached to this affix. + /** The 'prefix name' attached to this affix. * * Include the word [ITEM] to indicate where the item name should go. * * Note that it is not guaranteed that this is actually a prefix; it could be a - * suffix. - */ + * suffix. */ public String affixPrefix; - /* - * The min/max levels the affix can spawn at. - */ - /** - * The minimum level of an item this affix can spawn on. - */ + /* The min/max levels the affix can spawn at. */ + + /** The minimum level of an item this affix can spawn on. */ public int minLevel; - /** - * The maximum level of an item this affix can spawn on. - */ + /** The maximum level of an item this affix can spawn on. */ public int maxLevel; - /** - * The spawn weight for the affix. - */ + /** The spawn weight for the affix. */ public int weight; - /** - * The number of affix slots taken up. - */ + /** The number of affix slots taken up. */ public int slots; - /** - * Whether this is a socketable affix. - */ + // @NOTE isEnchantment, isSocketable and isPerson seem to be mutally + // exclusive. Should they be a enum? - bculkin, 12/29/2020 + /** Whether this is a socketable affix. */ public boolean isSocketable; - /** - * Whether this is an enchantment, instead of a standard affix. - */ + + /** Whether this is an enchantment, instead of a standard affix. */ public boolean isEnchantment; - /** - * Whether this is a mob/player affix. - */ + /** Whether this is a mob/player affix. */ public boolean isPerson; - /** - * The types of equipment this can spawn on. - */ + /** The types of equipment this can spawn on. */ public List<String> equipTypes; - /** - * The types of equipment this can't spawn on. - */ + /** The types of equipment this can't spawn on. */ public List<String> nonequipTypes; - /** - * Places to get this enchantment from; - */ + /** Places to get this enchantment from; */ public List<String> enchantSources; - /** - * The socketable types this spawns on. - */ + /** The socketable types this spawns on. */ public List<String> socketableTypes; - /** - * The effects attached to this affix. - */ + /** The effects attached to this affix. */ public List<Effect> effects; - /** - * Is this affix in an 'affix group' with another affix? + /** Determine whether this affix is in an 'affix group' with another affix. * * By 'affix group', what we mean is that it is essentially the same affix, with * generally just differing levels/values. @@ -115,50 +81,45 @@ public class Affix { * strength would be considered to be in the same affix group (assuming that * both of those strength bonuses had the same effect name). * - * @param afx - * The affix to check if we are in an affix group with. + * @param afx The affix to check if we are in an affix group with. * - * @return Whether or now we are in an affix group with the specified affix. - */ + * @return Whether or now we are in an affix group with the specified affix. */ public boolean isInAffixGroup(Affix afx) { if (effects == null) { - if (afx.effects != null) - return false; - } else if (!effects.equals(afx.effects)) // TODO this isn't actually an equals; - // maybe make this a 'isEquivalent' or - // 'isSimilarEffect'? + if (afx.effects != null) return false; + } else if (!effects.equals(afx.effects)) { + // TODO this isn't actually an equals; maybe make this a 'isEquivalent' or 'isSimilarEffect'? + // -bculkin, 12/29/2020 return false; - if (enchantSources == null) { - if (afx.enchantSources != null) - return false; - } else if (!enchantSources.equals(afx.enchantSources)) + } else if (enchantSources == null) { + if (afx.enchantSources != null) return false; + } else if (!enchantSources.equals(afx.enchantSources)) { return false; - if (equipTypes == null) { - if (afx.equipTypes != null) - return false; - } else if (!equipTypes.equals(afx.equipTypes)) + } else if (equipTypes == null) { + if (afx.equipTypes != null) return false; + } else if (!equipTypes.equals(afx.equipTypes)) { return false; - if (isEnchantment != afx.isEnchantment) + } else if (isEnchantment != afx.isEnchantment) { return false; - if (isPerson != afx.isPerson) + } else if (isPerson != afx.isPerson) { return false; - if (isSocketable != afx.isSocketable) + } else if (isSocketable != afx.isSocketable) { return false; - if (nonequipTypes == null) { - if (afx.nonequipTypes != null) - return false; - } else if (!nonequipTypes.equals(afx.nonequipTypes)) + } else if (nonequipTypes == null) { + if (afx.nonequipTypes != null) return false; + } else if (!nonequipTypes.equals(afx.nonequipTypes)) { return false; - if (socketableTypes == null) { - if (afx.socketableTypes != null) - return false; - } else if (!socketableTypes.equals(afx.socketableTypes)) + } else if (socketableTypes == null) { + if (afx.socketableTypes != null) return false; + } else if (!socketableTypes.equals(afx.socketableTypes)) { return false; + } else { + return true; + } return true; } - /** - * Gets the name of the 'affix group' that this affix is in. + /** Gets the name of the 'affix group' that this affix is in. * * By 'affix group', what we mean is that it is essentially the same affix, with * generally just differing levels/values. @@ -168,71 +129,50 @@ public class Affix { * both of those strength bonuses had the same effect name, and applied to the * same sorts of items). * - * @return The name of the affix group - */ + * @return The name of the affix group */ public String getAffixGroupName() { StringBuilder sb = new StringBuilder(); - for (Effect eft : effects) { - sb.append(eft.getEffectGroup()); - } + for (Effect eft : effects) sb.append(eft.getEffectGroup()); - for (String enchantSource : enchantSources) { - sb.append(enchantSource); - } + for (String enchantSource : enchantSources) sb.append(enchantSource); - for (String equipType : equipTypes) { - sb.append(equipType); - } + for (String equipType : equipTypes) sb.append(equipType); - for (String nonEquipType : nonequipTypes) { - sb.append(nonEquipType); - } + for (String nonEquipType : nonequipTypes) sb.append(nonEquipType); - for (String socketableType : socketableTypes) { - sb.append(socketableType); - } + for (String socketableType : socketableTypes) sb.append(socketableType); return sb.toString(); } - /* - * Are invalid equip types being added? + /* Are invalid equip types being added? * * NOTE: This is kinda bad practice. It should really be handled via two * separate affix methods, one to add a valid affix, one to add an invalid, w/ - * the caller keeping tracking/calling the right one. - */ + * the caller keeping tracking/calling the right one. */ private boolean inNonEquip; - /** - * Create a new blank affix. - */ + /** Create a new blank affix. */ public Affix() { - equipTypes = new ArrayList<>(); - nonequipTypes = new ArrayList<>(); - enchantSources = new ArrayList<>(); + equipTypes = new ArrayList<>(); + nonequipTypes = new ArrayList<>(); + enchantSources = new ArrayList<>(); socketableTypes = new ArrayList<>(); - effects = new ArrayList<>(); + effects = new ArrayList<>(); } - /** - * Sets the set of equip types that is added to. + /** Sets the set of equip types that is added to. * - * @param nonequip - * True if the equip types being added are prohibited, or false - * if they are allowed. - */ + * @param nonequip True if the equip types being added are prohibited, or false + * if they are allowed. */ public void setEquipType(boolean nonequip) { inNonEquip = nonequip; } - /** - * Add an equip type to the right set of equip types. + /** Add an equip type to the right set of equip types. * - * @param type - * The equip type to add. - */ + * @param type The equip type to add. */ public void addEquipType(String type) { if (inNonEquip) { nonequipTypes.add(type); @@ -256,13 +196,12 @@ public class Affix { return intName; } - /** - * Print out the full details of this affix. + /** Print out the full details of this affix. * - * @return The full details of the affix. - */ + * @return The full details of the affix. */ public String toLongString() { StringBuilder sb = new StringBuilder(); + if (isSocketable) { sb.append("Socketable "); } else if (isPerson || (intName != null && intName.startsWith("HERO_"))) { @@ -324,12 +263,14 @@ public class Affix { } if (equipTypes.size() != 0) { - if (isSocketable) + if (isSocketable) { sb.append("\tSocketable Into: "); - else if (isEnchantment) + } else if (isEnchantment) { sb.append("\tEnchants Onto: "); - else + } else { sb.append("\tSpawns On: "); + } + sb.append(equipTypes); sb.append("\n"); } @@ -362,6 +303,7 @@ public class Affix { sb.append("\n"); } + /* sb.append("Affix Group: "); String afxGroupName = getAffixGroupName(); sb.append(afxGroupName); @@ -369,36 +311,29 @@ public class Affix { sb.append(afxGroupName.hashCode()); sb.append(")"); sb.append("\n"); + */ return sb.toString(); } - /** - * Load an affix from an input source. + /** Load an affix from an input source. * - * @param scn - * The input source to load from. + * @param scn The input source to load from. * - * @param fName - * The name of the input source in question. + * @param fName The name of the input source in question. * - * @return The loaded affix. - */ + * @return The loaded affix. */ public static Affix loadAffix(Scanner scn, String fName) { return loadAffix(scn, fName, new ArrayList<>()); } - /** - * Load an affix from an input source. + /** Load an affix from an input source. * - * @param scn - * The input source to read from. - * @param scnName - * The name of the input source. - * @param errors - * A list to stick errors encountered during loading the affix. - * @return The affix, loaded from the file. - */ + * @param scn The input source to read from. + * @param scnName The name of the input source. + * @param errors A list to stick errors encountered during loading the affix. + * + * @return The affix, loaded from the file. */ public static Affix loadAffix(Scanner scn, String scnName, List<String> errors) { Affix afx = new Affix(); @@ -428,9 +363,10 @@ public class Affix { afx.affixPrefix = splits[1]; break; default: - errors.add( - String.format("Misformed affix translation: (%s) (%s) (%s)\n", - splits[0], splits[1], scnName)); + String msg = String.format( + "Misformed affix translation: (%s) (%s) (%s)\n", + splits[0], splits[1], scnName); + errors.add(msg); } } else if (ln.contains("MIN_SPAWN_RANGE")) { afx.minLevel = Integer.parseInt(splits[1]); @@ -442,13 +378,17 @@ public class Affix { afx.weight = Integer.parseInt(splits[1]); } else if (ln.contains("UNITTYPE") && !ln.contains("/")) { if (splits.length == 1) - errors.add(String.format("Malformed equip type: (%s) (%s)\n", + errors.add(String.format( + "Malformed equip type: (%s) (%s)\n", splits[0], scnName)); + afx.addEquipType(splits[1]); } else if (splits[0].equals("<STRING>NAME")) { if (splits.length == 1) - errors.add(String.format("Malformed name: (%s) (%s)\n", splits[0], - scnName)); + errors.add(String.format( + "Malformed name: (%s) (%s)\n", + splits[0], scnName)); + afx.intName = splits[1]; } else if (ln.contains("[EFFECT]")) { List<String> eftErrs = new ArrayList<>(); @@ -459,21 +399,21 @@ public class Affix { afx.effects.add(eft); } } + // Sort effects, so that they are in a stable order, even if specified out of // order afx.effects.sort(Comparator.comparingInt((val) -> val.hashCode())); long endTime = System.nanoTime(); if (doTiming) { - String fmt - = "\tProcessed affix %s from %s in %d nanoseconds (%.2f seconds)\n\n"; + String fmt = "\tProcessed affix %s from %s in %d nanoseconds (%.2f seconds)\n\n"; double seconds = ((double) (endTime - startTime) / 1000000000); - errors.add(String.format(fmt, afx.intName, scnName, endTime - startTime, - seconds)); + errors.add(String.format( + fmt, + afx.intName, scnName, endTime - startTime, seconds)); } return afx; } - } diff --git a/src/main/java/tlIItools/AffixGroup.java b/src/main/java/tlIItools/AffixGroup.java new file mode 100644 index 00000000..7ae57453 --- /dev/null +++ b/src/main/java/tlIItools/AffixGroup.java @@ -0,0 +1,11 @@ +package tlIItools; + +/** + * Represents a 'group' of related affixes. + * + * These are affixes that are do the same thing, but could be of varying levels; + * or have effects of differing intensity. + * + * @author Ben Culkin */ +public class AffixGroup { +} diff --git a/src/main/java/tlIItools/AffixLister.java b/src/main/java/tlIItools/AffixLister.java index 4601ef4d..3d5519d3 100644 --- a/src/main/java/tlIItools/AffixLister.java +++ b/src/main/java/tlIItools/AffixLister.java @@ -5,76 +5,48 @@ import java.io.*; import java.util.*; import java.util.Map.Entry; -/** - * Lists randomly generated affixes for Torchlight II gear. +/** Lists randomly generated affixes for Torchlight II gear. * - * @author Ben Culkin - */ + * @author Ben Culkin */ public class AffixLister { - /* - * Count of effects this class has loaded. - */ + /* Count of effects this class has loaded. */ private static int effectCount = 0; - /** - * Should the class record timing data? - */ + /** Should the class record timing data? */ public static boolean doTiming = false; - /** - * Should the file name be attached to things? - */ + /** Should the file name be attached to things? */ public static boolean addFileName = false; - /* - * Output streams to use. - */ - /** - * The normal output to use. - */ + /* Output streams to use. */ + + /** The normal output to use. */ public static PrintStream normOut = System.out; - /** - * The error output to use. - */ + /** The error output to use. */ public static PrintStream errOut = System.err; - /** - * Indicates how to treat affixes with regards to their names. - */ + /** Indicates how to treat affixes with regards to their names. */ public static enum NameMode { - /** - * Show all affixes. - */ + /** Show all affixes. */ ALL, - /** - * Show only unnamed affixes. - */ + /** Show only unnamed affixes. */ UNNAMED, - /** - * Show only named affixes. - */ + /** Show only named affixes. */ NAMED; } - /** - * Main method. + /** Main method. * - * @param args - * The names of the files to read affix data from. - */ + * @param args The names of the files to read affix data from. */ public static void main(String[] args) { listAffixes(args); } - /** - * Main method that actually does stuff. + /** Main method that actually does stuff. * - * @param args - * The names of the files to read affix data from. - * - * @return The listed affix set. + * @param args The names of the files to read affix data from. * - */ + * @return The listed affix set. */ @SuppressWarnings("unused") public static AffixSet listAffixes(String[] args) { AffixSet affixSetByName = new AffixSet(); @@ -86,17 +58,16 @@ public class AffixLister { NameMode nameMode = NameMode.ALL; - int namedCount = 0; + int namedCount = 0; int unnamedCount = 0; - int zeroCount = 0; - int groupCount = 0; + int zeroCount = 0; + int groupCount = 0; - boolean outputAffixGroups = false; + boolean outputAffixGroups = false; OutputStream affixGroupDest = null; - Map<String, Set<Affix>> groupContents = affixSetByName.affixGroups; - - Set<Affix> nonGroupContents = affixSetByName.ungroupedAffixes; + Map<String, Set<Affix>> groupContents = affixSetByName.affixGroups; + Set<Affix> nonGroupContents = affixSetByName.ungroupedAffixes; NameFileReader nfr = new NameFileReader(false); nfr.groupRx = ".*/mods/([^/]+)/*"; @@ -112,144 +83,112 @@ public class AffixLister { case "--": doingArgs = false; break; - case "--omit-zero": case "-z": omitZeros = true; break; - case "--no-omit-zero": case "-Z": omitZeros = false; break; - case "--list-zero": case "-l": listZeros = true; break; - case "--no-list-zero": case "-L": listZeros = false; break; - case "--timing": case "-t": doTiming = true; Effect.doTiming = true; break; - case "--no-timing": case "-T": doTiming = false; Effect.doTiming = false; break; - case "--file-names": case "-f": addFileName = true; break; - case "--no-file-names": case "-F": addFileName = true; break; - case "--name-mode": case "-n": if (i + 1 >= args.length) { - errOut.printf( - "ERROR: name mode argument requires the mode to use be specified (all, unnamed or named)\n"); + errOut.printf("ERROR: name mode argument requires the mode to use be specified (all, unnamed or named)\n"); break; } nameMode = NameMode.valueOf(args[++i].toUpperCase()); - break; - case "--file-group": case "-g": if (i + 1 >= args.length) { - errOut.printf( - "ERROR: file group argument requires the group name to use be specified\n"); + errOut.printf("ERROR: file group argument requires the group name to use be specified\n"); break; } nfr.swapGroup(args[++i]); - break; - case "--guess-groups": nfr.guessGroups = true; - break; - case "--no-guess-groups": nfr.guessGroups = false; - break; - case "--read-names-from-file": case "-r": if (i + 1 >= args.length) { - errOut.printf( - "ERROR: read name file argument requires the file to use be specified\n"); + errOut.printf("ERROR: read name file argument requires the file to use be specified\n"); break; } nfr.readFrom(args[++i]); - break; - case "--output": case "-o": if (i + 1 >= args.length) { - errOut.printf( - "ERROR: output file argument requires the file to use be specified\n"); + errOut.printf("ERROR: output file argument requires the file to use be specified\n"); break; } try { normOut = new PrintStream(args[++i]); - nfr.normOut = normOut; } catch (IOException ioex) { errOut.printf("Could not open output file %s\n", args[i]); ioex.printStackTrace(errOut); } - break; - case "--output-errors": case "-e": if (i + 1 >= args.length) { - errOut.printf( - "ERROR: error output file argument requires the file to use be specified\n"); + errOut.printf("ERROR: error output file argument requires the file to use be specified\n"); break; } try { errOut = new PrintStream(args[++i]); - nfr.errOut = errOut; } catch (IOException ioex) { errOut.printf("Could not open error output file %s\n", args[i]); ioex.printStackTrace(errOut); } - break; - case "--guess-regex": if (i + 1 >= args.length) { - errOut.printf( - "ERROR: group regex argument requires the regex to use be specified\n"); + errOut.printf("ERROR: group regex argument requires the regex to use be specified\n"); break; } nfr.groupRx = args[++i]; - break; case "--output-affix-groups": if (i + 1 >= args.length) { @@ -260,24 +199,19 @@ public class AffixLister { try { affixGroupDest = new PrintStream(args[++i]); - outputAffixGroups = true; } catch (IOException ioex) { errOut.printf( "ERROR: Couldn't open file %s to write affix groups to\n", affixGroupDest); } - break; default: isArg = false; } - if (isArg) { - continue; - } - - nfr.addFile(fName); + if (isArg) continue; + else nfr.addFile(fName); } else { nfr.addFile(fName); } @@ -286,8 +220,8 @@ public class AffixLister { AffixSet affixSetByContents = new AffixSet(); for (Entry<String, List<String>> fGroup : nfr.fNames.entrySet()) { - if (fGroup.getValue().size() == 0) - continue; + if (fGroup.getValue().size() == 0) continue; + normOut.printf("\nFile Group '%s' starting\n", fGroup.getKey()); for (String fName : fGroup.getValue()) { try (FileReader fr = new FileReader(fName)) { @@ -323,61 +257,62 @@ public class AffixLister { } } - if (afx.weight == 0) - zeroCount += 1; + if (afx.weight == 0) zeroCount += 1; if (afx.weight == 0 && !listZeros) { - if (!omitZeros) - normOut.printf("\nAffix %s has zero spawn weight\n", - afx.intName); + if (!omitZeros) normOut.printf( + "\nAffix %s has zero spawn weight\n", + afx.intName); } else { - boolean isNamed - = (afx.affixSuffix != null) || (afx.affixPrefix != null); + boolean isNamed = + (afx.affixSuffix != null) || (afx.affixPrefix != null); - if (isNamed) - namedCount += 1; - else - unnamedCount += 1; + if (isNamed) namedCount += 1; + else unnamedCount += 1; - if (nameMode == NameMode.UNNAMED && isNamed) - continue; - if (nameMode == NameMode.NAMED && !isNamed) - continue; + if (nameMode == NameMode.UNNAMED && isNamed) continue; + if (nameMode == NameMode.NAMED && !isNamed) continue; normOut.printf("\n%s\n", afx.toLongString()); } } catch (Exception ex) { - errOut.printf("Something bad happened for file %s:%s\n", fName, - ex.getMessage()); + errOut.printf( + "Something bad happened for file %s:%s\n", + fName, ex.getMessage()); ex.printStackTrace(errOut); - errOut.println(); } } + normOut.printf("\nFile Group '%s' ending\n", fGroup.getKey()); } errOut.println("\nGroup Contents: "); + for (Entry<String, Set<Affix>> ent : groupContents.entrySet()) { errOut.printf("\t%s: %s\n", ent.getKey(), ent.getValue()); } + errOut.println(); errOut.println(); if (outputAffixGroups) { - for (Entry<String, Set<Affix>> ent : affixSetByContents.affixGroups - .entrySet()) { - String groupName = ent.getKey(); - Set<Affix> affixes = ent.getValue(); + for (Entry<String, Set<Affix>> ent : + affixSetByContents.affixGroups .entrySet()) { + + String groupName = ent.getKey(); + Set<Affix> affixes = ent.getValue(); boolean isFirstAfx = true; for (Affix afx : affixes) { + // @TODO actually implement this -bculkin, 12/29/2020 + + // Print the header for this group if (isFirstAfx) { - // Print the header for this - // group isFirstAfx = false; } + // print this affix in the group format } } @@ -385,14 +320,15 @@ public class AffixLister { long endTime = System.nanoTime(); errOut.printf( - "\nProcessed %,d affixes (%,d named, %,d unnamed, %,d zero-weight) (%,d effects) (%,d distinct groups, %,d actual groups, %,d nongrouped affixes) out of %,d files (%,d groups) in %,d nanoseconds (%.2f seconds)\n", - nfr.fCount, namedCount, unnamedCount, zeroCount, effectCount, groupCount, - groupContents.size(), nonGroupContents.size(), nfr.fCount, - nfr.fNames.size(), endTime - startTime, - ((double) (endTime - startTime) / 1000000000)); + "\nProcessed %,d affixes (%,d named, %,d unnamed, %,d zero-weight) (%,d effects) (%,d distinct groups, %,d actual groups, %,d nongrouped affixes) out of %,d files (%,d groups) in %,d nanoseconds (%.2f seconds)\n", + nfr.fCount, namedCount, unnamedCount, zeroCount, effectCount, groupCount, + groupContents.size(), nonGroupContents.size(), nfr.fCount, + nfr.fNames.size(), endTime - startTime, + ((double) (endTime - startTime) / 1000000000)); + errOut.printf( - "\tOptions: Name Mode: %s, Special-case zero weight: %s, Noting zero-weight in special case: %s\n", - nameMode, !listZeros, !omitZeros); + "\tOptions: Name Mode: %s, Special-case zero weight: %s, Noting zero-weight in special case: %s\n", + nameMode, !listZeros, !omitZeros); return affixSetByName; } diff --git a/src/main/java/tlIItools/AffixSet.java b/src/main/java/tlIItools/AffixSet.java index d43b34e1..d6b950f6 100644 --- a/src/main/java/tlIItools/AffixSet.java +++ b/src/main/java/tlIItools/AffixSet.java @@ -2,50 +2,37 @@ package tlIItools; import java.util.*; -/** - * Container of a set of affixes. +/** Container of a set of affixes. * - * @author Ben Culkin - */ + * @author Ben Culkin */ public class AffixSet { private static class AffixComparator implements Comparator<Affix> { @Override public int compare(Affix a1, Affix a2) { - if (a1.minLevel == a2.minLevel) { - return a1.maxLevel - a2.maxLevel; - } - - return a1.minLevel - a2.minLevel; + if (a1.minLevel == a2.minLevel) return a1.maxLevel - a2.maxLevel; + else return a1.minLevel - a2.minLevel; } } - /** - * All of the affix groups contained in this set. + /** All of the affix groups contained in this set. * * An affix group is a set of affixes that generally have the same or - * similar effects, but have different intensities or spawn levels. - */ + * similar effects, but have different intensities or spawn levels. */ public Map<String, Set<Affix>> affixGroups; - /** - * All of the ungrouped affixes contained in this set. - */ + /** All of the ungrouped affixes contained in this set. */ public Set<Affix> ungroupedAffixes; - /** - * Create a new blank affix set. - */ + /** Create a new blank affix set. */ public AffixSet() { affixGroups = new TreeMap<>(); ungroupedAffixes = new TreeSet<>(new AffixComparator()); } - /** - * Add an affix to this set. + /** Add an affix to this set. * - * @param afx The affix to add. - */ + * @param afx The affix to add. */ public void addAffixByContents(Affix afx) { String afxGroup = afx.getAffixGroupName(); @@ -55,13 +42,10 @@ public class AffixSet { affixGroups.compute(afxGroup, (key, val) -> { if (val == null) { Set<Affix> afxSet = new HashSet<>(); - afxSet.add(afx); - return afxSet; } else { val.add(afx); - return val; } }); diff --git a/src/main/java/tlIItools/Effect.java b/src/main/java/tlIItools/Effect.java index d641b112..b6b7e30f 100644 --- a/src/main/java/tlIItools/Effect.java +++ b/src/main/java/tlIItools/Effect.java @@ -1,162 +1,96 @@ package tlIItools; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Scanner; +import java.util.*; -/** - * Represents an effect attached to an affix. +/** Represents an effect attached to an affix. * - * @author Ben Culkin - */ + * @author Ben Culkin */ public class Effect { - /** - * Count of all loaded effects. - */ + /** Count of all loaded effects. */ public static int effectCount = 0; - /** - * Do timing analysis when loading effects. - */ + /** Do timing analysis when loading effects. */ public static boolean doTiming; - /** - * The file name this effect came from. - */ + /** The file name this effect came from. */ public String fName; - - /** - * The name of the effect. - */ + /** The name of the effect. */ public String name; - /** - * The specific effect that happens. - */ + /** The specific effect that happens. */ public String type; - /** - * Damage type for the effect, if applicable. - */ + /** Damage type for the effect, if applicable. */ public String damageType = "physical"; - /** - * Duration of the effect. - */ + /** Duration of the effect. */ public double duration; - /** - * Whether or not we have a duration or not. - */ + /** Whether or not we have a duration or not. */ public boolean hasDuration; - /** - * Minimum value for the effect. - */ + /** Minimum value for the effect. */ public double minValue; - /** - * Maximum value for the effect. - */ + /** Maximum value for the effect. */ public double maxValue; - /** - * The name of the stat that applies to this affect. - */ + /** The name of the stat that applies to this affect. */ public String statName; - /** - * The percent of the stat value to apply. - */ + /** The percent of the stat value to apply. */ public double statPercent; - /** - * Whether or not this stat is a bonus value. - */ + /** Whether or not this stat is a bonus value. */ public boolean isStatBonus; - /** - * Whether or not this uses the owners level to modify - * any applicable graph. - */ + /** Whether or not this uses the owners level to modify any applicable graph. */ public boolean ownerLevel; - /** - * The graph to use instead of the default graph. - */ - public String graphOverride; - - /** - * Whether or not a graph is used for this effect. - */ + /** Whether or not a graph is used for this effect. */ public boolean useGraph = true; + /** The graph to use instead of the default graph. */ + public String graphOverride; - /** - * Whether this effect can stack with itself. - */ + /** Whether this effect can stack with itself. */ public boolean exclusive; - /** - * The amount the targets armor is reduced by for this - * effect. - */ + /** The amount the targets armor is reduced by for this effect. */ public double soakScale = 1.0; - /** - * Level of the effect. - */ + /** Level of the effect. */ public int level = -1; - /** - * Whether or not this effect is a 'transfer' - * effect (Applied to the enemy on a hit). - */ + /** Whether or not this effect is a 'transfer' effect (Applied to the enemy on a hit). */ public boolean isTransfer; - /** - * The amount to resist/do knockback by. - */ + /** The amount to resist/do knockback by. */ public double resist; - /** - * Minimum value per monster. - */ + /** Minimum value per monster. */ public double minPer; - /** - * Maximum value per monster. - */ + /** Maximum value per monster. */ public double maxPer; - /** - * Range for effect. - */ + /** Range for effect. */ public double range; - /** - * Maximum count of monsters. - */ + /** Maximum count of monsters. */ public double maxCount; - /** - * The rate at which the effect fires. - */ + /** The rate at which the effect fires. */ public double pulse; - /** - * Create a new blank effect. - */ + /** Create a new blank effect. */ public Effect() { } - /** - * Gets the 'effect group' this effect belongs to. + /** Gets the 'effect group' this effect belongs to. * * An 'effect group is essentially any other effect that is the same general sort of effect, just with different details. * * For instance, an effect that grants +4 strength would group with one granting +8 strength, * assuming that most other details were equal. * - * @return The 'effect group' this effect belongs to. - */ + * @return The 'effect group' this effect belongs to. */ public String getEffectGroup() { StringBuilder sb = new StringBuilder(); @@ -185,9 +119,16 @@ public class Effect { Map<String, String> detMap = hasDuration ? EffectRepo.timeDetals : EffectRepo.detals; - if (detMap.containsKey(type) || (hasDuration && !EffectRepo.timeDetals.containsKey(type) && EffectRepo.detals.containsKey(type))) { + if (detMap.containsKey(type) || + (hasDuration + && !EffectRepo.timeDetals.containsKey(type) + && EffectRepo.detals.containsKey(type))) + { String fmt; - if (hasDuration && !EffectRepo.timeDetals.containsKey(type) && EffectRepo.detals.containsKey(type)) { + if (hasDuration + && !EffectRepo.timeDetals.containsKey(type) + && EffectRepo.detals.containsKey(type)) + { AffixLister.errOut.printf("Improvised details for timed %s\n", type); fmt = EffectRepo.detals.get(type) + "for <DUR> seconds"; } else { @@ -196,35 +137,27 @@ public class Effect { // Expand aliases first. - for (ReplPair repl : EffectRepo.replList) { - fmt = fmt.replaceAll(repl.find, repl.replace); - } + for (ReplPair repl : EffectRepo.replList) fmt = fmt.replaceAll(repl.find, repl.replace); - if (minValue <= 0 && maxValue <= 0) { - fmt = fmt.replaceAll("<C\\|([^|>]+)\\|([^|>]+)>", "$1"); - } - - if (minValue >= 0 && maxValue >= 0) { - fmt = fmt.replaceAll("<C\\|([^|>]+)\\|([^|>]+)>", "$2"); - } - - if (minPer <= 0 && maxPer <= 0) { - fmt = fmt.replaceAll("<MC\\|(\\w+)\\|(\\w+)>", "$1"); - } - - if (minPer >= 0 && maxPer >= 0) { - fmt = fmt.replaceAll("<MC\\|([^|>]+)\\|([^|>]+)>", "$2"); - } + if (minValue <= 0 && maxValue <= 0) { fmt = fmt.replaceAll("<C\\|([^|>]+)\\|([^|>]+)>", "$1"); } + if (minValue >= 0 && maxValue >= 0) { fmt = fmt.replaceAll("<C\\|([^|>]+)\\|([^|>]+)>", "$2"); } + if (minPer <= 0 && maxPer <= 0) { fmt = fmt.replaceAll("<MC\\|(\\w+)\\|(\\w+)>", "$1"); } + if (minPer >= 0 && maxPer >= 0) { fmt = fmt.replaceAll("<MC\\|([^|>]+)\\|([^|>]+)>", "$2"); } if (fmt.contains("<") || fmt.contains(">")) { AffixLister.errOut.printf("WARN: Details for effect %s are malformatted (contains < or >):\n\t%s\n", type, fmt); } - sb.append(String.format(fmt, Math.abs(minValue), Math.abs(maxValue), duration, damageType.toLowerCase(), level, resist, name, Math.abs(minPer), Math.abs(maxPer), range, maxCount, pulse)); + sb.append(String.format(fmt, + Math.abs(minValue), Math.abs(maxValue), + duration, damageType.toLowerCase(), level, resist, name, + Math.abs(minPer), Math.abs(maxPer), range, maxCount, pulse)); } else { sb.append("No effect details for effect "); sb.append(type); - sb.append(String.format(" with parameters (min %.2f, max %.2f, dur %.2f, type %s, level %d)", minValue, maxValue, duration, damageType.toLowerCase(), level, name)); + sb.append(String.format( + " with parameters (min %.2f, max %.2f, dur %.2f, type %s, level %d)", + minValue, maxValue, duration, damageType.toLowerCase(), level, name)); if (AffixLister.addFileName) { sb.append(" from file "); @@ -267,6 +200,7 @@ public class Effect { if (statName != null) { sb.append(String.format(" (%.2f of stat %s", statPercent, statName)); + if (isStatBonus) sb.append(" as bonus)"); else sb.append(")"); } @@ -321,16 +255,14 @@ public class Effect { @Override public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; + if (this == obj) return true; + if (obj == null) return false; + if (getClass() != obj.getClass()) return false; + Effect other = (Effect) obj; + if (damageType == null) { - if (other.damageType != null) - return false; + if (other.damageType != null) return false; } else if (!damageType.equals(other.damageType)) return false; if (Double.doubleToLongBits(duration) != Double.doubleToLongBits(other.duration)) @@ -394,25 +326,26 @@ public class Effect { return true; } - /** - * Parse an effect. + /** Parse an effect. + * * @param afx The affix the effect belongs to. * @param scn The scanner to read from. * @param scnSource The name of the scanner. + * * @return An effect, read from the scanner. */ public static Effect parseEffect(Affix afx, Scanner scn, String scnSource) { return parseEffect(afx, scn, scnSource, new ArrayList<>()); } - /** - * Parse an effect. + /** Parse an effect. + * * @param afx The affix the effect belongs to. * @param scn The scanner to read from. * @param scnSource The name of the scanner. * @param errs Repository for errors found while parsing. - * @return An effect, read from the scanner. - */ + * + * @return An effect, read from the scanner. */ public static Effect parseEffect(Affix afx, Scanner scn, String scnSource, List<String> errs) { Effect efct = new Effect(); @@ -532,6 +465,4 @@ public class Effect { return efct; } - - } diff --git a/src/main/java/tlIItools/EffectRepo.java b/src/main/java/tlIItools/EffectRepo.java index f2f0d076..05151a48 100644 --- a/src/main/java/tlIItools/EffectRepo.java +++ b/src/main/java/tlIItools/EffectRepo.java @@ -1,40 +1,26 @@ package tlIItools; -import java.io.FileReader; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Scanner; +import java.io.*; +import java.util.*; import java.util.Map.Entry; -/** - * Repository class for storing information needed for parsing/outputing +/** Repository class for storing information needed for parsing/outputing * effects. * - * @author Ben Culkin - * - */ + * @author Ben Culkin */ public class EffectRepo { // NOTE: consider making these use function accessors in the future? // --bculkin, 6/24/20 - /** - * The list of detail strings for skills. - */ + + /** The list of detail strings for skills. */ public static Map<String, String> detals; - /** - * The list of detail strings for timed skills. - */ + /** The list of detail strings for timed skills. */ public static Map<String, String> timeDetals; - /** - * The list of replacements for detail strings. - */ + /** The list of replacements for detail strings. */ public static List<ReplPair> replList; - /* - * Init. lists from files. - */ + /* Init. lists from files. */ static { try (FileReader detalReader = new FileReader("data/affix-detals.txt")) { detals = readDetails(new Scanner(detalReader)); @@ -42,8 +28,7 @@ public class EffectRepo { AffixLister.errOut.println("Error loading affix detail text"); } - try (FileReader timedDetalReader - = new FileReader("data/timed-affix-detals.txt")) { + try (FileReader timedDetalReader = new FileReader("data/timed-affix-detals.txt")) { timeDetals = readDetails(new Scanner(timedDetalReader)); } catch (IOException ioex) { AffixLister.errOut.println("Error loading timed affix detail text"); @@ -56,36 +41,31 @@ public class EffectRepo { } } - /** - * Read effect detail strings from an input source. + /** Read effect detail strings from an input source. + * + * @param scn The source to read from. * - * @param scn - * The source to read from. - * @return The map of effect details to use. - */ + * @return The map of effect details to use. */ public static Map<String, String> readDetails(Scanner scn) { Map<String, String> detalMap = new HashMap<>(); return readDetails(detalMap, scn); } - /** - * Read effect detail strings from an input source, adding to an existing set. + /** Read effect detail strings from an input source, adding to an existing set. + * + * @param detalMap The details to add to. + * @param scn The source to read from. * - * @param detalMap - * The details to add to. - * @param scn - * The source to read from. - * @return The map of effect details to use. - */ - public static Map<String, String> readDetails(Map<String, String> detalMap, - Scanner scn) { + * @return The map of effect details to use. */ + public static Map<String, String> readDetails( + Map<String, String> detalMap, Scanner scn) + { while (scn.hasNextLine()) { String name = scn.nextLine().trim(); - if (name.equals("")) - continue; - if (name.startsWith("#")) - continue; + + if (name.equals("")) continue; + if (name.startsWith("#")) continue; String body; do { @@ -98,18 +78,17 @@ public class EffectRepo { return detalMap; } - /** - * Sanity check the loaded format strings. - */ + /** Sanity check the loaded format strings. */ public static void sanityCheckFormats() { for (Entry<String, String> detal : detals.entrySet()) { String fmt = detal.getValue(); - AffixLister.errOut.printf("\tTRACE: Applying replacements for %s\n", - detal.getKey()); + AffixLister.errOut.printf("\tTRACE: Applying replacements for %s\n", detal.getKey()); + for (ReplPair repl : replList) { String tmp = fmt; fmt = fmt.replaceAll(repl.find, repl.replace); + if (!fmt.equals(tmp)) { String outFmt = "\t\tTRACE: Replaced %s with %s: \n\t\t%s\n\t\t%s\n"; @@ -118,8 +97,7 @@ public class EffectRepo { } if (fmt.contains("<") || fmt.contains(">")) { - String warnFmt - = "WARN: Details for effect %s are malformated (contains < or >):\n\t%s\n"; + String warnFmt = "WARN: Details for effect %s are malformated (contains < or >):\n\t%s\n"; AffixLister.errOut.printf(warnFmt, detal.getKey(), fmt); } @@ -133,8 +111,7 @@ public class EffectRepo { } if (fmt.contains("<") || fmt.contains(">")) { - String warnFmt - = "WARN: Details for timed effect %s are malformatted (contains < or >):\n\t%s\n"; + String warnFmt = "WARN: Details for timed effect %s are malformatted (contains < or >):\n\t%s\n"; AffixLister.errOut.printf(warnFmt, detal.getKey(), fmt); } } diff --git a/src/main/java/tlIItools/Main.java b/src/main/java/tlIItools/Main.java index fa2617c5..a4d09bff 100644 --- a/src/main/java/tlIItools/Main.java +++ b/src/main/java/tlIItools/Main.java @@ -1,17 +1,12 @@ package tlIItools; -/** - * Main method for TLIITools +/** Main method for TLIITools * - * @author Ben Culkin - * - */ + * @author Ben Culkin */ public class Main { - /** - * Main method. + /** Main method. * - * @param args Unused CLI args. - */ + * @param args Unused CLI args. */ public static void main(String[] args) { // TODO implement this } diff --git a/src/main/java/tlIItools/NameFileReader.java b/src/main/java/tlIItools/NameFileReader.java index 8b1b62d4..a9646942 100644 --- a/src/main/java/tlIItools/NameFileReader.java +++ b/src/main/java/tlIItools/NameFileReader.java @@ -1,120 +1,71 @@ package tlIItools; -import java.io.FileReader; -import java.io.IOException; -import java.io.PrintStream; -import java.io.Reader; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Scanner; - -/** - * Reads in a list of file names to process. +import java.io.*; + +import java.util.*; + +/** Reads in a list of file names to process. * - * @author Ben Culkin - */ + * @author Ben Culkin */ public class NameFileReader { - /** - * Are we attempting to guess group names? - */ + /** Are we attempting to guess group names? */ public boolean guessGroups; - - /** - * Regex to use for guessing group names. - */ + /** Regex to use for guessing group names. */ public String groupRx; - - /** - * The default group to put files into. - */ + /** The default group to put files into. */ public String defGroup; - - /** - * The map of file groups. - */ + /** The map of file groups. */ public Map<String, List<String>> fNames; - /* - * The current group. - */ + /* The current group. */ private String curGroup; - /* - * The list of files for the current group. - */ + /* The list of files for the current group. */ private List<String> curList; - /** - * Counts the files read in. - */ + /** Counts the files read in. */ public int fCount; - /** - * Stream to write normal output to. - */ + /** Stream to write normal output to. */ public PrintStream normOut = System.out; - - /** - * Stream to write error output to. - */ + /** Stream to write error output to. */ public PrintStream errOut = System.err; - /** - * Create a new name reader using the default settings. + /** Create a new name reader using the default settings. * - * Guessing groups is disabled by default. - */ + * Guessing groups is disabled by default. */ public NameFileReader() { this(false); } - /** - * Create a new name reader using the default settings. + /** Create a new name reader using the default settings. * - * @param guessGroups - * Controls whether or not to try to guess file groups from file - * names. - */ + * @param guessGroups Controls whether or not to try to guess file groups from file names. */ public NameFileReader(boolean guessGroups) { this(new HashMap<>(), "default", guessGroups); } - /** - * Create a new name reader using the specified settings. - * - * @param fNames - * The set of groups to add files to. - * - * @param defGroup - * The name of the default file group. + /** Create a new name reader using the specified settings. * - * @param guessGroups - * Whether or not to attempt to guess group names. - */ + * @param fNames The set of groups to add files to. + * @param defGroup The name of the default file group. + * @param guessGroups Whether or not to attempt to guess group names. */ public NameFileReader(Map<String, List<String>> fNames, String defGroup, boolean guessGroups) { - if (!fNames.containsKey(defGroup)) - fNames.put(defGroup, new ArrayList<>()); + if (!fNames.containsKey(defGroup)) fNames.put(defGroup, new ArrayList<>()); this.fNames = fNames; - this.defGroup = defGroup; - + this.defGroup = defGroup; this.guessGroups = guessGroups; + this.curGroup = defGroup; - this.curGroup = defGroup; - this.curList = fNames.get(curGroup); + this.curList = fNames.get(curGroup); this.fCount = 0; } - /** - * Read in file names from a file. + /** Read in file names from a file. * - * @param from - * The name of the file to read from. - */ + * @param from The name of the file to read from. */ public void readFrom(String from) { try (FileReader fr = new FileReader(from)) { readFrom(fr); @@ -125,13 +76,9 @@ public class NameFileReader { } } - /** - * Read in file names from an input source. - * - * @param r - * The input source to read from. + /** Read in file names from an input source. * - */ + * @param r The input source to read from. */ public void readFrom(Reader r) { Scanner scn = new Scanner(r); @@ -160,12 +107,9 @@ public class NameFileReader { scn.close(); } - /** - * Swap to a new file group. + /** Swap to a new file group. * - * @param groupName - * The name of the group to swap to. - */ + * @param groupName The name of the group to swap to. */ public void swapGroup(String groupName) { curGroup = groupName; @@ -178,23 +122,19 @@ public class NameFileReader { } } - /** - * Add a file to this file reader. + /** Add a file to this file reader. * - * @param fName The file to add. - */ + * @param fName The file to add. */ public void addFile(String fName) { curList.add(fName); fCount += 1; } - /** - * Add a file to this file reader. + /** Add a file to this file reader. * - * @param groupName The group to add the file to. * - * @param fName The file to add. - */ + * @param groupName The group to add the file to. + * @param fName The file to add. */ public void addFile(String groupName, String fName) { fNames.computeIfAbsent(groupName, (key) -> new ArrayList<>()).add(fName); diff --git a/src/main/java/tlIItools/ReplPair.java b/src/main/java/tlIItools/ReplPair.java index 74012716..90717a0a 100644 --- a/src/main/java/tlIItools/ReplPair.java +++ b/src/main/java/tlIItools/ReplPair.java @@ -1,51 +1,31 @@ package tlIItools; -import java.util.ArrayList; -import java.util.List; -import java.util.Scanner; +import java.util.*; -/** - * String pairs for replacements. +/** String pairs for replacements. * - * @author Ben Culkin - */ + * @author Ben Culkin */ public class ReplPair implements Comparable<ReplPair> { - /** - * Represents an error encountered parsing ReplPairs + /** Represents an error encountered parsing ReplPairs * - * @author Ben Culkin - */ + * @author Ben Culkin */ public static class ReplError { - /** - * The line the error occured on. - */ + /** The line the error occured on. */ public int line; - /** - * The number of pairs we have processed so far. - */ + /** The number of pairs we have processed so far. */ public int numPairs; - /** - * The text of the line we errored on. - */ + /** The text of the line we errored on. */ public String txt; - /** - * The message of the error. - */ + /** The message of the error. */ public String msg; - /** - * Create a new ReplPair parse error. + /** Create a new ReplPair parse error. * - * @param lne - * The line the error occured on. - * @param nPairs - * The number of pairs processed up to this point. - * @param msg - * The message detailing the error. - * @param txt - * The text that caused the error. - */ + * @param lne The line the error occured on. + * @param nPairs The number of pairs processed up to this point. + * @param msg The message detailing the error. + * @param txt The text that caused the error. */ public ReplError(int lne, int nPairs, String msg, String txt) { line = lne; numPairs = nPairs; @@ -65,86 +45,56 @@ public class ReplPair implements Comparable<ReplPair> { } } - /** - * The priority for this replacement. - */ + /** The priority for this replacement. */ public int priority; - - /** - * The name of this replacement. + /** The name of this replacement. * - * Defaults to the 'find' string. - */ + * Defaults to the 'find' string. */ public String name; - /** - * The string to look for. - */ + /** The string to look for. */ public String find; - - /** - * The string to replace it with. - */ + /** The string to replace it with. */ public String replace; - /** - * Create a new blank replacement pair. - */ + /** Create a new blank replacement pair. */ public ReplPair() { this("", "", 1, null); } - /** - * Create a new replacement pair with a priority of 1. + /** Create a new replacement pair with a priority of 1. * - * @param f - * The string to find. - * @param r - * The string to replace. + * @param f The string to find. + * @param r The string to replace. */ public ReplPair(String f, String r) { this(f, r, 1); } - /** - * Create a new named replacement pair with a priority of 1. + /** Create a new named replacement pair with a priority of 1. * - * @param f - * The string to find. - * @param r - * The string to replace. - * @param n - * The name of the replacement pair. + * @param f The string to find. + * @param r The string to replace. + * @param n The name of the replacement pair. */ public ReplPair(String f, String r, String n) { this(f, r, 1, n); } - /** - * Create a new replacement pair with a set priority. + /** Create a new replacement pair with a set priority. * - * @param f - * The string to find. - * @param r - * The string to replace. - * @param p - * The priority for the replacement. - */ + * @param f The string to find. + * @param r The string to replace. + * @param p The priority for the replacement. */ public ReplPair(String f, String r, int p) { this(f, r, p, f); } - /** - * Create a new replacement pair with a set priority and name. + /** Create a new replacement pair with a set priority and name. * - * @param f - * The string to find. - * @param r - * The string to replace. - * @param n - * The name of the replacement pair. - * @param p - * The priority for the replacement. - */ + * @param f The string to find. + * @param r The string to replace. + * @param n The name of the replacement pair. + * @param p The priority for the replacement. */ public ReplPair(String f, String r, int p, String n) { find = f; replace = r; @@ -153,29 +103,23 @@ public class ReplPair implements Comparable<ReplPair> { priority = p; } - /** - * Read a list of replacement pairs from an input source. + + /** Read a list of replacement pairs from an input source. * - * @param scn - * The source to read the replacements from. - * @return - * The list of replacements. - */ + * @param scn The source to read the replacements from. + * + * @return The list of replacements. */ public static List<ReplPair> readList(Scanner scn) { return ReplPair.readList(new ArrayList<>(), scn); } - /** - * Read a list of replacement pairs from an input source, adding them to + /** Read a list of replacement pairs from an input source, adding them to * an existing list. * - * @param detals - * The list to add the replacements to. - * @param scn - * The source to read the replacements from. - * @return - * The list of replacements. - */ + * @param detals The list to add the replacements to. + * @param scn The source to read the replacements from. + * + * @return The list of replacements. */ public static List<ReplPair> readList(List<ReplPair> detals, Scanner scn) { List<ReplError> errList = new ArrayList<>(); @@ -186,25 +130,22 @@ public class ReplPair implements Comparable<ReplPair> { if (errList.size() == 0) errString = "An error"; else errString = "Errors"; - throw new IllegalArgumentException(String.format("%s occured parsing replacement pairs:\n%s", errString, errList)); + throw new IllegalArgumentException(String.format( + "%s occured parsing replacement pairs:\n%s", + errString, errList)); } return rplPar; } - /** - * Read a list of replacement pairs from an input source, adding them to + /** Read a list of replacement pairs from an input source, adding them to * an existing list. * - * @param detals - * The list to add the replacements to. - * @param scn - * The source to read the replacements from. - * @param errs - * The list to stick errors in. - * @return - * The list of replacements. - */ + * @param detals The list to add the replacements to. + * @param scn The source to read the replacements from. + * @param errs The list to stick errors in. + * + * @return The list of replacements. */ public static List<ReplPair> readList(List<ReplPair> detals, Scanner scn, List<ReplError> errs) { int lno = 0; int pno = 0; @@ -236,8 +177,7 @@ public class ReplPair implements Comparable<ReplPair> { // Read in the next uncommented line do { if (!scn.hasNextLine()) { - String msg = - "Ran out of input looking for replacement body for raw name " + name; + String msg = "Ran out of input looking for replacement body for raw name " + name; errs.add(new ReplError(lno, pno, msg, null)); break; @@ -247,7 +187,6 @@ public class ReplPair implements Comparable<ReplPair> { lno += 1; } while (body.startsWith("#")); - rp.replace = body; resList.add(rp); |
