// 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; }
// 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; }
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; }
public static Change unloadAirTransportChange( final TripleAUnit unit, final Territory territory, final PlayerID id, final boolean dependentBattle) { final CompositeChange change = new CompositeChange(); final TripleAUnit transport = (TripleAUnit) transportedBy(unit); if (transport == null) { return change; } assertTransport(transport); if (!transport.getTransporting().contains(unit)) { throw new IllegalStateException( "Not being carried, unit:" + unit + " transport:" + transport); } final ArrayList<Unit> newUnloaded = new ArrayList<Unit>(transport.getUnloaded()); newUnloaded.add(unit); change.add(ChangeFactory.unitPropertyChange(unit, territory, TripleAUnit.UNLOADED_TO)); if (!GameStepPropertiesHelper.isNonCombatMove(unit.getData(), true)) { change.add( ChangeFactory.unitPropertyChange(unit, true, TripleAUnit.UNLOADED_IN_COMBAT_PHASE)); // change.add(ChangeFactory.unitPropertyChange(unit, true, TripleAUnit.UNLOADED_AMPHIBIOUS)); change.add( ChangeFactory.unitPropertyChange(transport, true, TripleAUnit.UNLOADED_IN_COMBAT_PHASE)); // change.add(ChangeFactory.unitPropertyChange(transport, true, // TripleAUnit.UNLOADED_AMPHIBIOUS)); } if (!dependentBattle) { // TODO: this is causing issues with Scrambling. if the units were unloaded, then scrambling // creates a battle, there is no longer any // way to have the units removed if those transports die. change.add(ChangeFactory.unitPropertyChange(unit, null, TripleAUnit.TRANSPORTED_BY)); } // dependencies for battle calc and casualty selection include unloaded. therefore even if we // have unloaded this unit, it will die if // air transport dies IF we have the unloaded flat set. so don't set it. // TODO: fix this bullshit by re-writing entire transportation engine // change.add(ChangeFactory.unitPropertyChange(transport, newUnloaded, TripleAUnit.UNLOADED)); return change; }
public static Change unloadTransportChange( final TripleAUnit unit, final Territory territory, final PlayerID id, final boolean dependentBattle) { final CompositeChange change = new CompositeChange(); final TripleAUnit transport = (TripleAUnit) transportedBy(unit); if (transport == null) { return change; } assertTransport(transport); if (!transport.getTransporting().contains(unit)) { throw new IllegalStateException( "Not being carried, unit:" + unit + " transport:" + transport); } final ArrayList<Unit> newUnloaded = new ArrayList<Unit>(transport.getUnloaded()); newUnloaded.add(unit); change.add(ChangeFactory.unitPropertyChange(unit, territory, TripleAUnit.UNLOADED_TO)); if (!GameStepPropertiesHelper.isNonCombatMove(unit.getData(), true)) { change.add( ChangeFactory.unitPropertyChange(unit, true, TripleAUnit.UNLOADED_IN_COMBAT_PHASE)); change.add(ChangeFactory.unitPropertyChange(unit, true, TripleAUnit.UNLOADED_AMPHIBIOUS)); change.add( ChangeFactory.unitPropertyChange(transport, true, TripleAUnit.UNLOADED_IN_COMBAT_PHASE)); change.add( ChangeFactory.unitPropertyChange(transport, true, TripleAUnit.UNLOADED_AMPHIBIOUS)); } if (!dependentBattle) { // TODO: this is causing issues with Scrambling. if the units were unloaded, then scrambling // creates a battle, there is no longer any // way to have the units removed if those transports die. change.add(ChangeFactory.unitPropertyChange(unit, null, TripleAUnit.TRANSPORTED_BY)); } change.add(ChangeFactory.unitPropertyChange(transport, newUnloaded, TripleAUnit.UNLOADED)); return change; }