|
|
@ -18,6 +18,7 @@ import engine.net.client.ClientConnection; |
|
|
|
import engine.net.client.msg.*; |
|
|
|
import engine.net.client.msg.*; |
|
|
|
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.simple.JSONObject; |
|
|
|
import org.json.simple.JSONObject; |
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
|
|
|
|
|
|
|
@ -28,7 +29,7 @@ import java.util.concurrent.ConcurrentHashMap; |
|
|
|
|
|
|
|
|
|
|
|
public class Warehouse { |
|
|
|
public class Warehouse { |
|
|
|
|
|
|
|
|
|
|
|
public EnumSet<Enum.ResourceType> lockedResourceTypes; |
|
|
|
public EnumSet<Enum.ResourceType> locked; |
|
|
|
public int buildingUID; |
|
|
|
public int buildingUID; |
|
|
|
public City city; |
|
|
|
public City city; |
|
|
|
public ArrayList<Transaction> transactions = new ArrayList<>(); |
|
|
|
public ArrayList<Transaction> transactions = new ArrayList<>(); |
|
|
@ -45,6 +46,12 @@ public class Warehouse { |
|
|
|
resources.put(resourceType, value); |
|
|
|
resources.put(resourceType, value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
JSONArray lockedResources = (JSONArray) warehouse.get("locked"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (lockedResources.isEmpty() == false) |
|
|
|
|
|
|
|
for (Object o : lockedResources) |
|
|
|
|
|
|
|
this.locked.add(Enum.ResourceType.valueOf((String) o)); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void warehouseDeposit(MerchantMsg msg, PlayerCharacter player, NPC npc) { |
|
|
|
public static void warehouseDeposit(MerchantMsg msg, PlayerCharacter player, NPC npc) { |
|
|
@ -162,10 +169,10 @@ public class Warehouse { |
|
|
|
|
|
|
|
|
|
|
|
// toggle lock
|
|
|
|
// toggle lock
|
|
|
|
|
|
|
|
|
|
|
|
if (warehouse.lockedResourceTypes.contains(resourceType)) { |
|
|
|
if (warehouse.locked.contains(resourceType)) { |
|
|
|
|
|
|
|
|
|
|
|
boolean worked; |
|
|
|
boolean worked; |
|
|
|
warehouse.lockedResourceTypes.remove(resourceType); |
|
|
|
warehouse.locked.remove(resourceType); |
|
|
|
worked = DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse); |
|
|
|
worked = DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse); |
|
|
|
|
|
|
|
|
|
|
|
if (worked) { |
|
|
|
if (worked) { |
|
|
@ -176,17 +183,17 @@ public class Warehouse { |
|
|
|
dispatch = Dispatch.borrow(player, vrm); |
|
|
|
dispatch = Dispatch.borrow(player, vrm); |
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); |
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); |
|
|
|
} else |
|
|
|
} else |
|
|
|
warehouse.lockedResourceTypes.add(resourceType); |
|
|
|
warehouse.locked.add(resourceType); |
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
boolean worked; |
|
|
|
boolean worked; |
|
|
|
warehouse.lockedResourceTypes.add(resourceType); |
|
|
|
warehouse.locked.add(resourceType); |
|
|
|
worked = DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse); |
|
|
|
worked = DbManager.WarehouseQueries.UPDATE_WAREHOUSE(warehouse); |
|
|
|
|
|
|
|
|
|
|
|
if (worked) { |
|
|
|
if (worked) { |
|
|
|
warehouse.lockedResourceTypes.add(resourceType); |
|
|
|
warehouse.locked.add(resourceType); |
|
|
|
ViewResourcesMessage vrm = new ViewResourcesMessage(player); |
|
|
|
ViewResourcesMessage vrm = new ViewResourcesMessage(player); |
|
|
|
vrm.setGuild(player.getGuild()); |
|
|
|
vrm.setGuild(player.getGuild()); |
|
|
|
vrm.setWarehouseBuilding(warehouseBuilding); |
|
|
|
vrm.setWarehouseBuilding(warehouseBuilding); |
|
|
@ -194,7 +201,7 @@ public class Warehouse { |
|
|
|
dispatch = Dispatch.borrow(player, vrm); |
|
|
|
dispatch = Dispatch.borrow(player, vrm); |
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); |
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY); |
|
|
|
} else |
|
|
|
} else |
|
|
|
warehouse.lockedResourceTypes.remove(resourceType); |
|
|
|
warehouse.locked.remove(resourceType); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -602,7 +609,7 @@ public class Warehouse { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static boolean isResourceLocked(Warehouse warehouse, Enum.ResourceType resourceType) { |
|
|
|
public static boolean isResourceLocked(Warehouse warehouse, Enum.ResourceType resourceType) { |
|
|
|
return resourceType.elementOf(warehouse.lockedResourceTypes); |
|
|
|
return resourceType.elementOf(warehouse.locked); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |