Files
Server/src/engine/objects/RuneBaseAttribute.java
T

134 lines
4.4 KiB
Java
Raw Normal View History

2026-07-26 19:08:44 -04:00
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2026
// https://www.magicbane.com
2022-04-30 09:41:17 -04:00
package engine.objects;
import engine.gameManager.DbManager;
import engine.mbEnums;
2024-05-12 13:36:47 -04:00
import engine.mbEnums.GameObjectType;
import engine.parsers.objects.RuneTemplate;
import engine.server.MBServerStatics;
2022-04-30 09:41:17 -04:00
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.EnumMap;
2022-04-30 09:41:17 -04:00
import java.util.HashMap;
public class RuneBaseAttribute extends AbstractGameObject {
2023-07-15 09:23:48 -04:00
public static HashMap<Integer, ArrayList<RuneBaseAttribute>> runeBaseAttributeMap = new HashMap<>();
private short attributeID;
private short modValue;
private int runeBaseID;
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
/**
* No Table ID Constructor
*/
public RuneBaseAttribute(short attributeID, short modValue) {
super();
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
this.attributeID = attributeID;
this.modValue = modValue;
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
/**
* Normal
*/
public RuneBaseAttribute(short attributeID, short modValue, int newUUID) {
super(newUUID);
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
this.attributeID = attributeID;
this.modValue = modValue;
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
/**
* ResultSet Constructor
*/
public RuneBaseAttribute(ResultSet rs) throws SQLException {
super(rs);
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
this.attributeID = rs.getShort("attributeID");
this.modValue = rs.getShort("modValue");
this.runeBaseID = rs.getInt("RuneBaseID");
}
2022-04-30 09:41:17 -04:00
// Attribute ids: 0 = rune_creation_cost, 1-5 = rune_attr_adj, 6-10 = rune_max_attr_adj,
// 11-15 = item_attr_req; the AttributeType ordinals Strength..Spirit are 1-5.
public static ArrayList<RuneBaseAttribute> getAttributesForRune(RuneTemplate rune) {
ArrayList<RuneBaseAttribute> attributes = new ArrayList<>();
if (rune.rune_creation_cost != 0)
attributes.add(new RuneBaseAttribute((short) MBServerStatics.RUNE_COST_ATTRIBUTE_ID, (short) rune.rune_creation_cost));
addAttributes(attributes, rune.rune_attr_adj, 0);
addAttributes(attributes, rune.rune_max_attr_adj, 5);
addAttributes(attributes, rune.item_attr_req, 10);
return attributes;
}
private static void addAttributes(ArrayList<RuneBaseAttribute> attributes, EnumMap<mbEnums.AttributeType, Integer> values, int idOffset) {
for (mbEnums.AttributeType attributeType : values.keySet()) {
if (values.get(attributeType) == 0)
continue;
attributes.add(new RuneBaseAttribute((short) (attributeType.ordinal() + idOffset), values.get(attributeType).shortValue()));
}
}
2023-07-15 09:23:48 -04:00
public static void LoadAllAttributes() {
DbManager.RuneBaseAttributeQueries.GET_ATTRIBUTES_FOR_RUNEBASE();
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
//cache attributeLists for rune.
for (AbstractGameObject ago : DbManager.getList(GameObjectType.RuneBaseAttribute)) {
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
RuneBaseAttribute runeBaseAttribute = (RuneBaseAttribute) ago;
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
int runeBaseID = ((RuneBaseAttribute) runeBaseAttribute).runeBaseID;
if (runeBaseAttributeMap.get(runeBaseID) == null) {
ArrayList<RuneBaseAttribute> attributeList = new ArrayList<>();
attributeList.add(runeBaseAttribute);
runeBaseAttributeMap.put(runeBaseID, attributeList);
} else {
ArrayList<RuneBaseAttribute> attributeList = runeBaseAttributeMap.get(runeBaseID);
attributeList.add(runeBaseAttribute);
runeBaseAttributeMap.put(runeBaseID, attributeList);
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
/*
* Getters
*/
public short getAttributeID() {
return attributeID;
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
public short getModValue() {
return modValue;
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
/*
* Utils
*/
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
@Override
public void updateDatabase() {
// TODO Auto-generated method stub
}
2022-04-30 09:41:17 -04:00
}