Optional triggers on one effect affect each other in playability.
This commit is contained in:
@@ -33,6 +33,7 @@ public class MusterRule {
|
||||
List<OptionalTriggerAction> actions = new LinkedList<OptionalTriggerAction>();
|
||||
for (PhysicalCard musterCard : Filters.filterActive(game.getGameState(), game.getModifiersQuerying(), Keyword.MUSTER)) {
|
||||
OptionalTriggerAction action = new OptionalTriggerAction("muster" + musterCard.getCardId(), musterCard);
|
||||
action.setText("Use Muster");
|
||||
action.appendCost(
|
||||
new ChooseAndDiscardCardsFromHandEffect(action, playerId, false, 1));
|
||||
action.appendEffect(
|
||||
|
||||
@@ -7,11 +7,12 @@ import com.gempukku.lotro.logic.decisions.AwaitingDecision;
|
||||
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
|
||||
import com.gempukku.lotro.logic.timing.DefaultLotroGame;
|
||||
import com.gempukku.lotro.logic.vo.LotroDeck;
|
||||
import static org.junit.Assert.fail;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public abstract class AbstractAtTest {
|
||||
protected static LotroCardBlueprintLibrary _library;
|
||||
|
||||
@@ -84,6 +85,14 @@ public abstract class AbstractAtTest {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String getCardActionId(AwaitingDecision awaitingDecision, String actionTextStart) {
|
||||
String[] actionTexts = (String[]) awaitingDecision.getDecisionParameters().get("actionText");
|
||||
for (int i = 0; i < actionTexts.length; i++)
|
||||
if (actionTexts[i].startsWith(actionTextStart))
|
||||
return ((String[]) awaitingDecision.getDecisionParameters().get("actionId"))[i];
|
||||
return null;
|
||||
}
|
||||
|
||||
private void addPlayerDeck(String player, Map<String, LotroDeck> decks, Map<String, Collection<String>> additionalCardsInDeck) {
|
||||
LotroDeck deck = createSimplestDeck();
|
||||
if (additionalCardsInDeck != null) {
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.gempukku.lotro.at;
|
||||
|
||||
import com.gempukku.lotro.common.Keyword;
|
||||
import com.gempukku.lotro.common.Phase;
|
||||
import com.gempukku.lotro.common.Zone;
|
||||
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 com.gempukku.lotro.logic.modifiers.KeywordModifier;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -13,6 +15,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
public class TriggersAtTest extends AbstractAtTest {
|
||||
@Test
|
||||
@@ -66,5 +69,134 @@ public class TriggersAtTest extends AbstractAtTest {
|
||||
validateContents(new String[]{"" + gimli.getCardId(), "" + stoutAndStrong.getCardId()}, (String[]) chooseTriggersDecision.getDecisionParameters().get("cardId"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void musterWorkingWithOtherOptionalStartOfRegroupTrigger() throws DecisionResultInvalidException {
|
||||
Map<String, Collection<String>> extraCards = new HashMap<String, Collection<String>>();
|
||||
initializeSimplestGame(extraCards);
|
||||
|
||||
PhysicalCardImpl dervorin = new PhysicalCardImpl(100, "7_88", P1, _library.getLotroCardBlueprint("7_88"));
|
||||
PhysicalCardImpl boromir = new PhysicalCardImpl(101, "1_96", P1, _library.getLotroCardBlueprint("1_96"));
|
||||
PhysicalCardImpl cardInHand1 = new PhysicalCardImpl(102, "4_57", P1, _library.getLotroCardBlueprint("4_57"));
|
||||
PhysicalCardImpl cardInHand2 = new PhysicalCardImpl(103, "4_57", P1, _library.getLotroCardBlueprint("4_57"));
|
||||
PhysicalCardImpl cardInHand3 = new PhysicalCardImpl(104, "4_57", P1, _library.getLotroCardBlueprint("4_57"));
|
||||
PhysicalCardImpl cardInHand4 = new PhysicalCardImpl(105, "4_57", P1, _library.getLotroCardBlueprint("4_57"));
|
||||
|
||||
skipMulligans();
|
||||
|
||||
_game.getGameState().addCardToZone(_game, dervorin, Zone.FREE_CHARACTERS);
|
||||
_game.getGameState().addCardToZone(_game, boromir, Zone.FREE_CHARACTERS);
|
||||
_game.getModifiersEnvironment().addUntilEndOfTurnModifier(
|
||||
new KeywordModifier(dervorin, dervorin, Keyword.MUSTER));
|
||||
|
||||
_game.getGameState().addCardToZone(_game, cardInHand1, Zone.HAND);
|
||||
_game.getGameState().addCardToZone(_game, cardInHand2, Zone.HAND);
|
||||
_game.getGameState().addCardToZone(_game, cardInHand3, Zone.HAND);
|
||||
_game.getGameState().addCardToZone(_game, cardInHand4, Zone.HAND);
|
||||
|
||||
// End fellowship phase
|
||||
playerDecided(P1, "");
|
||||
|
||||
// End shadow phase
|
||||
playerDecided(P2, "");
|
||||
|
||||
final AwaitingDecision optionalStartOfRegroupDecision = _userFeedback.getAwaitingDecision(P1);
|
||||
assertEquals(AwaitingDecisionType.CARD_ACTION_CHOICE, optionalStartOfRegroupDecision.getDecisionType());
|
||||
validateContents(new String[]{"" + dervorin.getCardId(), "" + dervorin.getCardId()}, (String[]) optionalStartOfRegroupDecision.getDecisionParameters().get("cardId"));
|
||||
|
||||
playerDecided(P1, getCardActionId(optionalStartOfRegroupDecision, "Optional "));
|
||||
|
||||
final AwaitingDecision optionalSecondStartOfRegroupDecision = _userFeedback.getAwaitingDecision(P1);
|
||||
assertEquals(AwaitingDecisionType.CARD_ACTION_CHOICE, optionalSecondStartOfRegroupDecision.getDecisionType());
|
||||
validateContents(new String[]{"" + dervorin.getCardId()}, (String[]) optionalSecondStartOfRegroupDecision.getDecisionParameters().get("cardId"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void userOfMusterAllowsUseOfOtherOptionalStartOfRegroupTrigger() throws DecisionResultInvalidException {
|
||||
Map<String, Collection<String>> extraCards = new HashMap<String, Collection<String>>();
|
||||
initializeSimplestGame(extraCards);
|
||||
|
||||
PhysicalCardImpl dervorin = new PhysicalCardImpl(100, "7_88", P1, _library.getLotroCardBlueprint("7_88"));
|
||||
PhysicalCardImpl boromir = new PhysicalCardImpl(101, "1_96", P1, _library.getLotroCardBlueprint("1_96"));
|
||||
PhysicalCardImpl cardInHand1 = new PhysicalCardImpl(102, "4_57", P1, _library.getLotroCardBlueprint("4_57"));
|
||||
PhysicalCardImpl cardInHand2 = new PhysicalCardImpl(103, "4_57", P1, _library.getLotroCardBlueprint("4_57"));
|
||||
PhysicalCardImpl cardInHand3 = new PhysicalCardImpl(104, "4_57", P1, _library.getLotroCardBlueprint("4_57"));
|
||||
PhysicalCardImpl cardInHand4 = new PhysicalCardImpl(105, "4_57", P1, _library.getLotroCardBlueprint("4_57"));
|
||||
PhysicalCardImpl cardInHand5 = new PhysicalCardImpl(106, "4_57", P1, _library.getLotroCardBlueprint("4_57"));
|
||||
|
||||
skipMulligans();
|
||||
|
||||
_game.getGameState().addCardToZone(_game, dervorin, Zone.FREE_CHARACTERS);
|
||||
_game.getGameState().addCardToZone(_game, boromir, Zone.FREE_CHARACTERS);
|
||||
_game.getModifiersEnvironment().addUntilEndOfTurnModifier(
|
||||
new KeywordModifier(dervorin, dervorin, Keyword.MUSTER));
|
||||
|
||||
_game.getGameState().addCardToZone(_game, cardInHand1, Zone.HAND);
|
||||
_game.getGameState().addCardToZone(_game, cardInHand2, Zone.HAND);
|
||||
_game.getGameState().addCardToZone(_game, cardInHand3, Zone.HAND);
|
||||
_game.getGameState().addCardToZone(_game, cardInHand4, Zone.HAND);
|
||||
_game.getGameState().addCardToZone(_game, cardInHand5, Zone.HAND);
|
||||
|
||||
// End fellowship phase
|
||||
playerDecided(P1, "");
|
||||
|
||||
// End shadow phase
|
||||
playerDecided(P2, "");
|
||||
|
||||
final AwaitingDecision optionalStartOfRegroupDecision = _userFeedback.getAwaitingDecision(P1);
|
||||
assertEquals(AwaitingDecisionType.CARD_ACTION_CHOICE, optionalStartOfRegroupDecision.getDecisionType());
|
||||
validateContents(new String[]{"" + dervorin.getCardId()}, (String[]) optionalStartOfRegroupDecision.getDecisionParameters().get("cardId"));
|
||||
|
||||
playerDecided(P1, getCardActionId(optionalStartOfRegroupDecision, "Use "));
|
||||
|
||||
playerDecided(P1, String.valueOf(cardInHand1.getCardId()));
|
||||
|
||||
final AwaitingDecision optionalSecondStartOfRegroupDecision = _userFeedback.getAwaitingDecision(P1);
|
||||
assertEquals(AwaitingDecisionType.CARD_ACTION_CHOICE, optionalSecondStartOfRegroupDecision.getDecisionType());
|
||||
validateContents(new String[]{"" + dervorin.getCardId()}, (String[]) optionalSecondStartOfRegroupDecision.getDecisionParameters().get("cardId"));
|
||||
assertTrue(((String[]) optionalSecondStartOfRegroupDecision.getDecisionParameters().get("actionText"))[0].startsWith("Optional "));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void userOfMusterDisablesUseOfOtherOptionalStartOfRegroupTrigger() throws DecisionResultInvalidException {
|
||||
Map<String, Collection<String>> extraCards = new HashMap<String, Collection<String>>();
|
||||
initializeSimplestGame(extraCards);
|
||||
|
||||
PhysicalCardImpl dervorin = new PhysicalCardImpl(100, "7_88", P1, _library.getLotroCardBlueprint("7_88"));
|
||||
PhysicalCardImpl boromir = new PhysicalCardImpl(101, "1_96", P1, _library.getLotroCardBlueprint("1_96"));
|
||||
PhysicalCardImpl cardInHand1 = new PhysicalCardImpl(102, "4_57", P1, _library.getLotroCardBlueprint("4_57"));
|
||||
PhysicalCardImpl cardInHand2 = new PhysicalCardImpl(103, "4_57", P1, _library.getLotroCardBlueprint("4_57"));
|
||||
PhysicalCardImpl cardInHand3 = new PhysicalCardImpl(104, "4_57", P1, _library.getLotroCardBlueprint("4_57"));
|
||||
PhysicalCardImpl cardInHand4 = new PhysicalCardImpl(105, "4_57", P1, _library.getLotroCardBlueprint("4_57"));
|
||||
|
||||
skipMulligans();
|
||||
|
||||
_game.getGameState().addCardToZone(_game, dervorin, Zone.FREE_CHARACTERS);
|
||||
_game.getGameState().addCardToZone(_game, boromir, Zone.FREE_CHARACTERS);
|
||||
_game.getModifiersEnvironment().addUntilEndOfTurnModifier(
|
||||
new KeywordModifier(dervorin, dervorin, Keyword.MUSTER));
|
||||
|
||||
_game.getGameState().addCardToZone(_game, cardInHand1, Zone.HAND);
|
||||
_game.getGameState().addCardToZone(_game, cardInHand2, Zone.HAND);
|
||||
_game.getGameState().addCardToZone(_game, cardInHand3, Zone.HAND);
|
||||
_game.getGameState().addCardToZone(_game, cardInHand4, Zone.HAND);
|
||||
|
||||
// End fellowship phase
|
||||
playerDecided(P1, "");
|
||||
|
||||
// End shadow phase
|
||||
playerDecided(P2, "");
|
||||
|
||||
final AwaitingDecision optionalStartOfRegroupDecision = _userFeedback.getAwaitingDecision(P1);
|
||||
assertEquals(AwaitingDecisionType.CARD_ACTION_CHOICE, optionalStartOfRegroupDecision.getDecisionType());
|
||||
validateContents(new String[]{"" + dervorin.getCardId(), "" + dervorin.getCardId()}, (String[]) optionalStartOfRegroupDecision.getDecisionParameters().get("cardId"));
|
||||
|
||||
playerDecided(P1, getCardActionId(optionalStartOfRegroupDecision, "Use "));
|
||||
playerDecided(P1, String.valueOf(cardInHand1.getCardId()));
|
||||
|
||||
final AwaitingDecision regroupPhaseActionDecision = _userFeedback.getAwaitingDecision(P1);
|
||||
assertEquals(AwaitingDecisionType.CARD_ACTION_CHOICE, regroupPhaseActionDecision.getDecisionType());
|
||||
validateContents(new String[]{}, (String[]) regroupPhaseActionDecision.getDecisionParameters().get("cardId"));
|
||||
|
||||
assertEquals(Phase.REGROUP, _game.getGameState().getCurrentPhase());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user