Exemplo n.º 1
0
 // In some versions, a transport can never unload into
 // multiple territories in a given turn.
 // In WW2V1 a transport can unload to multiple territories in
 // non-combat phase, provided they are both adjacent to the sea zone.
 public static boolean isTransportUnloadRestrictedToAnotherTerritory(
     final Unit transport, final Territory territory) {
   final Collection<Unit> unloaded = ((TripleAUnit) transport).getUnloaded();
   if (unloaded.isEmpty()) {
     return false;
   }
   // See if transport has unloaded anywhere yet
   final GameData data = transport.getData();
   for (final Unit u : unloaded) {
     final TripleAUnit taUnit = (TripleAUnit) u;
     if (isWW2V2(data) || isTransportUnloadRestricted(data)) {
       // cannot unload to two different territories
       if (!taUnit.getUnloadedTo().equals(territory)) {
         return true;
       }
     } else {
       // cannot unload to two different territories in combat phase
       if (!GameStepPropertiesHelper.isNonCombatMove(transport.getData(), true)
           && !taUnit.getUnloadedTo().equals(territory)) {
         return true;
       }
     }
   }
   return false;
 }
Exemplo n.º 2
0
 // If a transport has been in combat, it cannot load AND unload in non-combat
 public static boolean isTransportUnloadRestrictedInNonCombat(final Unit transport) {
   final TripleAUnit taUnit = (TripleAUnit) transport;
   if (GameStepPropertiesHelper.isNonCombatMove(transport.getData(), true)
       && taUnit.getWasInCombat()
       && taUnit.getWasLoadedAfterCombat()) {
     return true;
   }
   return false;
 }
Exemplo n.º 3
0
 public static boolean hasTransportUnloadedInPreviousPhase(final Unit transport) {
   final Collection<Unit> unloaded = ((TripleAUnit) transport).getUnloaded();
   // See if transport has unloaded anywhere yet
   for (final Unit u : unloaded) {
     final TripleAUnit taUnit = (TripleAUnit) u;
     // cannot unload in two different phases
     if (GameStepPropertiesHelper.isNonCombatMove(transport.getData(), true)
         && taUnit.getWasUnloadedInCombatPhase()) {
       return true;
     }
   }
   return false;
 }
Exemplo n.º 4
0
 public static int getAvailableCapacity(final Unit unit) {
   final UnitAttachment ua = UnitAttachment.get(unit.getType());
   // Check if there are transports available, also check for destroyer capacity (Tokyo Express)
   if (ua.getTransportCapacity() == -1
       || (unit.getData().getProperties().get(Constants.PACIFIC_THEATER, false)
           && ua.getIsDestroyer()
           && !unit.getOwner().getName().equals("Japanese"))) {
     return 0;
   }
   final int capacity = ua.getTransportCapacity();
   final int used = getCost(transporting(unit));
   final int unloaded = getCost(unloaded(unit));
   return capacity - used - unloaded;
 }