// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . // ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· // ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ // ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ // ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ // 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 skillsGranted; private final ArrayList powersGranted; private int token = 0; private ArrayList effectsList = new ArrayList<>(); /** * No Table ID Constructor */ public BaseClass(String name, String description, byte strMod, byte dexMod, byte conMod, byte intMod, byte spiMod, ArrayList allowedRunes, ArrayList skillsGranted, ArrayList 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 allowedRunes, ArrayList skillsGranted, ArrayList 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 = SkillReq.getSkillReqsForRune(this.getObjectUUID()); this.powersGranted = PowerReq.getPowerReqsForRune(this.getObjectUUID()); this.effectsList = MobBaseEffects.getEffectsForRune(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 = SkillReq.getSkillReqsForRune(this.getObjectUUID()); this.powersGranted = PowerReq.getPowerReqsForRune(this.getObjectUUID()); this.effectsList = MobBaseEffects.getEffectsForRune(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 getRuneList() { return RuneBase.AllowedBaseClassRunesMap.get(this.getObjectUUID()); } public ArrayList getSkillsGranted() { return this.skillsGranted; } /* * Serializing */ public ArrayList getPowersGranted() { return this.powersGranted; } public ArrayList 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 getEffectsList() { return effectsList; } }