Build Race from its race rune and compare every field
Adds Race(RuneTemplate, Race): start/max attributes from rune_attr_adj/
rune_max_attr_adj (min is always 0), health/mana/stamina bonus from
rune_health/mana/stamina, startingPoints = 30 - rune_creation_cost, token =
SBStringHash(rune_sub_type), name from obj_name, description from rune_dsc,
hair/beard styles from rune_hair/rune_beard (style 0 when rune_hair is empty),
and baseClasses = the creation class runes whose item_race_req names the race
sub type. minHeight/strHeightMod come from the static_rune_race row; colors,
skills, powers and effects still load from the DB by rune id. A
static_rune_race comparator checks every field against a JSON-built Race.
Offline parity (scripts/p23.py, 26 rows + racebaseclass/hairstyle/beardstyle
vs the RACE runes): the 22 creation races match in every attribute, bonus,
startingPoints, token and base class. Differences:
- name: "Aelfborn, Male" -> "Aelfborn" on every row
- hair 0 dropped by the JSON on Aracoix M/F and Shade M/F (kept by the
empty-hair rule); beard 0 dropped on Shade M/F, Minotaur, Vampire F
- Minotaur hair 6958 -> 6598, Vampire M beard 5020170 -> 5020300
- 2018 Archon: startingPoints 0 -> 30, token 0 -> SBStringHash("Celestial"),
health 0 -> 20, stamina 0 -> 90
- 2019 Half-Giant-Old Man: str/dex/con/spi start and max, startingPoints
20 -> 15, health/mana/stamina 0 -> 10/5/70, baseClasses {} -> {Fighter}
- 2020/2021 CSR: stats 60/120 -> 40/100, startingPoints 0 -> 30, token 0 ->
SBStringHash("CSR"), health/mana/stamina 0 -> 40/40/10000
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
957293165b
commit
a30a065841
2 files changed
+152
No files matched your search
@@ -13,7 +13,10 @@ import engine.gameManager.DbManager;
|
||||
import engine.mbEnums;
|
||||
import engine.mbEnums.RaceType;
|
||||
import engine.net.ByteBufferWriter;
|
||||
import engine.parsers.cache.CacheParserUtil;
|
||||
import engine.parsers.objects.RuneTemplate;
|
||||
import engine.server.MBServerStatics;
|
||||
import engine.util.Hasher;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@@ -27,6 +30,9 @@ public class Race {
|
||||
|
||||
private static ConcurrentHashMap<Integer, Race> _raceByID = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW);
|
||||
|
||||
// Creation points before the race rune's rune_creation_cost is taken off
|
||||
private static final int STARTING_POINT_POOL = 30;
|
||||
|
||||
private final String name;
|
||||
private final String description;
|
||||
private final int raceRuneID;
|
||||
@@ -107,6 +113,80 @@ public class Race {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Rune Template Constructor
|
||||
* minHeight and strHeightMod are server-only and come from the static_rune_race row.
|
||||
*/
|
||||
public Race(RuneTemplate rune, Race dbRace) {
|
||||
|
||||
this.raceRuneID = rune.template_id;
|
||||
this.raceType = mbEnums.RaceType.getRaceTypebyRuneID(raceRuneID);
|
||||
this.name = rune.obj_name;
|
||||
this.description = rune.rune_dsc;
|
||||
this.strStart = rune.rune_attr_adj.getOrDefault(mbEnums.AttributeType.Strength, 0).shortValue();
|
||||
this.strMin = 0;
|
||||
this.strMax = rune.rune_max_attr_adj.getOrDefault(mbEnums.AttributeType.Strength, 0).shortValue();
|
||||
this.dexStart = rune.rune_attr_adj.getOrDefault(mbEnums.AttributeType.Dexterity, 0).shortValue();
|
||||
this.dexMin = 0;
|
||||
this.dexMax = rune.rune_max_attr_adj.getOrDefault(mbEnums.AttributeType.Dexterity, 0).shortValue();
|
||||
this.conStart = rune.rune_attr_adj.getOrDefault(mbEnums.AttributeType.Constitution, 0).shortValue();
|
||||
this.conMin = 0;
|
||||
this.conMax = rune.rune_max_attr_adj.getOrDefault(mbEnums.AttributeType.Constitution, 0).shortValue();
|
||||
this.intStart = rune.rune_attr_adj.getOrDefault(mbEnums.AttributeType.Intelligence, 0).shortValue();
|
||||
this.intMin = 0;
|
||||
this.intMax = rune.rune_max_attr_adj.getOrDefault(mbEnums.AttributeType.Intelligence, 0).shortValue();
|
||||
this.spiStart = rune.rune_attr_adj.getOrDefault(mbEnums.AttributeType.Spirit, 0).shortValue();
|
||||
this.spiMin = 0;
|
||||
this.spiMax = rune.rune_max_attr_adj.getOrDefault(mbEnums.AttributeType.Spirit, 0).shortValue();
|
||||
this.token = Hasher.SBStringHash(rune.rune_sub_type);
|
||||
this.healthBonus = (short) rune.rune_health;
|
||||
this.manaBonus = (short) rune.rune_mana;
|
||||
this.staminaBonus = (short) rune.rune_stamina;
|
||||
this.startingPoints = (byte) (STARTING_POINT_POOL - rune.rune_creation_cost);
|
||||
this.minHeight = dbRace.minHeight;
|
||||
this.strHeightMod = dbRace.strHeightMod;
|
||||
this.hairStyles = new HashSet<>(rune.rune_hair);
|
||||
this.beardStyles = new HashSet<>(rune.rune_beard);
|
||||
this.skinColors = DbManager.RaceQueries.SKIN_COLOR_FOR_RACE(raceRuneID);
|
||||
this.beardColors = DbManager.RaceQueries.BEARD_COLORS_FOR_RACE(raceRuneID);
|
||||
this.hairColors = DbManager.RaceQueries.HAIR_COLORS_FOR_RACE(raceRuneID);
|
||||
this.baseClasses = getBaseClassesForRace(rune);
|
||||
this.skillsGranted = DbManager.SkillReqQueries.GET_REQS_FOR_RUNE(raceRuneID);
|
||||
this.powersGranted = PowerReq.getPowerReqsForRune(raceRuneID);
|
||||
this.effectsList = DbManager.MobBaseQueries.GET_RUNEBASE_EFFECTS(this.raceRuneID);
|
||||
|
||||
// Races without hair styles (Aracoix, Shade) select style 0, which creation validates
|
||||
if (this.hairStyles.isEmpty())
|
||||
this.hairStyles.add(0);
|
||||
}
|
||||
|
||||
// Base classes are the creation class runes whose item_race_req names this race's sub type.
|
||||
// Every creation class rune's race list is a whitelist (restrict false).
|
||||
|
||||
private static ArrayList<BaseClass> getBaseClassesForRace(RuneTemplate rune) {
|
||||
|
||||
ArrayList<BaseClass> baseClasses = new ArrayList<>();
|
||||
mbEnums.MonsterType monsterType;
|
||||
BaseClass baseClass;
|
||||
|
||||
monsterType = CacheParserUtil.readEnum(mbEnums.MonsterType.class, rune.rune_sub_type, rune.template_id, "rune_sub_type");
|
||||
|
||||
for (RuneTemplate classRune : RuneTemplate._runes.values()) {
|
||||
if (classRune.rune_type != mbEnums.RuneType.CLASS || !classRune.rune_is_standard_character_creation)
|
||||
continue;
|
||||
|
||||
if (!classRune.item_race_req.contains(monsterType))
|
||||
continue;
|
||||
|
||||
baseClass = DbManager.BaseClassQueries.GET_BASE_CLASS(classRune.template_id);
|
||||
|
||||
if (baseClass != null)
|
||||
baseClasses.add(baseClass);
|
||||
}
|
||||
|
||||
return baseClasses;
|
||||
}
|
||||
|
||||
public static void loadAllRaces() {
|
||||
Race._raceByID = DbManager.RaceQueries.LOAD_ALL_RACES();
|
||||
}
|
||||
|
||||
+72
@@ -9,8 +9,13 @@
|
||||
package engine.parsers.cache;
|
||||
|
||||
import engine.gameManager.ConfigManager;
|
||||
import engine.mbEnums;
|
||||
import engine.objects.BaseClass;
|
||||
import engine.objects.Race;
|
||||
import engine.parsers.objects.RuneTemplate;
|
||||
import org.pmw.tinylog.Logger;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
@@ -28,6 +33,10 @@ public class ParityCheck {
|
||||
private int differenceCount = 0;
|
||||
private int missingCount = 0;
|
||||
|
||||
static {
|
||||
register("static_rune_race", ParityCheck::compareRaces);
|
||||
}
|
||||
|
||||
private ParityCheck(String table) {
|
||||
this.table = table;
|
||||
}
|
||||
@@ -81,4 +90,67 @@ public class ParityCheck {
|
||||
differenceCount++;
|
||||
Logger.warn("Parity: " + table + "/" + id + "/" + field + ": db=" + dbValue + " json=" + jsonValue);
|
||||
}
|
||||
|
||||
private static void compareRaces(ParityCheck check) {
|
||||
|
||||
Race race;
|
||||
Race jsonRace;
|
||||
RuneTemplate rune;
|
||||
int id;
|
||||
|
||||
for (mbEnums.RaceType raceType : mbEnums.RaceType.values()) {
|
||||
id = raceType.getRuneID();
|
||||
race = Race.getRace(id);
|
||||
|
||||
if (race == null) {
|
||||
Logger.warn("Parity: static_rune_race/" + id + ": not loaded from the db");
|
||||
continue;
|
||||
}
|
||||
|
||||
rune = RuneTemplate._runes.get(id);
|
||||
|
||||
if (rune != null && rune.rune_type != mbEnums.RuneType.RACE)
|
||||
rune = null;
|
||||
|
||||
if (!check.compareRow(id, rune))
|
||||
continue;
|
||||
|
||||
jsonRace = new Race(rune, race);
|
||||
|
||||
check.compareField(id, "name", race.getName(), jsonRace.getName());
|
||||
check.compareField(id, "strStart", race.getStrStart(), jsonRace.getStrStart());
|
||||
check.compareField(id, "strMin", race.getStrMin(), jsonRace.getStrMin());
|
||||
check.compareField(id, "strMax", race.getStrMax(), jsonRace.getStrMax());
|
||||
check.compareField(id, "dexStart", race.getDexStart(), jsonRace.getDexStart());
|
||||
check.compareField(id, "dexMin", race.getDexMin(), jsonRace.getDexMin());
|
||||
check.compareField(id, "dexMax", race.getDexMax(), jsonRace.getDexMax());
|
||||
check.compareField(id, "conStart", race.getConStart(), jsonRace.getConStart());
|
||||
check.compareField(id, "conMin", race.getConMin(), jsonRace.getConMin());
|
||||
check.compareField(id, "conMax", race.getConMax(), jsonRace.getConMax());
|
||||
check.compareField(id, "intStart", race.getIntStart(), jsonRace.getIntStart());
|
||||
check.compareField(id, "intMin", race.getIntMin(), jsonRace.getIntMin());
|
||||
check.compareField(id, "intMax", race.getIntMax(), jsonRace.getIntMax());
|
||||
check.compareField(id, "spiStart", race.getSpiStart(), jsonRace.getSpiStart());
|
||||
check.compareField(id, "spiMin", race.getSpiMin(), jsonRace.getSpiMin());
|
||||
check.compareField(id, "spiMax", race.getSpiMax(), jsonRace.getSpiMax());
|
||||
check.compareField(id, "token", race.getToken(), jsonRace.getToken());
|
||||
check.compareField(id, "healthBonus", race.getHealthBonus(), jsonRace.getHealthBonus());
|
||||
check.compareField(id, "manaBonus", race.getManaBonus(), jsonRace.getManaBonus());
|
||||
check.compareField(id, "staminaBonus", race.getStaminaBonus(), jsonRace.getStaminaBonus());
|
||||
check.compareField(id, "startingPoints", race.getStartingPoints(), jsonRace.getStartingPoints());
|
||||
check.compareField(id, "hairStyles", race.getHairStyles(), jsonRace.getHairStyles());
|
||||
check.compareField(id, "beardStyles", race.getBeardStyles(), jsonRace.getBeardStyles());
|
||||
check.compareField(id, "baseClasses", getObjectIds(race.getValidBaseClasses()), getObjectIds(jsonRace.getValidBaseClasses()));
|
||||
}
|
||||
}
|
||||
|
||||
private static HashSet<Integer> getObjectIds(Iterable<BaseClass> baseClasses) {
|
||||
|
||||
HashSet<Integer> ids = new HashSet<>();
|
||||
|
||||
for (BaseClass baseClass : baseClasses)
|
||||
ids.add(baseClass.getObjectUUID());
|
||||
|
||||
return ids;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user