Playing "discount on" attachments (Asfaloth) test.

This commit is contained in:
marcins78@gmail.com
2011-12-01 19:35:46 +00:00
parent 0677f2dab0
commit 70dc6c2ffb
2 changed files with 64 additions and 5 deletions

View File

@@ -115,9 +115,6 @@ public class AttachPermanentAction extends AbstractCostToEffectAction implements
@Override
public Effect nextEffect(LotroGame game) {
if (_preCostIterator.hasNext())
return _preCostIterator.next();
if (!_cardRemoved) {
_cardRemoved = true;
game.getGameState().removeCardsFromZone(_cardToAttach.getOwner(), Collections.singleton(_cardToAttach));
@@ -128,6 +125,9 @@ public class AttachPermanentAction extends AbstractCostToEffectAction implements
return _chooseTargetEffect;
}
if (_preCostIterator.hasNext())
return _preCostIterator.next();
if (!_discountResolved) {
_discountResolved = true;
if (_discountEffect == null) {

View File

@@ -2,18 +2,19 @@ package com.gempukku.lotro.at;
import com.gempukku.lotro.common.Phase;
import com.gempukku.lotro.common.Zone;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.PhysicalCardImpl;
import com.gempukku.lotro.logic.decisions.AwaitingDecision;
import com.gempukku.lotro.logic.decisions.AwaitingDecisionType;
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
import static junit.framework.Assert.assertEquals;
import org.junit.Test;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import static junit.framework.Assert.assertEquals;
public class IndividualCardAtTest extends AbstractAtTest {
@Test
public void dwarvenAxeDoesNotFreeze() throws DecisionResultInvalidException {
@@ -70,4 +71,62 @@ public class IndividualCardAtTest extends AbstractAtTest {
assertEquals(Phase.REGROUP, _game.getGameState().getCurrentPhase());
assertEquals(Zone.DISCARD, goblinRunner.getZone());
}
@Test
public void playDiscountAsfalothOnArwen() throws DecisionResultInvalidException {
Map<String, Collection<String>> extraCards = new HashMap<String, Collection<String>>();
extraCards.put(P1, Arrays.asList("1_30", "1_31"));
initializeSimplestGame(extraCards);
// Play first character
AwaitingDecision firstCharacterDecision = _userFeedback.getAwaitingDecision(P1);
assertEquals(AwaitingDecisionType.ARBITRARY_CARDS, firstCharacterDecision.getDecisionType());
validateContents(new String[]{"1_30"}, ((String[]) firstCharacterDecision.getDecisionParameters().get("blueprintId")));
playerDecided(P1, getArbitraryCardId(firstCharacterDecision, "1_30"));
skipMulligans();
PhysicalCard asfaloth = _game.getGameState().getHand(P1).get(0);
final AwaitingDecision awaitingDecision = _userFeedback.getAwaitingDecision(P1);
assertEquals(AwaitingDecisionType.CARD_ACTION_CHOICE, awaitingDecision.getDecisionType());
validateContents(new String[]{"" + asfaloth.getCardId()}, (String[]) awaitingDecision.getDecisionParameters().get("cardId"));
assertEquals(0, _game.getGameState().getTwilightPool());
playerDecided(P1, "0");
assertEquals(0, _game.getGameState().getTwilightPool());
assertEquals(Zone.ATTACHED, asfaloth.getZone());
}
@Test
public void playDiscountAsfalothOnOtherElf() throws DecisionResultInvalidException {
Map<String, Collection<String>> extraCards = new HashMap<String, Collection<String>>();
extraCards.put(P1, Arrays.asList("1_51", "1_31"));
initializeSimplestGame(extraCards);
// Play first character
AwaitingDecision firstCharacterDecision = _userFeedback.getAwaitingDecision(P1);
assertEquals(AwaitingDecisionType.ARBITRARY_CARDS, firstCharacterDecision.getDecisionType());
validateContents(new String[]{"1_51"}, ((String[]) firstCharacterDecision.getDecisionParameters().get("blueprintId")));
playerDecided(P1, getArbitraryCardId(firstCharacterDecision, "1_51"));
skipMulligans();
PhysicalCard asfaloth = _game.getGameState().getHand(P1).get(0);
final AwaitingDecision awaitingDecision = _userFeedback.getAwaitingDecision(P1);
assertEquals(AwaitingDecisionType.CARD_ACTION_CHOICE, awaitingDecision.getDecisionType());
validateContents(new String[]{"" + asfaloth.getCardId()}, (String[]) awaitingDecision.getDecisionParameters().get("cardId"));
assertEquals(0, _game.getGameState().getTwilightPool());
playerDecided(P1, "0");
assertEquals(2, _game.getGameState().getTwilightPool());
assertEquals(Zone.ATTACHED, asfaloth.getZone());
}
}