Fixed Azog (or any card playing another card) interaction with Rivendell

This commit is contained in:
marcin.sciesinski
2021-01-15 15:00:14 -08:00
parent 19a36808f1
commit c4cb1d7768
7 changed files with 59 additions and 0 deletions

View File

@@ -104,6 +104,9 @@ public class PlayUtils {
if (!game.getModifiersQuerying().canPayExtraCostsToPlay(game, card))
return false;
if (!game.getModifiersQuerying().canPlayCard(game, card.getOwner(), card))
return false;
// Check uniqueness
if (!blueprint.skipUniquenessCheck() && !PlayConditions.checkUniqueness(game, card, ignoreCheckingDeadPile))
return false;

View File

@@ -208,6 +208,11 @@ public abstract class AbstractModifier implements Modifier {
return true;
}
@Override
public boolean canPlayCard(LotroGame game, String performingPlayer, PhysicalCard card) {
return true;
}
@Override
public List<? extends Action> getExtraPhaseAction(LotroGame game, PhysicalCard card) {
return null;

View File

@@ -19,6 +19,11 @@ public class CantPlayCardsModifier extends AbstractModifier {
_filters = Filters.and(filters);
}
@Override
public boolean canPlayCard(LotroGame game, String performingPlayer, PhysicalCard card) {
return !_filters.accepts(game, card);
}
@Override
public boolean canPlayAction(LotroGame game, String performingPlayer, Action action) {
final PhysicalCard actionSource = action.getActionSource();

View File

@@ -85,6 +85,8 @@ public interface Modifier {
boolean canPlayAction(LotroGame game, String performingPlayer, Action action);
boolean canPlayCard(LotroGame game, String performingPlayer, PhysicalCard card);
List<? extends Action> getExtraPhaseAction(LotroGame game, PhysicalCard card);
List<? extends Action> getExtraPhaseActionFromStacked(LotroGame game, PhysicalCard card);

View File

@@ -682,6 +682,14 @@ public class ModifiersLogic implements ModifiersEnvironment, ModifiersQuerying {
return true;
}
@Override
public boolean canPlayCard(LotroGame game, String performingPlayer, PhysicalCard card) {
for (Modifier modifier : getModifiers(game, ModifierEffect.ACTION_MODIFIER))
if (!modifier.canPlayCard(game, performingPlayer, card))
return false;
return true;
}
@Override
public boolean canHavePlayedOn(LotroGame game, PhysicalCard playedCard, PhysicalCard target) {
for (Modifier modifier : getModifiersAffectingCard(game, ModifierEffect.TARGET_MODIFIER, target))

View File

@@ -103,6 +103,8 @@ public interface ModifiersQuerying {
// Playing actions
public boolean canPlayAction(LotroGame game, String performingPlayer, Action action);
public boolean canPlayCard(LotroGame game, String performingPlayer, PhysicalCard card);
public boolean canHavePlayedOn(LotroGame game, PhysicalCard playedCard, PhysicalCard target);
public boolean canHaveTransferredOn(LotroGame game, PhysicalCard playedCard, PhysicalCard target);

View File

@@ -149,4 +149,38 @@ public class PlayCardFromDiscardAtTest extends AbstractAtTest {
assertFalse(_userFeedback.getAwaitingDecision(P2).getDecisionType() == AwaitingDecisionType.MULTIPLE_CHOICE);
}
@Test
public void azogCantPlayTrollFromDiscardInRivendell() throws Exception {
initializeSimplestGame();
skipMulligans();
final PhysicalCardImpl rivendell = createCard(P2, "30_51");
rivendell.setSiteNumber(2);
_game.getGameState().addCardToZone(_game, rivendell, Zone.ADVENTURE_PATH);
PhysicalCardImpl azog = createCard(P2, "32_28");
_game.getGameState().addCardToZone(_game, azog, Zone.SHADOW_CHARACTERS);
PhysicalCardImpl watchfulOrc = createCard(P2, "30_40");
_game.getGameState().addCardToZone(_game, watchfulOrc, Zone.SHADOW_CHARACTERS);
PhysicalCardImpl demolitionTroll = createCard(P2, "32_31");
_game.getGameState().addCardToZone(_game, demolitionTroll, Zone.DISCARD);
_game.getGameState().setTwilight(20);
// Fellowship phase
playerDecided(P1, "");
// Shadow phase
playerDecided(P2, getCardActionId(P2, "Use Watchful Orc"));
// Choose Battleground
playerDecided(P2, "0");
playerDecided(P2, "");
// Maneuver phase
playerDecided(P1, "");
assertNull(getCardActionId(P2, "Use Azog"));
}
}