Files
BattleBane/src/engine/objects/BaseClass.java
T
MagicBotandClaude Opus 5.5 c8c322a3f5 Load BaseClass from the class runes instead of static_rune_baseclass
LoadAllBaseClasses builds one BaseClass per CLASS rune with
rune_is_standard_character_creation (2500-2503; promotions and Pet are
skipped) and caches it. Race.baseClasses picks up the cached objects through
GET_BASECLASS_FOR_RACE. The SQL loader stays until task 2.11.

Value changes: description goes from '' to the rune_dsc class blurb (unread).
All other fields unchanged; final parity before the switch (scripts/p21.py):
4 rows, 0 differences in name, attribute mods, token, health/mana/stamina mods.
The static_rune_baseclass comparator is removed; it would only compare the
JSON with itself now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 09:55:09 -04:00

257 lines
8.0 KiB
Java

// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2026
// https://www.magicbane.com
package engine.objects;
import engine.gameManager.DbManager;
import engine.mbEnums;
import engine.net.ByteBufferWriter;
import engine.parsers.objects.RuneTemplate;
import engine.util.Hasher;
import org.pmw.tinylog.Logger;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
public class BaseClass extends AbstractGameObject {
private final String name;
private final String description;
private final byte strMod;
private final byte dexMod;
private final byte conMod;
private final byte intMod;
private final byte spiMod;
private final float healthMod;
private final float manaMod;
private final float staminaMod;
private final ArrayList<SkillReq> skillsGranted;
private final ArrayList<PowerReq> powersGranted;
private int token = 0;
private ArrayList<MobBaseEffects> effectsList = new ArrayList<>();
/**
* No Table ID Constructor
*/
public BaseClass(String name, String description, byte strMod, byte dexMod, byte conMod, byte intMod, byte spiMod,
ArrayList<RuneBase> allowedRunes, ArrayList<SkillReq> skillsGranted, ArrayList<PowerReq> powersGranted) {
super();
this.name = name;
this.description = description;
this.strMod = strMod;
this.dexMod = dexMod;
this.conMod = conMod;
this.intMod = intMod;
this.spiMod = spiMod;
this.healthMod = 1;
this.manaMod = 1;
this.staminaMod = 1;
this.skillsGranted = skillsGranted;
this.powersGranted = powersGranted;
}
/**
* Normal Constructor
*/
public BaseClass(String name, String description, byte strMod, byte dexMod, byte conMod, byte intMod, byte spiMod,
ArrayList<RuneBase> allowedRunes, ArrayList<SkillReq> skillsGranted, ArrayList<PowerReq> powersGranted, int newUUID) {
super(newUUID);
this.name = name;
this.description = description;
this.strMod = strMod;
this.dexMod = dexMod;
this.conMod = conMod;
this.intMod = intMod;
this.spiMod = spiMod;
this.healthMod = 1;
this.manaMod = 1;
this.staminaMod = 1;
this.skillsGranted = skillsGranted;
this.powersGranted = powersGranted;
}
/**
* ResultSet Constructor
*/
public BaseClass(ResultSet rs) throws SQLException {
super(rs);
this.name = rs.getString("name");
this.description = rs.getString("description");
this.strMod = rs.getByte("strMod");
this.dexMod = rs.getByte("dexMod");
this.conMod = rs.getByte("conMod");
this.intMod = rs.getByte("intMod");
this.spiMod = rs.getByte("spiMod");
this.token = rs.getInt("token");
this.healthMod = rs.getInt("healthMod");
this.manaMod = rs.getInt("manaMod");
this.staminaMod = rs.getInt("staminaMod");
this.skillsGranted = DbManager.SkillReqQueries.GET_REQS_FOR_RUNE(this.getObjectUUID());
this.powersGranted = PowerReq.getPowerReqsForRune(this.getObjectUUID());
this.effectsList = (DbManager.MobBaseQueries.GET_RUNEBASE_EFFECTS(this.getObjectUUID()));
}
/**
* Rune Template Constructor
*/
public BaseClass(RuneTemplate rune) {
super(rune.template_id);
this.name = rune.obj_name;
this.description = rune.rune_dsc;
this.strMod = rune.rune_attr_adj.getOrDefault(mbEnums.AttributeType.Strength, 0).byteValue();
this.dexMod = rune.rune_attr_adj.getOrDefault(mbEnums.AttributeType.Dexterity, 0).byteValue();
this.conMod = rune.rune_attr_adj.getOrDefault(mbEnums.AttributeType.Constitution, 0).byteValue();
this.intMod = rune.rune_attr_adj.getOrDefault(mbEnums.AttributeType.Intelligence, 0).byteValue();
this.spiMod = rune.rune_attr_adj.getOrDefault(mbEnums.AttributeType.Spirit, 0).byteValue();
this.token = Hasher.SBStringHash(rune.rune_sub_type);
this.healthMod = rune.rune_health;
this.manaMod = rune.rune_mana;
this.staminaMod = rune.rune_stamina;
this.skillsGranted = DbManager.SkillReqQueries.GET_REQS_FOR_RUNE(this.getObjectUUID());
this.powersGranted = PowerReq.getPowerReqsForRune(this.getObjectUUID());
this.effectsList = (DbManager.MobBaseQueries.GET_RUNEBASE_EFFECTS(this.getObjectUUID()));
}
public static void LoadAllBaseClasses() {
int loadedCount = 0;
// Promotion classes and the Pet class are also CLASS runes, but not standard creation runes
for (RuneTemplate rune : RuneTemplate._runes.values()) {
if (rune.rune_type != mbEnums.RuneType.CLASS || !rune.rune_is_standard_character_creation)
continue;
DbManager.addToCache(new BaseClass(rune));
loadedCount++;
}
Logger.info("Loaded " + loadedCount + " base classes from runes");
}
public static void serializeForClientMsg(BaseClass baseClass, ByteBufferWriter writer) {
serializeForClientMsg(baseClass, writer, 3);
}
public static void serializeForClientMsg(BaseClass baseClass, ByteBufferWriter writer, int type) {
writer.putInt(type); // For BaseClass
writer.putInt(0); // Pad
writer.putInt(baseClass.getObjectUUID());
writer.putInt(baseClass.getObjectType().ordinal()); // Is this correct?
writer.putInt(baseClass.getObjectUUID());
}
public static BaseClass getBaseClass(final int UUID) {
return DbManager.BaseClassQueries.GET_BASE_CLASS(UUID);
}
/*
* Getters
*/
public String getName() {
return name;
}
public String getDescription() {
return description;
}
public byte getStrMod() {
return strMod;
}
public byte getDexMod() {
return dexMod;
}
public byte getConMod() {
return conMod;
}
public byte getIntMod() {
return intMod;
}
public byte getSpiMod() {
return spiMod;
}
public int getToken() {
return this.token;
}
public float getHealthMod() {
return this.healthMod;
}
public float getManaMod() {
return this.manaMod;
}
public float getStaminaMod() {
return this.staminaMod;
}
public ArrayList<Integer> getRuneList() {
return RuneBase.AllowedBaseClassRunesMap.get(this.getObjectUUID());
}
public ArrayList<SkillReq> getSkillsGranted() {
return this.skillsGranted;
}
/*
* Serializing
*/
public ArrayList<PowerReq> getPowersGranted() {
return this.powersGranted;
}
public ArrayList<RuneBaseEffect> getEffectsGranted() {
return RuneBaseEffect.RuneIDBaseEffectMap.get(this.getObjectUUID());
}
/*
* Utils
*/
public boolean isAllowedRune(RuneBase rb) {
if (this.getRuneList().contains(rb.getObjectUUID()))
return true;
if (RuneBase.AllowedBaseClassRunesMap.containsKey(111111)) {
if (RuneBase.AllowedBaseClassRunesMap.get(111111).contains(rb.getObjectUUID()))
return true;
}
return false;
}
@Override
public void updateDatabase() {
; //Never update..
}
public ArrayList<MobBaseEffects> getEffectsList() {
return effectsList;
}
}