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();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user