Browse Source

Refactor to remove abstraction.

master
MagicBot 2 years ago
parent
commit
4b0a3627d4
  1. 54
      src/engine/db/handlers/dbRuneBaseEffectHandler.java

54
src/engine/db/handlers/dbRuneBaseEffectHandler.java

@ -13,7 +13,12 @@ import engine.Enum.GameObjectType; @@ -13,7 +13,12 @@ import engine.Enum.GameObjectType;
import engine.gameManager.DbManager;
import engine.objects.AbstractGameObject;
import engine.objects.RuneBaseEffect;
import org.pmw.tinylog.Logger;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
@ -25,34 +30,49 @@ public class dbRuneBaseEffectHandler extends dbHandlerBase { @@ -25,34 +30,49 @@ public class dbRuneBaseEffectHandler extends dbHandlerBase {
}
public ArrayList<RuneBaseEffect> GET_EFFECTS_FOR_RUNEBASE(int id) {
prepareCallable("SELECT * FROM `static_rune_baseeffect` WHERE `runeID`=?");
setInt(1, id);
return getObjectList();
}
public RuneBaseEffect GET_RUNEBASE_EFFECT(int id) {
ArrayList<RuneBaseEffect> runeBaseEffectsList = new ArrayList<>();
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_rune_baseeffect` WHERE `runeID`=?")) {
preparedStatement.setInt(1, id);
ResultSet rs = preparedStatement.executeQuery();
runeBaseEffectsList = getObjectsFromRs(rs, 250);
if (id == 0)
return null;
RuneBaseEffect runeBaseEffect = (RuneBaseEffect) DbManager.getFromCache(GameObjectType.RuneBaseEffect, id);
if (runeBaseEffect != null)
return runeBaseEffect;
prepareCallable("SELECT * FROM `static_rune_baseeffect` WHERE `ID` = ?");
setInt(1, id);
return (RuneBaseEffect) getObjectSingle(id);
} catch (SQLException e) {
Logger.error(e);
}
return runeBaseEffectsList;
}
public ArrayList<RuneBaseEffect> GET_ALL_RUNEBASE_EFFECTS(){
prepareCallable("SELECT * FROM `static_rune_baseeffect`;");
return getObjectList();
public ArrayList<RuneBaseEffect> GET_ALL_RUNEBASE_EFFECTS() {
ArrayList<RuneBaseEffect> runeBaseEffectsList = new ArrayList<>();
try (Connection connection = DbManager.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_rune_baseeffect`;")) {
ResultSet rs = preparedStatement.executeQuery();
runeBaseEffectsList = getObjectsFromRs(rs, 250);
} catch (SQLException e) {
Logger.error(e);
}
return runeBaseEffectsList;
}
//This calls from cache only. Call this AFTER caching all runebase effects;
public HashMap<Integer, ArrayList<RuneBaseEffect>> LOAD_BASEEFFECTS_FOR_RUNEBASE() {
HashMap<Integer, ArrayList<RuneBaseEffect>> runeBaseEffectSet;
runeBaseEffectSet = new HashMap<>();
for (AbstractGameObject runeBaseEffect:DbManager.getList(GameObjectType.RuneBaseEffect)){
int runeBaseID = ((RuneBaseEffect)runeBaseEffect).getRuneBaseID();

Loading…
Cancel
Save