Normalize case and punctuation in DamageType.getDamageType

The validity check compared names case-sensitively, so mixed-case
input such as "Fire" or "Crushing" from static_power_failcondition and
static_power_poweraction, and SourceType names in the fortitude check,
all resolved to NONE. Input is now stripped of spaces, commas and
hyphens and upper-cased before lookup, so "Anti-Siege" maps to
ANTISIEGE as well.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
MagicBotandClaude Opus 5.5 committed 2026-10-15 20:18:38 -04:00
1 parent c14231afb9
commit 0fb1c078ad
1 file changed
+12 -20
+12 -20
View File
@@ -843,34 +843,26 @@ public class mbEnums {
public static DamageType getDamageType(String modName) {
String name;
if (modName.isEmpty())
return DamageType.NONE;
if(modName.toLowerCase().equals("blind"))
modName = "BLINDNESS";
// Client and DB strings vary in case and punctuation ("Fire", "Anti-Siege")
if(modName.toLowerCase().equals("powerblock"))
modName = "POWERINHIBITOR";
name = modName.replaceAll("[\\s,-]", "").toUpperCase();
//validity check for not looking up damage type that doesn't exist
boolean valid = false;
for(DamageType type : DamageType.values()){
if(type.name().equals(modName))
valid = true;
}
if (name.equals("BLIND"))
name = "BLINDNESS";
if(!valid)
return DamageType.NONE;
if (name.equals("POWERBLOCK"))
name = "POWERINHIBITOR";
DamageType damageType;
for (DamageType type : DamageType.values())
if (type.name().equals(name))
return type;
try {
damageType = DamageType.valueOf(modName.replace(",", "").toUpperCase());
} catch (Exception e) {
Logger.error(e);
return DamageType.NONE;
}
return damageType;
return DamageType.NONE;
}
}