Added test for "They Are Coming"

This commit is contained in:
marcin.sciesinski
2021-01-15 10:18:58 -08:00
parent 74f8afc744
commit f54363f2ef
7 changed files with 59 additions and 7 deletions

View File

@@ -811,11 +811,12 @@
"cost": { "cost": {
"type": "discardFromHand", "type": "discardFromHand",
"forced": false, "forced": false,
"count": 3 "count": 3,
"memorize": "discardedCards"
}, },
"effect": { "effect": {
"type": "playCardFromDiscard", "type": "playCardFromDiscard",
"filter": "choose(culture(moria),orc)" "filter": "choose(culture(moria),orc,not(memory(discardedCards)))"
} }
} }
}, },

View File

@@ -42,7 +42,7 @@ public class EffectAppenderFactory {
effectAppenderProducers.put("putonring", new PutOnRing()); effectAppenderProducers.put("putonring", new PutOnRing());
effectAppenderProducers.put("takeoffring", new TakeOffRing()); effectAppenderProducers.put("takeoffring", new TakeOffRing());
effectAppenderProducers.put("discardstackedcards", new DiscardStackedCards()); effectAppenderProducers.put("discardstackedcards", new DiscardStackedCards());
effectAppenderProducers.put("memorize", new Memorize()); effectAppenderProducers.put("memorize", new MemorizeActive());
effectAppenderProducers.put("memorizenumber", new MemorizeNumber()); effectAppenderProducers.put("memorizenumber", new MemorizeNumber());
effectAppenderProducers.put("preventwound", new PreventWound()); effectAppenderProducers.put("preventwound", new PreventWound());
effectAppenderProducers.put("preventexert", new PreventExert()); effectAppenderProducers.put("preventexert", new PreventExert());

View File

@@ -18,7 +18,7 @@ import org.json.simple.JSONObject;
import java.util.Collection; import java.util.Collection;
public class Memorize implements EffectAppenderProducer { public class MemorizeActive implements EffectAppenderProducer {
@Override @Override
public EffectAppender createEffectAppender(JSONObject effectObject, CardGenerationEnvironment environment) throws InvalidCardDefinitionException { public EffectAppender createEffectAppender(JSONObject effectObject, CardGenerationEnvironment environment) throws InvalidCardDefinitionException {
FieldUtils.validateAllowedFields(effectObject, "filter", "memory"); FieldUtils.validateAllowedFields(effectObject, "filter", "memory");

View File

@@ -74,12 +74,13 @@ public class Filters {
return getCardsMatchingFilter.getPhysicalCards(); return getCardsMatchingFilter.getPhysicalCards();
} }
public static Collection<PhysicalCard> filter(Collection<? extends PhysicalCard> cards, LotroGame game, Filterable... filters) { public static Collection<PhysicalCard> filter(Iterable<? extends PhysicalCard> cards, LotroGame game, Filterable... filters) {
Filter filter = Filters.and(filters); Filter filter = Filters.and(filters);
List<PhysicalCard> result = new LinkedList<PhysicalCard>(); List<PhysicalCard> result = new LinkedList<PhysicalCard>();
for (PhysicalCard card : cards) for (PhysicalCard card : cards) {
if (filter.accepts(game, card)) if (filter.accepts(game, card))
result.add(card); result.add(card);
}
return result; return result;
} }

View File

@@ -554,6 +554,10 @@ public class GameState {
return _allCards.get(cardId); return _allCards.get(cardId);
} }
public Iterable<? extends PhysicalCard> getAllCards() {
return Collections.unmodifiableCollection(_allCards.values());
}
public List<? extends PhysicalCard> getHand(String playerId) { public List<? extends PhysicalCard> getHand(String playerId) {
return Collections.unmodifiableList(_hands.get(playerId)); return Collections.unmodifiableList(_hands.get(playerId));
} }

View File

@@ -34,7 +34,7 @@ public abstract class AbstractAtTest {
protected static final String P2 = "player2"; protected static final String P2 = "player2";
protected PhysicalCardImpl createCard(String owner, String blueprintId) throws CardNotFoundException { protected PhysicalCardImpl createCard(String owner, String blueprintId) throws CardNotFoundException {
return new PhysicalCardImpl(cardId++, blueprintId, owner, _library.getLotroCardBlueprint(blueprintId)); return (PhysicalCardImpl) _game.getGameState().createPhysicalCard(owner, _library, blueprintId);
} }
protected void initializeSimplestGame() throws DecisionResultInvalidException { protected void initializeSimplestGame() throws DecisionResultInvalidException {

View File

@@ -0,0 +1,46 @@
package com.gempukku.lotro.at.effects;
import com.gempukku.lotro.at.AbstractAtTest;
import com.gempukku.lotro.common.Phase;
import com.gempukku.lotro.common.Zone;
import com.gempukku.lotro.game.CardNotFoundException;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.PhysicalCardImpl;
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
import org.junit.Test;
import java.util.Map;
import static junit.framework.Assert.assertEquals;
public class PlayCardFromDiscardAtTest extends AbstractAtTest {
@Test
public void cantPlayCardDiscardedWithTheyAreComing() throws Exception {
initializeSimplestGame();
final PhysicalCardImpl theyAreComing = createCard(P2, "1_196");
final PhysicalCardImpl goblinSneakInDiscard = createCard(P2, "1_181");
_game.getGameState().addCardToZone(_game, theyAreComing, Zone.SUPPORT);
_game.getGameState().addCardToZone(_game, goblinSneakInDiscard, Zone.DISCARD);
for (int i = 0; i < 3; i++) {
final PhysicalCardImpl goblinRunner = createCard(P2, "1_178");
_game.getGameState().addCardToZone(_game, goblinRunner, Zone.HAND);
}
skipMulligans();
_game.getGameState().setTwilight(10);
assertEquals(Phase.FELLOWSHIP, _game.getGameState().getCurrentPhase());
playerDecided(P1, "");
playerDecided(P2, getCardActionId(P2, "Use They Are Coming"));
Map<String, Object> decisionParameters = _userFeedback.getAwaitingDecision(P2).getDecisionParameters();
String[] cardId = (String[]) decisionParameters.get("cardId");
assertEquals(1, cardId.length);
assertEquals(String.valueOf(goblinSneakInDiscard.getCardId()), cardId[0]);
}
}