Added more ATs

This commit is contained in:
Marcin Sciesinski
2024-10-18 17:26:13 +07:00
parent b9546e5cc8
commit f2fbe43ae7
17 changed files with 358 additions and 21 deletions

View File

@@ -256,8 +256,8 @@
type: playCardFromDiscard
select: self
extraEffects: {
type: removeFromTheGame
select: self
type: removePlayedEventFromTheGame
filter: self
}
}
}

View File

@@ -553,8 +553,8 @@
type: playCardFromDiscard
select: self
extraEffects: {
type: removeFromTheGame
select: self
type: removePlayedEventFromTheGame
filter: self
}
}
}

View File

@@ -417,8 +417,8 @@
type: playCardFromDiscard
select: self
extraEffects: {
type: removeFromTheGame
select: self
type: removePlayedEventFromTheGame
filter: self
}
}
}

View File

@@ -681,8 +681,8 @@
type: playCardFromDiscard
select: self
extraEffects: {
type: removeFromTheGame
select: self
type: removePlayedEventFromTheGame
filter: self
}
}
}

View File

@@ -169,8 +169,8 @@
type: playCardFromDiscard
select: self
extraEffects: {
type: removeFromTheGame
select: self
type: removePlayedEventFromTheGame
filter: self
}
}
}

View File

@@ -581,8 +581,8 @@
type: playCardFromDiscard
select: self
extraEffects: {
type: removeFromTheGame
select: self
type: removePlayedEventFromTheGame
filter: self
}
}
}

View File

@@ -316,8 +316,8 @@
type: playCardFromDiscard
select: self
extraEffects: {
type: removeFromTheGame
select: self
type: removePlayedEventFromTheGame
filter: self
}
}
}

View File

@@ -139,7 +139,7 @@
type: choice
texts: [
Exert an {elven} companion
Spot Arwern
Spot Arwen
]
effects: [
{
@@ -163,6 +163,7 @@
fromMemory: topCards
text: Choose cards to set aside
memorize: setAsideCards
count: 0-5
}
{
type: shuffleDeck

View File

@@ -147,6 +147,7 @@ public class EffectAppenderFactory {
effectAppenderProducers.put("removecardsindiscardfromgame", new RemoveCardsInDiscardFromGame());
effectAppenderProducers.put("removecharacterfromskirmish", new RemoveCharacterFromSkirmish());
effectAppenderProducers.put("removefromthegame", new RemoveFromTheGame());
effectAppenderProducers.put("removeplayedeventfromthegame", new RemovePlayedEventFromTheGame());
effectAppenderProducers.put("removekeyword", new RemoveKeyword());
effectAppenderProducers.put("removetext", new RemoveText());
effectAppenderProducers.put("removethreats", new RemoveThreats());

View File

@@ -58,7 +58,7 @@ public class ChooseArbitraryCards implements EffectAppenderProducer {
cards, selectableCards, minimum, maximum) {
@Override
public void decisionMade(String result) throws DecisionResultInvalidException {
actionContext.setValueToMemory(memorize, String.valueOf(getSelectedCardsByResponse(result)));
actionContext.setCardMemory(memorize, getSelectedCardsByResponse(result));
}
});
}

View File

@@ -0,0 +1,45 @@
package com.gempukku.lotro.cards.build.field.effect.appender;
import com.gempukku.lotro.cards.build.*;
import com.gempukku.lotro.cards.build.field.FieldUtils;
import com.gempukku.lotro.cards.build.field.effect.EffectAppender;
import com.gempukku.lotro.cards.build.field.effect.EffectAppenderProducer;
import com.gempukku.lotro.cards.build.field.effect.appender.resolver.CardResolver;
import com.gempukku.lotro.cards.build.field.effect.appender.resolver.PlayerResolver;
import com.gempukku.lotro.cards.build.field.effect.appender.resolver.ValueResolver;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.logic.actions.CostToEffectAction;
import com.gempukku.lotro.logic.effects.PutPlayedEventIntoHandEffect;
import com.gempukku.lotro.logic.effects.RemoveCardsFromTheGameEffect;
import com.gempukku.lotro.logic.effects.RemovePlayedEventFromTheGameEffect;
import com.gempukku.lotro.logic.timing.Effect;
import com.gempukku.lotro.logic.timing.results.PlayCardResult;
import org.json.simple.JSONObject;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
public class RemovePlayedEventFromTheGame implements EffectAppenderProducer {
@Override
public EffectAppender createEffectAppender(JSONObject effectObject, CardGenerationEnvironment environment) throws InvalidCardDefinitionException {
FieldUtils.validateAllowedFields(effectObject, "filter");
final String filter = FieldUtils.getString(effectObject.get("filter"), "filter", "self");
if (!filter.equalsIgnoreCase("self") && !filter.equalsIgnoreCase("played"))
throw new InvalidCardDefinitionException("Can only return either 'self' or 'played'");
return new DelayedAppender() {
@Override
protected Effect createEffect(boolean cost, CostToEffectAction action, ActionContext actionContext) {
if (filter.equalsIgnoreCase("played")) {
PhysicalCard playedCard = ((PlayCardResult) actionContext.getEffectResult()).getPlayedCard();
return new RemovePlayedEventFromTheGameEffect(playedCard);
} else {
return new RemovePlayedEventFromTheGameEffect(actionContext.getSource());
}
}
};
}
}

View File

@@ -287,8 +287,7 @@ public class CardResolver {
final PlayerSource playerSource = PlayerResolver.resolvePlayer(choicePlayer);
Function<ActionContext, Iterable<? extends PhysicalCard>> cardSource = actionContext -> {
String targetPlayerId = playerSource.getPlayer(actionContext);
return actionContext.getGame().getGameState().getDeadPile(targetPlayerId);
return actionContext.getGame().getGameState().getDeadPile(actionContext.getGame().getGameState().getCurrentPlayerId());
};
if (type.equals("self")) {

View File

@@ -0,0 +1,44 @@
package com.gempukku.lotro.logic.effects;
import com.gempukku.lotro.common.Zone;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.GameUtils;
import com.gempukku.lotro.logic.timing.AbstractEffect;
import java.util.Collections;
public class RemovePlayedEventFromTheGameEffect extends AbstractEffect {
private final PhysicalCard card;
public RemovePlayedEventFromTheGameEffect(PhysicalCard card) {
this.card = card;
}
@Override
public String getText(LotroGame game) {
return "Remove " + GameUtils.getFullName(card) + " from the game";
}
@Override
public Type getType() {
return null;
}
@Override
public boolean isPlayableInFull(LotroGame game) {
Zone zone = card.getZone();
return zone == Zone.VOID || zone == Zone.VOID_FROM_HAND;
}
@Override
protected FullEffectResult playEffectReturningResult(LotroGame game) {
if (isPlayableInFull(game)) {
game.getGameState().sendMessage(card.getOwner() + " removes " + GameUtils.getCardLink(card) + " from the game");
game.getGameState().removeCardsFromZone(card.getOwner(), Collections.singletonList(card));
game.getGameState().addCardToZone(game, card, Zone.REMOVED);
return new FullEffectResult(true);
}
return new FullEffectResult(false);
}
}

View File

@@ -98,8 +98,8 @@ public abstract class AbstractAtTest {
return _game.getGameState().getTokenCount(tomBombadilsHat, Token.findTokenForCulture(culture));
}
public void selectArbitraryCards(String player, String[] blueprintIds) throws DecisionResultInvalidException {
playerDecided(player, StringUtils.join(blueprintIds, ","));
public void selectArbitraryCards(String player, String... cardId) throws DecisionResultInvalidException {
playerDecided(player, StringUtils.join(cardId, ","));
}
public void selectCardAction(String player, PhysicalCard card) throws DecisionResultInvalidException {
@@ -338,6 +338,15 @@ public abstract class AbstractAtTest {
return null;
}
public String getArbitraryCardId(String playerId, String blueprintId) {
String[] blueprintIds = getAwaitingDecision(playerId).getDecisionParameters().get("blueprintId");
for (int i=0; i<blueprintIds.length; i++) {
if (blueprintIds[i].equals(blueprintId))
return getAwaitingDecision(playerId).getDecisionParameters().get("cardId")[i];
}
return null;
}
public void addPlayerDeck(String player, Map<String, LotroDeck> decks, Map<String, Collection<String>> additionalCardsInDeck) {
LotroDeck deck = createSimplestDeck();
if (additionalCardsInDeck != null) {

View File

@@ -157,7 +157,7 @@ public class DiscountAtTest extends AbstractAtTest {
assertEquals(Phase.SKIRMISH, getPhase());
selectCardAction(P2, defiled);
selectArbitraryCards(P2, new String[]{"temp0", "temp1", "temp2", "temp3"});
selectArbitraryCards(P2, "temp0", "temp1", "temp2", "temp3");
assertEquals(0, getTwilightPool());
assertEquals(Zone.DISCARD, defiled.getZone());

View File

@@ -0,0 +1,183 @@
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.PhysicalCard;
import org.junit.Test;
import java.util.List;
import static org.junit.Assert.assertEquals;
public class PutCardsAtTest extends AbstractAtTest {
@Test
public void putCardsFromDeckOnBottomOfDeck() throws Exception {
initializeSimplestGame();
PhysicalCard intoTheWest = addToZone(createCard(P1, "7_23"), Zone.SUPPORT);
PhysicalCard elrond = addToZone(createCard(P1, "1_40"), Zone.SUPPORT);
passUntil(Phase.FELLOWSHIP);
for (int i=0; i<2; i++) {
addToZone(createCard(P1, "1_3"), Zone.DECK);
}
passUntil(Phase.REGROUP);
List<? extends PhysicalCard> deck = _game.getGameState().getDeck(P1);
PhysicalCard topCardFromDeck = deck.get(0);
selectCardAction(P1, intoTheWest);
pass(P1);
pass(P2);
assertEquals(deck.get(1), topCardFromDeck);
}
@Test
public void putCardsFromDeckOnTopOfDeck() throws Exception {
initializeSimplestGame();
PhysicalCard arwen = addToZone(createCard(P1, "1_30"), Zone.FREE_CHARACTERS);
PhysicalCard backToTheLight = addToZone(createCard(P1, "18_6"), Zone.HAND);
PhysicalCard goblinRunner = addToZone(createCard(P2, "1_178"), Zone.SHADOW_CHARACTERS);
passUntil(Phase.FELLOWSHIP);
addToZone(createCard(P1, "1_3"), Zone.DECK);
addToZone(createCard(P1, "1_4"), Zone.DECK);
passUntil(Phase.MANEUVER);
selectCardAction(P1, backToTheLight);
playerDecided(P1, "1");
// Select cards to put aside
selectArbitraryCards(P1, getArbitraryCardId(P1, "1_3"), getArbitraryCardId(P1, "1_4"));
// Select cards order
selectArbitraryCards(P1, getArbitraryCardId(P1, "1_3"));
List<? extends PhysicalCard> deck = _game.getGameState().getDeck(P1);
assertEquals("1_4", deck.get(0).getBlueprintId());
assertEquals("1_3", deck.get(1).getBlueprintId());
}
@Test
public void putCardFromDiscardOnBottomOfDeck() throws Exception {
initializeSimplestGame();
PhysicalCard breedingPit = addToZone(createCard(P2, "1_122"), Zone.HAND);
passUntil(Phase.FELLOWSHIP);
setTwilightPool(10);
PhysicalCard urukSavageInDiscard = addToZone(createCard(P2, "1_151"), Zone.DISCARD);
PhysicalCard urukSavageInHand = addToZone(createCard(P2, "1_151"), Zone.HAND);
PhysicalCard urukSavageInDeck = addToZone(createCard(P2, "1_151"), Zone.DECK);
passUntil(Phase.SHADOW);
selectCardAction(P2, urukSavageInHand);
selectCardAction(P2, breedingPit);
List<? extends PhysicalCard> deck = _game.getGameState().getDeck(P2);
assertEquals(urukSavageInDiscard, deck.get(1));
}
@Test
public void putCardsFromDiscardOnTopOfDeck() throws Exception {
initializeSimplestGame();
PhysicalCard gondorStillStands = addToZone(createCard(P1, "7_95"), Zone.SUPPORT);
PhysicalCard citadelOfTheStars = addToZone(createCard(P1, "5_32"), Zone.DISCARD);
passUntil(Phase.REGROUP);
PhysicalCard urukSavageInDeck = addToZone(createCard(P1, "1_151"), Zone.DECK);
selectCardAction(P1, gondorStillStands);
List<? extends PhysicalCard> deck = _game.getGameState().getDeck(P1);
assertEquals(citadelOfTheStars, deck.get(0));
}
@Test
public void putCardsFromPlayOnBottomOfDeck() throws Exception {
initializeSimplestGame();
PhysicalCard ringBearer = getRingBearer(P1);
PhysicalCard braga = addToZone(createCard(P2, "33_25"), Zone.SHADOW_CHARACTERS);
PhysicalCard goblinRunner = addToZone(createCard(P2, "1_178"), Zone.SHADOW_CHARACTERS);
passUntil(Phase.ASSIGNMENT);
PhysicalCard urukSavageInDeck = addToZone(createCard(P2, "1_151"), Zone.DECK);
pass(P1);
pass(P2);
playerDecided(P1, ringBearer.getCardId()+" "+braga.getCardId());
pass(P2);
selectCard(P1, ringBearer);
pass(P1);
selectCardAction(P2, braga);
List<? extends PhysicalCard> deck = _game.getGameState().getDeck(P2);
assertEquals(goblinRunner, deck.get(1));
}
@Test
public void putCardsFromPlayOnTopOfDeck() throws Exception {
initializeSimplestGame();
PhysicalCard gladdenHomestead = addToZone(createCard(P1, "13_49"), Zone.SUPPORT);
PhysicalCard sarumansAmbition= addToZone(createCard(P2, "1_133"), Zone.SUPPORT);
PhysicalCard goblinRunner = addToZone(createCard(P2, "1_178"), Zone.SHADOW_CHARACTERS);
passUntil(Phase.MANEUVER);
PhysicalCard urukSavageInDeck = addToZone(createCard(P2, "1_151"), Zone.DECK);
selectCardAction(P1, gladdenHomestead);
List<? extends PhysicalCard> deck = _game.getGameState().getDeck(P2);
assertEquals(sarumansAmbition, deck.get(0));
}
@Test
public void putPlayedEventOnBottomOfDrawDeck() throws Exception {
initializeSimplestGame();
PhysicalCard tossMe = addToZone(createCard(P1, "6_11"), Zone.HAND);
passUntil(Phase.FELLOWSHIP);
PhysicalCard urukSavageInDeck = addToZone(createCard(P1, "1_151"), Zone.DECK);
selectCardAction(P1, tossMe);
playerDecided(P1, "1");
List<? extends PhysicalCard> deck = _game.getGameState().getDeck(P1);
assertEquals(tossMe, deck.get(1));
}
@Test
public void putPlayedEventOnTopOfDrawDeck() throws Exception {
initializeSimplestGame();
PhysicalCard tossMe = addToZone(createCard(P1, "6_11"), Zone.HAND);
passUntil(Phase.FELLOWSHIP);
PhysicalCard urukSavageInDeck = addToZone(createCard(P1, "1_151"), Zone.DECK);
selectCardAction(P1, tossMe);
playerDecided(P1, "0");
List<? extends PhysicalCard> deck = _game.getGameState().getDeck(P1);
assertEquals(tossMe, deck.get(0));
}
@Test
public void putRandomCardFromHandBeneathDrawDeck() throws Exception {
initializeSimplestGame();
PhysicalCard windInHisFace = addToZone(createCard(P1, "7_259"), Zone.HAND);
PhysicalCard eomer = addToZone(createCard(P1, "7_365"), Zone.FREE_CHARACTERS);
PhysicalCard swiftSteed = attachTo(createCard(P1, "7_253"), eomer);
PhysicalCard goblinRunner = addToZone(createCard(P2, "1_178"), Zone.SHADOW_CHARACTERS);
passUntil(Phase.ASSIGNMENT);
PhysicalCard urukSavageInDeck = addToZone(createCard(P2, "1_151"), Zone.DECK);
PhysicalCard urukSavageInHand = addToZone(createCard(P2, "1_151"), Zone.HAND);
pass(P1);
pass(P2);
playerDecided(P1, eomer.getCardId() + " " + goblinRunner.getCardId());
selectCard(P1, eomer);
selectCardAction(P1, windInHisFace);
List<? extends PhysicalCard> deck = _game.getGameState().getDeck(P2);
assertEquals(urukSavageInHand, deck.get(1));
}
}

View File

@@ -0,0 +1,55 @@
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.PhysicalCard;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class RemoveFromGameAtTest extends AbstractAtTest {
@Test
public void removeCardsInDeadPileFromGame() throws Exception {
initializeSimplestGame();
PhysicalCard ruffian = addToZone(createCard(P2, "18_72"), Zone.SHADOW_CHARACTERS);
PhysicalCard corsairHalberd = attachTo(createCard(P2, "18_63"), ruffian);
PhysicalCard gimliInDeadPile = addToZone(createCard(P1, "5_7"), Zone.DEAD);
passUntil(Phase.FELLOWSHIP);
pass(P1);
selectCardAction(P2, corsairHalberd);
assertEquals(Zone.REMOVED, gimliInDeadPile.getZone());
}
@Test
public void removeCardsInDeckFromGame() throws Exception {
initializeSimplestGame();
PhysicalCard grond = addToZone(createCard(P2, "18_82"), Zone.SUPPORT);
passUntil(Phase.FELLOWSHIP);
PhysicalCard gimliInDeck = addToZone(createCard(P1, "5_7"), Zone.DECK);
PhysicalCard aragornInDeck = addToZone(createCard(P1, "1_89"), Zone.DECK);
passUntil(Phase.REGROUP);
pass(P1);
pass(P2);
selectYes(P1);
selectCardAction(P2, grond);
assertEquals(Zone.REMOVED, gimliInDeck.getZone());
assertEquals(Zone.REMOVED, aragornInDeck.getZone());
}
@Test
public void removeFromTheGame() throws Exception {
initializeSimplestGame();
PhysicalCard ourTime = addToZone(createCard(P1, "18_24"), Zone.SUPPORT);
PhysicalCard goblinRunner = addToZone(createCard(P2, "1_178"), Zone.SHADOW_CHARACTERS);
passUntil(Phase.MANEUVER);
assertEquals(Zone.REMOVED, ourTime.getZone());
}
}