- Finally fixed the Harrowdale (fingers crossed), added test to simulate different movement patterns.

This commit is contained in:
marcins78
2012-10-24 09:16:32 +00:00
parent a4315654d5
commit 0c171a68a6
3 changed files with 118 additions and 1 deletions

View File

@@ -91,6 +91,10 @@ public class DefaultActionsEnvironment implements ActionsEnvironment {
);
}
public List<ActionProxy> getUntilStartOfPhaseActionProxies(Phase phase) {
return _untilStartOfPhaseActionProxies.get(phase);
}
@Override
public void emitEffectResult(EffectResult effectResult) {
_effectResults.add(effectResult);

View File

@@ -32,7 +32,7 @@ public class ModifiersLogic implements ModifiersEnvironment, ModifiersQuerying {
@Override
public LimitCounter getUntilStartOfPhaseLimitCounter(PhysicalCard card, Phase phase) {
return getUntilEndOfPhaseLimitCounter(card, "", phase);
return getUntilStartOfPhaseLimitCounter(card, "", phase);
}
@Override
@@ -177,7 +177,18 @@ public class ModifiersLogic implements ModifiersEnvironment, ModifiersQuerying {
public void removeEndOfTurn() {
removeModifiers(_untilEndOfTurnModifiers);
_untilEndOfTurnModifiers.clear();
for (List<Modifier> modifiers : _untilStartOfPhaseModifiers.values())
removeModifiers(modifiers);
_untilStartOfPhaseModifiers.clear();
for (List<Modifier> modifiers : _untilEndOfPhaseModifiers.values())
removeModifiers(modifiers);
_untilEndOfPhaseModifiers.clear();
_turnLimitCounters.clear();
_startOfPhaseLimitCounters.clear();
_endOfPhaseLimitCounters.clear();
}
@Override

View File

@@ -0,0 +1,102 @@
package com.gempukku.lotro.at;
import com.gempukku.lotro.common.Phase;
import com.gempukku.lotro.common.Zone;
import com.gempukku.lotro.game.PhysicalCardImpl;
import com.gempukku.lotro.game.state.actions.DefaultActionsEnvironment;
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
import org.junit.Test;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNull;
public class HarrowdaleAtTest extends AbstractAtTest {
@Test
public void movesFromHarrowdale() throws DecisionResultInvalidException {
Map<String, Collection<String>> extraCards = new HashMap<String, Collection<String>>();
initializeSimplestGame(extraCards);
PhysicalCardImpl harrowdale = new PhysicalCardImpl(100, "11_243", P1, _library.getLotroCardBlueprint("11_243"));
harrowdale.setSiteNumber(1);
_game.getGameState().removeCardsFromZone(P1, Collections.singleton(_game.getGameState().getSite(1)));
_game.getGameState().addCardToZone(_game, harrowdale, Zone.ADVENTURE_PATH);
skipMulligans();
// Fellowship phase
assertEquals(Phase.FELLOWSHIP, _game.getGameState().getCurrentPhase());
assertEquals(1, ((DefaultActionsEnvironment) _game.getActionsEnvironment()).getUntilStartOfPhaseActionProxies(Phase.REGROUP).size());
playerDecided(P1, "");
// Move first time (from Harrowdale)
// Shadow phase
assertEquals(1, ((DefaultActionsEnvironment) _game.getActionsEnvironment()).getUntilStartOfPhaseActionProxies(Phase.REGROUP).size());
playerDecided(P2, "");
// End regroup phase
assertEquals(Phase.REGROUP, _game.getGameState().getCurrentPhase());
playerDecided(P1, "");
playerDecided(P2, "");
// Move again
playerDecided(P1, "0");
// Shadow phase
assertEquals(Phase.SHADOW, _game.getGameState().getCurrentPhase());
assertEquals(0, ((DefaultActionsEnvironment) _game.getActionsEnvironment()).getUntilStartOfPhaseActionProxies(Phase.REGROUP).size());
playerDecided(P2, "");
// End regroup phase
assertEquals(Phase.REGROUP, _game.getGameState().getCurrentPhase());
playerDecided(P1, "");
playerDecided(P2, "");
}
@Test
public void movesThroughHarrowdale() throws DecisionResultInvalidException {
Map<String, Collection<String>> extraCards = new HashMap<String, Collection<String>>();
initializeSimplestGame(extraCards);
PhysicalCardImpl harrowdale = new PhysicalCardImpl(100, "11_243", P1, _library.getLotroCardBlueprint("11_243"));
harrowdale.setSiteNumber(2);
_game.getGameState().addCardToZone(_game, harrowdale, Zone.ADVENTURE_PATH);
skipMulligans();
// Fellowship phase
assertEquals(Phase.FELLOWSHIP, _game.getGameState().getCurrentPhase());
assertNull(((DefaultActionsEnvironment) _game.getActionsEnvironment()).getUntilStartOfPhaseActionProxies(Phase.REGROUP));
playerDecided(P1, "");
// Move first time (to Harrowdale)
// Shadow phase
assertEquals(1, ((DefaultActionsEnvironment) _game.getActionsEnvironment()).getUntilStartOfPhaseActionProxies(Phase.REGROUP).size());
playerDecided(P2, "");
// End regroup phase
assertEquals(Phase.REGROUP, _game.getGameState().getCurrentPhase());
playerDecided(P1, "");
playerDecided(P2, "");
// Move again (from Harrowdale in regroup)
playerDecided(P1, "0");
// Shadow phase
assertEquals(Phase.SHADOW, _game.getGameState().getCurrentPhase());
assertEquals(0, ((DefaultActionsEnvironment) _game.getActionsEnvironment()).getUntilStartOfPhaseActionProxies(Phase.REGROUP).size());
playerDecided(P2, "");
// End regroup phase
assertEquals(Phase.REGROUP, _game.getGameState().getCurrentPhase());
assertEquals(0, ((DefaultActionsEnvironment) _game.getActionsEnvironment()).getUntilStartOfPhaseActionProxies(Phase.REGROUP).size());
playerDecided(P1, "");
playerDecided(P2, "");
}
}