Fixed all reported issues
This commit is contained in:
@@ -10,6 +10,7 @@ import com.gempukku.lotro.game.state.LotroGame;
|
||||
import com.gempukku.lotro.logic.GameUtils;
|
||||
import com.gempukku.lotro.logic.actions.CostToEffectAction;
|
||||
import com.gempukku.lotro.logic.effects.ChooseActiveCardsEffect;
|
||||
import com.gempukku.lotro.logic.effects.ChooseArbitraryCardsEffect;
|
||||
import com.gempukku.lotro.logic.effects.choose.ChooseCardsFromDeckEffect;
|
||||
import com.gempukku.lotro.logic.effects.choose.ChooseCardsFromDiscardEffect;
|
||||
import com.gempukku.lotro.logic.effects.choose.ChooseCardsFromHandEffect;
|
||||
@@ -38,7 +39,7 @@ public class CardResolver {
|
||||
String memory, String choicePlayer, String choiceText, CardGenerationEnvironment environment) throws InvalidCardDefinitionException {
|
||||
Function<ActionContext, Iterable<? extends PhysicalCard>> cardSource = actionContext -> {
|
||||
final Filterable stackedOnFilter = stackedOn.getFilterable(actionContext);
|
||||
return Filters.filterActive(actionContext.getGame(), Filters.stackedOn(stackedOnFilter));
|
||||
return Filters.filter(actionContext.getGame().getGameState().getAllCards(), actionContext.getGame(), Filters.stackedOn(stackedOnFilter));
|
||||
};
|
||||
|
||||
if (type.startsWith("memory(") && type.endsWith(")")) {
|
||||
@@ -107,18 +108,29 @@ public class CardResolver {
|
||||
} else if (type.startsWith("choose(") && type.endsWith(")")) {
|
||||
final PlayerSource playerSource = PlayerResolver.resolvePlayer(choicePlayer, environment);
|
||||
ChoiceEffectSource effectSource = (possibleCards, action, actionContext, min, max) -> {
|
||||
String handId = handSource.getPlayer(actionContext);
|
||||
String choicePlayerId = playerSource.getPlayer(actionContext);
|
||||
return new ChooseCardsFromHandEffect(choicePlayerId, min, max, Filters.in(possibleCards)) {
|
||||
@Override
|
||||
protected void cardsSelected(LotroGame game, Collection<PhysicalCard> cards) {
|
||||
actionContext.setCardMemory(memory, cards);
|
||||
}
|
||||
if (handId.equals(choicePlayerId)) {
|
||||
return new ChooseCardsFromHandEffect(choicePlayerId, min, max, Filters.in(possibleCards)) {
|
||||
@Override
|
||||
protected void cardsSelected(LotroGame game, Collection<PhysicalCard> cards) {
|
||||
actionContext.setCardMemory(memory, cards);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(LotroGame game) {
|
||||
return choiceText;
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public String getText(LotroGame game) {
|
||||
return choiceText;
|
||||
}
|
||||
};
|
||||
} else {
|
||||
List<? extends PhysicalCard> cardsInHand = actionContext.getGame().getGameState().getHand(handId);
|
||||
return new ChooseArbitraryCardsEffect(choicePlayerId, choiceText, cardsInHand, Filters.in(possibleCards), min, max, false) {
|
||||
@Override
|
||||
protected void cardsSelected(LotroGame game, Collection<PhysicalCard> selectedCards) {
|
||||
actionContext.setCardMemory(memory, selectedCards);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
return resolveChoiceCards(type, additionalFilter, additionalFilter, countSource, environment, cardSource, effectSource);
|
||||
@@ -307,8 +319,12 @@ public class CardResolver {
|
||||
return new DelayedAppender() {
|
||||
@Override
|
||||
public boolean isPlayableInFull(ActionContext actionContext) {
|
||||
int min = countSource.getMinimum(actionContext);
|
||||
return filterCards(actionContext, playabilityFilter).size() >= min;
|
||||
if (playabilityFilter != null) {
|
||||
int min = countSource.getMinimum(actionContext);
|
||||
return filterCards(actionContext, playabilityFilter).size() >= min;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.gempukku.lotro.at.effects;
|
||||
|
||||
import com.gempukku.lotro.at.AbstractAtTest;
|
||||
import com.gempukku.lotro.common.Zone;
|
||||
import com.gempukku.lotro.game.PhysicalCardImpl;
|
||||
import com.gempukku.lotro.logic.decisions.AwaitingDecisionType;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class ConditionalAtTest extends AbstractAtTest {
|
||||
@Test
|
||||
public void savageryToMatchTheirNumbersOffersAChoice() throws Exception {
|
||||
initializeSimplestGame();
|
||||
|
||||
skipMulligans();
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
final PhysicalCardImpl pippin = createCard(P1, "1_306");
|
||||
_game.getGameState().addCardToZone(_game, pippin, Zone.FREE_CHARACTERS);
|
||||
}
|
||||
|
||||
PhysicalCardImpl troopOfUrukHai = createCard(P2, "1_143");
|
||||
_game.getGameState().addCardToZone(_game, troopOfUrukHai, Zone.SHADOW_CHARACTERS);
|
||||
|
||||
PhysicalCardImpl savageryToMatchTheirNumbers = createCard(P2, "1_139");
|
||||
_game.getGameState().addCardToZone(_game, savageryToMatchTheirNumbers, Zone.HAND);
|
||||
|
||||
// End Fellowship
|
||||
playerDecided(P1, "");
|
||||
|
||||
// End Shadow
|
||||
playerDecided(P2, "");
|
||||
|
||||
// End Maneuvers
|
||||
playerDecided(P1, "");
|
||||
playerDecided(P2, "");
|
||||
|
||||
// End Archery
|
||||
playerDecided(P1, "");
|
||||
playerDecided(P2, "");
|
||||
|
||||
// End assignment phase
|
||||
playerDecided(P1, "");
|
||||
playerDecided(P2, "");
|
||||
|
||||
playerDecided(P1, _game.getGameState().getRingBearer(P1).getCardId() + " " + troopOfUrukHai.getCardId());
|
||||
|
||||
playerDecided(P1, ""+_game.getGameState().getRingBearer(P1).getCardId());
|
||||
|
||||
playerDecided(P1, "");
|
||||
playerDecided(P2, getCardActionId(P2, "Play Savagery"));
|
||||
|
||||
assertEquals(AwaitingDecisionType.MULTIPLE_CHOICE, _userFeedback.getAwaitingDecision(P2).getDecisionType());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.gempukku.lotro.at.effects;
|
||||
|
||||
import com.gempukku.lotro.at.AbstractAtTest;
|
||||
import com.gempukku.lotro.common.Zone;
|
||||
import com.gempukku.lotro.game.PhysicalCardImpl;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class DiscardFromHandAtTest extends AbstractAtTest {
|
||||
@Test
|
||||
public void foulCreationDiscardsCardAndDrawsCards() throws Exception {
|
||||
initializeSimplestGame();
|
||||
|
||||
final PhysicalCardImpl legolas = createCard(P1, "1_50");
|
||||
_game.getGameState().addCardToZone(_game, legolas, Zone.FREE_CHARACTERS);
|
||||
|
||||
PhysicalCardImpl foulCreation = createCard(P1, "1_44");
|
||||
_game.getGameState().addCardToZone(_game, foulCreation, Zone.HAND);
|
||||
|
||||
PhysicalCardImpl lurtz = createCard(P2, "1_127");
|
||||
_game.getGameState().addCardToZone(_game, lurtz, Zone.HAND);
|
||||
|
||||
skipMulligans();
|
||||
|
||||
playerDecided(P1, getCardActionId(P1, "Play Foul Creation"));
|
||||
|
||||
playerDecided(P1, "");
|
||||
|
||||
playerDecided(P1, "0");
|
||||
|
||||
assertEquals(Zone.DISCARD, lurtz.getZone());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
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.PhysicalCardImpl;
|
||||
import com.gempukku.lotro.logic.decisions.AwaitingDecisionType;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class PlayCardFromStackedAtTest extends AbstractAtTest {
|
||||
@Test
|
||||
public void playFromGoblinSwarms() throws Exception {
|
||||
initializeSimplestGame();
|
||||
|
||||
skipMulligans();
|
||||
|
||||
final PhysicalCardImpl goblinSwarms = createCard(P2, "1_183");
|
||||
_game.getGameState().addCardToZone(_game, goblinSwarms, Zone.SUPPORT);
|
||||
|
||||
final PhysicalCardImpl goblinRunner = createCard(P2, "1_178");
|
||||
_game.getGameState().stackCard(_game, goblinRunner, goblinSwarms);
|
||||
|
||||
_game.getGameState().setTwilight(20);
|
||||
|
||||
// Fellowship phase
|
||||
playerDecided(P1, "");
|
||||
|
||||
playerDecided(P2, getCardActionId(P2, "Use Goblin Swarms"));
|
||||
|
||||
assertEquals(Zone.SHADOW_CHARACTERS, goblinRunner.getZone());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user