Files
BattleBane/src/engine/db/handlers/dbEffectsResourceCostHandler.java
T

59 lines
2.3 KiB
Java
Raw Normal View History

2022-04-30 09:41:17 -04:00
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.db.handlers;
2023-05-21 17:34:31 -04:00
import engine.gameManager.DbManager;
2024-04-23 14:56:30 -04:00
import engine.gameManager.PowersManager;
import engine.mbEnums;
2022-04-30 09:41:17 -04:00
import engine.objects.EffectsResourceCosts;
import org.json.JSONObject;
2023-05-21 17:34:31 -04:00
import org.pmw.tinylog.Logger;
2022-04-30 09:41:17 -04:00
2023-05-21 17:34:31 -04:00
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
2022-04-30 09:41:17 -04:00
public class dbEffectsResourceCostHandler extends dbHandlerBase {
2023-05-23 10:27:03 -04:00
public dbEffectsResourceCostHandler() {
this.localClass = EffectsResourceCosts.class;
this.localObjectType = mbEnums.GameObjectType.valueOf(this.localClass.getSimpleName());
2023-05-23 10:27:03 -04:00
}
2023-05-21 17:34:31 -04:00
2024-04-23 14:56:30 -04:00
public void LOAD_ALL_COSTMAPS() {
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_effect_costmaps`")) {
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
String effectID = rs.getString("effectID");
String costString = rs.getString("costmap");
JSONObject costJSON = new JSONObject(costString);
HashMap<mbEnums.ResourceType, Integer> costmap = new HashMap<>();
for (String key : costJSON.keySet()) {
int value = costJSON.getInt(key);
costmap.put(mbEnums.ResourceType.valueOf(key), value);
}
PowersManager._effect_costMaps.put(effectID, costmap);
}
} catch (SQLException e) {
Logger.error(e);
}
}
2022-04-30 09:41:17 -04:00
}