|
|
@ -30,73 +30,6 @@ public class dbEffectsResourceCostHandler extends dbHandlerBase { |
|
|
|
this.localObjectType = mbEnums.GameObjectType.valueOf(this.localClass.getSimpleName()); |
|
|
|
this.localObjectType = mbEnums.GameObjectType.valueOf(this.localClass.getSimpleName()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void GENERATE_COST_DATA() { |
|
|
|
|
|
|
|
ArrayList<String> effectList = GET_EFFECTS_WITH_COST(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (String effectID : effectList) { |
|
|
|
|
|
|
|
JSONObject costMap = GET_EFFECT_COSTMAP(effectID); |
|
|
|
|
|
|
|
WRITE_COSTMAP(effectID, costMap); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public JSONObject GET_EFFECT_COSTMAP(String effectID) { |
|
|
|
|
|
|
|
HashMap<mbEnums.ResourceType, Integer> costMap = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
|
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_power_effectcost` WHERE `IDString` = ?")) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
preparedStatement.setString(1, effectID); |
|
|
|
|
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (rs.next()) { |
|
|
|
|
|
|
|
mbEnums.ResourceType resourceType = mbEnums.ResourceType.resourceLookup.get(rs.getInt("resource")); |
|
|
|
|
|
|
|
int value = rs.getInt("amount"); |
|
|
|
|
|
|
|
costMap.put(resourceType, value); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
|
|
|
Logger.error(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return new JSONObject(costMap); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ArrayList<String> GET_EFFECTS_WITH_COST() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ArrayList<String> effectList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
|
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT DISTINCT `IDString` FROM `static_power_effectcost`")) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (rs.next()) { |
|
|
|
|
|
|
|
effectList.add(rs.getString("IdString")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
|
|
|
Logger.error(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return effectList; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean WRITE_COSTMAP(String effectID, JSONObject costmap) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
|
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO `static_effect_costmaps` (`effectID`, `costMap`) VALUES (?, ?) " + |
|
|
|
|
|
|
|
"ON DUPLICATE KEY UPDATE `costmap` = VALUES(`costmap`)")) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
preparedStatement.setString(1, effectID); |
|
|
|
|
|
|
|
preparedStatement.setString(2, costmap.toString()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (preparedStatement.executeUpdate() > 0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
|
|
|
Logger.error(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void LOAD_ALL_COSTMAPS() { |
|
|
|
public void LOAD_ALL_COSTMAPS() { |
|
|
|
|
|
|
|
|
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
@ -123,22 +56,4 @@ public class dbEffectsResourceCostHandler extends dbHandlerBase { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ArrayList<EffectsResourceCosts> GET_ALL_EFFECT_RESOURCES(String idString) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ArrayList<EffectsResourceCosts> effectsResourceCosts = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
|
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `static_power_effectcost` WHERE `IDString` = ?")) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
preparedStatement.setString(1, idString); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ResultSet rs = preparedStatement.executeQuery(); |
|
|
|
|
|
|
|
effectsResourceCosts = getObjectsFromRs(rs, 1000); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (SQLException e) { |
|
|
|
|
|
|
|
Logger.error(e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return effectsResourceCosts; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|