|
|
@ -10,8 +10,10 @@ package engine.gameManager; |
|
|
|
|
|
|
|
|
|
|
|
import engine.loot.WorkOrder; |
|
|
|
import engine.loot.WorkOrder; |
|
|
|
import engine.mbEnums; |
|
|
|
import engine.mbEnums; |
|
|
|
import engine.net.client.msg.ErrorPopupMsg; |
|
|
|
import engine.objects.Item; |
|
|
|
import engine.objects.*; |
|
|
|
import engine.objects.ItemTemplate; |
|
|
|
|
|
|
|
import engine.objects.MobLoot; |
|
|
|
|
|
|
|
import engine.objects.Warehouse; |
|
|
|
import engine.powers.EffectsBase; |
|
|
|
import engine.powers.EffectsBase; |
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
|
|
|
|
|
|
|
@ -86,7 +88,12 @@ public enum ForgeManager implements Runnable { |
|
|
|
forgeManager.start(); |
|
|
|
forgeManager.start(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void submit(WorkOrder workOrder) { |
|
|
|
public static int submit(WorkOrder workOrder) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int validation_result = ForgeManager.validate(workOrder); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (validation_result != 0) |
|
|
|
|
|
|
|
return validation_result; |
|
|
|
|
|
|
|
|
|
|
|
workOrder.workOrderID = wordOrderCounter.incrementAndGet(); |
|
|
|
workOrder.workOrderID = wordOrderCounter.incrementAndGet(); |
|
|
|
workOrder.rollingDuration = ForgeManager.calcRollingDuration(workOrder); |
|
|
|
workOrder.rollingDuration = ForgeManager.calcRollingDuration(workOrder); |
|
|
@ -111,39 +118,33 @@ public enum ForgeManager implements Runnable { |
|
|
|
Logger.info(workOrder.toString()); |
|
|
|
Logger.info(workOrder.toString()); |
|
|
|
workOrder.vendor.workOrders.add(workOrder); |
|
|
|
workOrder.vendor.workOrders.add(workOrder); |
|
|
|
forge.add(workOrder); |
|
|
|
forge.add(workOrder); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return validation_result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static boolean validate(PlayerCharacter playerCharacter, WorkOrder workOrder) { |
|
|
|
public static int validate(WorkOrder workOrder) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int validation_result = 0; |
|
|
|
|
|
|
|
|
|
|
|
ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); |
|
|
|
ItemTemplate template = ItemTemplate.templates.get(workOrder.templateID); |
|
|
|
|
|
|
|
|
|
|
|
if (!workOrder.vendor.charItemManager.hasRoomInventory(template.item_wt)) { |
|
|
|
if (!workOrder.vendor.charItemManager.hasRoomInventory(template.item_wt)) |
|
|
|
if (playerCharacter != null) |
|
|
|
return 30; //30: That person cannot carry that item
|
|
|
|
ErrorPopupMsg.sendErrorPopup(playerCharacter, 30); //30: That person cannot carry that item
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!workOrder.vendor.getItemModTable().contains(((byte) template.modTable))) { |
|
|
|
if (!workOrder.vendor.getItemModTable().contains(((byte) template.modTable))) |
|
|
|
if (playerCharacter != null) |
|
|
|
return 59; //59: This hireling does not have this formula
|
|
|
|
ErrorPopupMsg.sendErrorPopup(playerCharacter, 59); //59: This hireling does not have this formula
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!calcCostOverrun(workOrder).isEmpty()) { |
|
|
|
|
|
|
|
if (playerCharacter != null) |
|
|
|
if (!calcCostOverrun(workOrder).isEmpty()) |
|
|
|
ErrorPopupMsg.sendErrorPopup(playerCharacter, 18); //18: You can't really afford that
|
|
|
|
return 10; //18: You can't really afford that
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Forge must be protected in order to access warehouse.
|
|
|
|
// Forge must be protected in order to access warehouse.
|
|
|
|
|
|
|
|
|
|
|
|
if (calcProductionCost(workOrder).size() > 1) |
|
|
|
if (calcProductionCost(workOrder).size() > 1) |
|
|
|
if (!workOrder.vendor.building.protectionState.equals(mbEnums.ProtectionState.PROTECTED)) { |
|
|
|
if (!workOrder.vendor.building.protectionState.equals(mbEnums.ProtectionState.PROTECTED)) |
|
|
|
if (playerCharacter != null) |
|
|
|
return 193; //193: Production denied: This building must be protected to gain access to warehouse
|
|
|
|
ErrorPopupMsg.sendErrorPopup(playerCharacter, 193); //193: Production denied: This building must be protected to gain access to warehouse
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return validation_result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static long calcRollingDuration(WorkOrder workOrder) { |
|
|
|
public static long calcRollingDuration(WorkOrder workOrder) { |
|
|
|