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