// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . // ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· // ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ // ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ // ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ // Magicbane Emulator Project © 2013 - 2022 // www.magicbane.com package engine.objects; import engine.Enum; import engine.gameManager.DbManager; import engine.net.ByteBufferWriter; import engine.server.MBServerStatics; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.HashMap; import java.util.concurrent.ConcurrentHashMap; public class RuneBase extends AbstractGameObject { private final String name; private final String description; private final int type; private final byte subtype; private final ConcurrentHashMap race = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); private final ConcurrentHashMap baseClass = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); private final ConcurrentHashMap promotionClass = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); private final ConcurrentHashMap discipline = new ConcurrentHashMap<>(MBServerStatics.CHM_INIT_CAP, MBServerStatics.CHM_LOAD, MBServerStatics.CHM_THREAD_LOW); private final ArrayList overwrite = new ArrayList<>(); private int levelRequired = 1; private ArrayList effectsList = new ArrayList<>(); public static HashMap> AllowedBaseClassRunesMap = new HashMap<>(); public static HashMap> AllowedRaceRunesMap = new HashMap<>(); /** * No Table ID Constructor */ public RuneBase(String name, String description, int type, byte subtype, ArrayList attrs) { super(); this.name = name; this.description = description; this.type = type; this.subtype = subtype; } /** * Normal Constructor */ public RuneBase(String name, String description, int type, byte subtype, ArrayList attrs, int newUUID) { super(newUUID); this.name = name; this.description = description; this.type = type; this.subtype = subtype; } /** * ResultSet Constructor */ public RuneBase(ResultSet rs) throws SQLException { super(rs); this.name = rs.getString("name"); this.description = rs.getString("description"); this.type = rs.getInt("type"); this.subtype = rs.getByte("subtype"); DbManager.RuneBaseQueries.GET_RUNE_REQS(this); this.effectsList = DbManager.MobBaseQueries.GET_RUNEBASE_EFFECTS(this.getObjectUUID()); } @Override public boolean equals(Object obj) { if (!super.equals(obj)) { return false; } if(obj instanceof RuneBase) { RuneBase rbObj = (RuneBase) obj; if (!this.name.equals(rbObj.name)) { return false; } if (!this.description.equals(rbObj.description)) { return false; } if (this.type != rbObj.type) { return false; } if (this.subtype != rbObj.subtype) { return false; } return true; } return false; } /* * Getters */ public String getName() { return name; } public String getDescription() { return description; } public int getType() { return type; } /** * @return the subtype */ public byte getSubtype() { return subtype; } /** * @return the attrs */ public ArrayList getAttrs() { return RuneBaseAttribute.runeBaseAttributeMap.get(this.getObjectUUID()); } public ConcurrentHashMap getRace() { return this.race; } public ConcurrentHashMap getBaseClass() { return this.baseClass; } public ConcurrentHashMap getPromotionClass() { return this.promotionClass; } public ConcurrentHashMap getDiscipline() { return this.discipline; } public ArrayList getOverwrite() { return this.overwrite; } public int getLevelRequired() { return this.levelRequired; } public void setLevelRequired(int levelRequired) { this.levelRequired = levelRequired; } public static RuneBase getRuneBase(int tableId) { if (tableId == 0) return null; RuneBase rb = (RuneBase) DbManager.getFromCache(Enum.GameObjectType.RuneBase, tableId); if (rb != null) return rb; return DbManager.RuneBaseQueries.GET_RUNEBASE(tableId); } /* * Serializing */ public static void serializeForClientMsg(RuneBase runeBase,ByteBufferWriter writer) { writer.putInt(runeBase.type); writer.putInt(0); // Pad writer.putInt(runeBase.getObjectUUID()); writer.putInt(runeBase.getObjectType().ordinal()); writer.putInt(runeBase.getObjectUUID()); } @Override public void updateDatabase() { // TODO Auto-generated method stub } /** * @return the effectsList */ public ArrayList getEffectsList() { return effectsList; } public static void LoadAllRuneBases(){ DbManager.RuneBaseQueries.LOAD_ALL_RUNEBASES(); RuneBase.AllowedBaseClassRunesMap = DbManager.RuneBaseQueries.LOAD_ALLOWED_STARTING_RUNES_FOR_BASECLASS(); RuneBase.AllowedRaceRunesMap = DbManager.RuneBaseQueries.LOAD_ALLOWED_STARTING_RUNES_FOR_RACE(); } }