diff options
| author | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2021-02-10 06:21:27 -0400 |
|---|---|---|
| committer | Benjamin J. Culkin <bjculkin@mix.wvu.edu> | 2021-02-10 06:21:27 -0400 |
| commit | aafd2d328e6a782a86056d354f3a7d9f1e6e4cdf (patch) | |
| tree | 684c314cbc81134eded638e320a85a01b7f53eeb | |
| parent | e65b232324ab7a50dfdae4744a9d411c4de1ffec (diff) | |
Bunch of AffixGroup changes
| -rw-r--r-- | src/main/java/tlIItools/Affix.java | 5 | ||||
| -rw-r--r-- | src/main/java/tlIItools/AffixGroup.java | 26 | ||||
| -rw-r--r-- | src/main/java/tlIItools/AffixLister.java | 13 | ||||
| -rw-r--r-- | src/main/java/tlIItools/EffectGroup.java | 30 | ||||
| -rw-r--r-- | src/main/java/tlIItools/LevelRange.java | 36 |
5 files changed, 81 insertions, 29 deletions
diff --git a/src/main/java/tlIItools/Affix.java b/src/main/java/tlIItools/Affix.java index 443e5095..c49e6e2a 100644 --- a/src/main/java/tlIItools/Affix.java +++ b/src/main/java/tlIItools/Affix.java @@ -140,6 +140,7 @@ public class Affix { public AffixGroup toAffixGroup() { AffixGroup group = new AffixGroup(); + group.type = type; group.enchantSources = enchantSources; group.equipTypes = equipTypes; group.nonequipTypes = nonequipTypes; @@ -228,7 +229,7 @@ public class Affix { sb.append("\tSpawn Weight: "); sb.append(weight); - sb.append("\n"); + sb.append("\t"); if (slots == 0) { sb.append("\tOccupies no slots\n"); @@ -241,7 +242,7 @@ public class Affix { if (effects.size() != 0) { sb.append("\tEffects: "); for (Effect eft : effects) { - sb.append("\n\t\t"); + if (effects.size() > 1) sb.append("\n\t\t"); sb.append(eft.toString()); } sb.append("\n"); diff --git a/src/main/java/tlIItools/AffixGroup.java b/src/main/java/tlIItools/AffixGroup.java index 61aab596..5835614d 100644 --- a/src/main/java/tlIItools/AffixGroup.java +++ b/src/main/java/tlIItools/AffixGroup.java @@ -56,25 +56,29 @@ public class AffixGroup implements Comparable<AffixGroup> { sb.append("Affix Type: "); sb.append(type); sb.append("\n"); -/* sb.append("Effects: \n"); + sb.append("Effects: "); + if (effects.size() > 1) sb.append("\n"); for (EffectGroup group : effects) { - sb.append("\t"); - sb.append(group); + if (effects.size() > 1) sb.append("\t"); + sb.append(group.summary()); sb.append("\n"); } -*/ - - sb.append("Affix can spawn on: "); - sb.append(String.join(", ", equipTypes)); - sb.append("\nAffix can't spawn on: "); - sb.append(String.join(", ", nonequipTypes)); - sb.append("\n"); if (type == AffixType.SOCKETABLE) { sb.append("Affix can be socketed into: "); + sb.append(String.join(", ", equipTypes)); + sb.append("\nAffix can spawn on: "); sb.append(String.join(", ", socketableTypes)); sb.append("\n"); - } else if (type == AffixType.ENCHANTMENT) { + } else { + sb.append("Affix can spawn on: "); + sb.append(String.join(", ", equipTypes)); + sb.append("\nAffix can't spawn on: "); + sb.append(String.join(", ", nonequipTypes)); + sb.append("\n"); + } + + if (type == AffixType.ENCHANTMENT) { sb.append("Affix can be enchanted by: "); sb.append(String.join(", ", socketableTypes)); sb.append("\n"); diff --git a/src/main/java/tlIItools/AffixLister.java b/src/main/java/tlIItools/AffixLister.java index ddb7da8a..c9cce52a 100644 --- a/src/main/java/tlIItools/AffixLister.java +++ b/src/main/java/tlIItools/AffixLister.java @@ -306,21 +306,26 @@ public class AffixLister { // Skip one-affix groups if (affixes.size() == 1) continue; + List<Affix> affixList = new ArrayList<>(affixes); + Collections.sort(affixList, (lhs, rhs) -> lhs.spawnRange.compareTo(rhs.spawnRange)); + boolean isFirstAfx = true; - for (Affix afx : affixes) { + for (Affix afx : affixList) { // @TODO actually implement this -bculkin, 12/29/2020 // Print the header for this group if (isFirstAfx) { isFirstAfx = false; - affixGroupDest.printf("Group ID %s (%d affixes)\n", + affixGroupDest.printf("Group ID %s (%d affixes)\t", group.hashCode(), affixes.size()); - affixGroupDest.println(group.groupSummary()); + affixGroupDest.print(group.groupSummary()); } - affixGroupDest.println(afx.toShortString()); + affixGroupDest.print("\t"); + affixGroupDest.print(afx.toShortString().replaceAll("\n(?=.)", "\n\t")); // print this affix in the group format } + affixGroupDest.println(); } } diff --git a/src/main/java/tlIItools/EffectGroup.java b/src/main/java/tlIItools/EffectGroup.java index 78e0324a..9f4ad49b 100644 --- a/src/main/java/tlIItools/EffectGroup.java +++ b/src/main/java/tlIItools/EffectGroup.java @@ -35,13 +35,39 @@ public class EffectGroup { public String summary() { StringBuilder sb = new StringBuilder(); + if (isTransfer) sb.append("Transfer: "); + sb.append(type); + if (name != null && !name.equals("")) { + sb.append(" (named "); + sb.append(name); + sb.append(")"); + } + + if (hasDuration) sb.append(" (timed)"); + if (statName != null && !name.equals("")) { + sb.append(" (uses stat "); + sb.append(statName); + if (isStatBonus) sb.append(" as a bonus"); + sb.append(")"); + } + + if (ownerLevel) sb.append(" (uses owner level)"); + if (useGraph) { + sb.append(" (uses "); + if (graphOverride != null && !graphOverride.equals("")) sb.append(graphOverride); + else sb.append("default"); + sb.append(" graph)"); + } + + if (exclusive) sb.append(" (exclusive)"); + // @TODO Ben Culkin 12/31/2020 :FancyEffectSummary // // EffectGroups should probably use something from EffectRepo to better // output the summary for a particular group type - String fmt = "%s (name %s, damageType %s, hasDuration %s, stat %s, isBonus %s, ownerLevel %s, useGraph %s, graphOverride %s, exclusive %s, isTransfer %s)"; + // String fmt = "%s (name %s, damageType %s, hasDuration %s, stat %s, isBonus %s, ownerLevel %s, useGraph %s, graphOverride %s, exclusive %s, isTransfer %s)"; - sb.append(String.format(fmt, type, name, damageType, hasDuration, statName, isStatBonus, ownerLevel, useGraph, graphOverride, exclusive, isTransfer)); + // sb.append(String.format(fmt, type, name, damageType, hasDuration, statName, isStatBonus, ownerLevel, useGraph, graphOverride, exclusive, isTransfer)); return sb.toString(); } diff --git a/src/main/java/tlIItools/LevelRange.java b/src/main/java/tlIItools/LevelRange.java index 015fae4e..b0d620bf 100644 --- a/src/main/java/tlIItools/LevelRange.java +++ b/src/main/java/tlIItools/LevelRange.java @@ -34,7 +34,7 @@ public class LevelRange implements Comparable<LevelRange> { private void clamp() { minLevel = Math.max(1, minLevel); - maxLevel = Math.max(999, maxLevel); + maxLevel = Math.min(999, maxLevel); } public boolean isUnrestricted() { @@ -82,26 +82,38 @@ public class LevelRange implements Comparable<LevelRange> { @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; + LevelRange other = (LevelRange) obj; clamp(); other.clamp(); - return maxLevel == other.maxLevel && minLevel == other.minLevel; + if (isUnrestricted() && other.isUnrestricted()) { + return true; + } else if (noLowerBound()) { + if (other.noLowerBound()) return maxLevel == other.maxLevel; + else return false; + } else if (noUpperBound()) { + if (other.noUpperBound()) return minLevel == other.minLevel; + else return false; + } else { + return maxLevel == other.maxLevel && minLevel == other.minLevel; + } } @Override public int compareTo(LevelRange other) { + clamp(); + other.clamp(); + if (this.equals(other)) return 0; // Unrestricted ranges sort above all others - if (isUnrestricted()) return 1; + if (isUnrestricted()) return 1; + if (other.isUnrestricted()) return -1; if (noLowerBound()) { if (other.noLowerBound()) { @@ -110,7 +122,11 @@ public class LevelRange implements Comparable<LevelRange> { return -1; } } else if (noUpperBound()) { - return minLevel - other.minLevel; + if (other.noUpperBound()) { + return minLevel - other.minLevel; + } else { + return 1; + } } else { if (minLevel == other.minLevel) return maxLevel - other.maxLevel; else return minLevel - other.minLevel; |
