|
|
@ -9,19 +9,18 @@ |
|
|
|
|
|
|
|
|
|
|
|
package engine.db.handlers; |
|
|
|
package engine.db.handlers; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import engine.gameManager.DbManager; |
|
|
|
import engine.mbEnums; |
|
|
|
import engine.mbEnums; |
|
|
|
import engine.mbEnums.GameObjectType; |
|
|
|
import engine.mbEnums.GameObjectType; |
|
|
|
import engine.mbEnums.TransactionType; |
|
|
|
import engine.mbEnums.TransactionType; |
|
|
|
import engine.gameManager.DbManager; |
|
|
|
|
|
|
|
import engine.objects.Building; |
|
|
|
import engine.objects.Building; |
|
|
|
import engine.objects.City; |
|
|
|
import engine.objects.City; |
|
|
|
import engine.objects.Transaction; |
|
|
|
import engine.objects.Transaction; |
|
|
|
import engine.objects.Warehouse; |
|
|
|
import engine.objects.Warehouse; |
|
|
|
import engine.server.MBServerStatics; |
|
|
|
import engine.server.MBServerStatics; |
|
|
|
import org.joda.time.DateTime; |
|
|
|
import org.joda.time.DateTime; |
|
|
|
import org.json.simple.JSONArray; |
|
|
|
import org.json.JSONArray; |
|
|
|
import org.json.simple.JSONObject; |
|
|
|
import org.json.JSONObject; |
|
|
|
import org.json.simple.parser.JSONParser; |
|
|
|
|
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
|
|
|
|
|
|
|
|
import java.sql.Connection; |
|
|
|
import java.sql.Connection; |
|
|
@ -106,7 +105,7 @@ public class dbWarehouseHandler extends dbHandlerBase { |
|
|
|
JSONArray locks = new JSONArray(); |
|
|
|
JSONArray locks = new JSONArray(); |
|
|
|
|
|
|
|
|
|
|
|
for (mbEnums.ResourceType resource : warehouse.locked) |
|
|
|
for (mbEnums.ResourceType resource : warehouse.locked) |
|
|
|
locks.add(resource.name()); |
|
|
|
locks.put(resource.name()); |
|
|
|
|
|
|
|
|
|
|
|
warehouseJSON.put("locked", locks); |
|
|
|
warehouseJSON.put("locked", locks); |
|
|
|
|
|
|
|
|
|
|
@ -127,15 +126,13 @@ public class dbWarehouseHandler extends dbHandlerBase { |
|
|
|
|
|
|
|
|
|
|
|
public void LOAD_WAREHOUSES() { |
|
|
|
public void LOAD_WAREHOUSES() { |
|
|
|
|
|
|
|
|
|
|
|
JSONParser jsonParser = new JSONParser(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
try (Connection connection = DbManager.getConnection(); |
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_warehouse`;"); |
|
|
|
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM `dyn_warehouse`;"); |
|
|
|
ResultSet rs = preparedStatement.executeQuery()) { |
|
|
|
ResultSet rs = preparedStatement.executeQuery()) { |
|
|
|
|
|
|
|
|
|
|
|
while (rs.next()) { |
|
|
|
while (rs.next()) { |
|
|
|
int cityUID = rs.getInt("cityUUID"); |
|
|
|
int cityUID = rs.getInt("cityUUID"); |
|
|
|
JSONObject jsonObject = (JSONObject) jsonParser.parse(rs.getString("warehouse")); |
|
|
|
JSONObject jsonObject = new JSONObject(rs.getString("warehouse")); |
|
|
|
City city = City.getCity(cityUID); |
|
|
|
City city = City.getCity(cityUID); |
|
|
|
city.warehouse = new Warehouse(jsonObject); |
|
|
|
city.warehouse = new Warehouse(jsonObject); |
|
|
|
city.warehouse.city = city; |
|
|
|
city.warehouse.city = city; |
|
|
|