- "Pippin, Friend to Frodo" now prevents only Shadow player from discarding Tales, not the FP player, if a Shadow card

makes FP player to discard it.
This commit is contained in:
marcins78@gmail.com
2012-05-30 08:51:50 +00:00
parent 67138a0bc7
commit 190070b59a
13 changed files with 57 additions and 17 deletions

View File

@@ -319,7 +319,7 @@ public class PlayConditions {
}
public static boolean canDiscardFromPlay(final PhysicalCard source, LotroGame game, final PhysicalCard card) {
return game.getModifiersQuerying().canBeDiscardedFromPlay(game.getGameState(), card, source);
return game.getModifiersQuerying().canBeDiscardedFromPlay(game.getGameState(), source.getOwner(), card, source);
}
public static boolean canSelfDiscard(PhysicalCard source, LotroGame game) {
@@ -331,7 +331,7 @@ public class PlayConditions {
new Filter() {
@Override
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
return modifiersQuerying.canBeDiscardedFromPlay(gameState, physicalCard, source);
return modifiersQuerying.canBeDiscardedFromPlay(gameState, source.getOwner(), physicalCard, source);
}
})) >= count;
}

View File

@@ -14,24 +14,26 @@ import java.util.Collection;
public class ChooseAndDiscardCardsFromPlayEffect extends ChooseActiveCardsEffect {
private Action _action;
private String _playerId;
private SubAction _resultSubAction;
public ChooseAndDiscardCardsFromPlayEffect(Action action, String playerId, int minimum, int maximum, Filterable... filters) {
super(action.getActionSource(), playerId, "Choose cards to discard", minimum, maximum, filters);
_action = action;
_playerId = playerId;
}
@Override
protected Filter getExtraFilterForPlaying(LotroGame game) {
if (_action.getActionSource() == null)
return Filters.any;
return Filters.canBeDiscarded(_action.getActionSource());
return Filters.canBeDiscarded(_playerId, _action.getActionSource());
}
@Override
protected void cardsSelected(LotroGame game, Collection<PhysicalCard> cards) {
_resultSubAction = new SubAction(_action);
_resultSubAction.appendEffect(new DiscardCardsFromPlayEffect(_action.getPerformingPlayer(), _action.getActionSource(), Filters.in(cards)));
_resultSubAction.appendEffect(new DiscardCardsFromPlayEffect(_playerId, _action.getActionSource(), Filters.in(cards)));
game.getActionsEnvironment().addActionToStack(_resultSubAction);
cardsToBeDiscardedCallback(cards);
}

View File

@@ -7,7 +7,7 @@ import com.gempukku.lotro.common.Race;
import com.gempukku.lotro.common.Signet;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.logic.modifiers.CantDiscardFromPlayModifier;
import com.gempukku.lotro.logic.modifiers.CantDiscardFromPlayByPlayerModifier;
import com.gempukku.lotro.logic.modifiers.Modifier;
/**
@@ -29,6 +29,6 @@ public class Card1_306 extends AbstractCompanion {
@Override
public Modifier getAlwaysOnModifier(PhysicalCard self) {
return new CantDiscardFromPlayModifier(self, "Can't be discarded by opponent", Filters.and(Culture.SHIRE, Keyword.TALE), Filters.not(Filters.owner(self.getOwner())));
return new CantDiscardFromPlayByPlayerModifier(self, "Can't be discarded by opponent", Filters.and(Culture.SHIRE, Keyword.TALE), self.getOwner());
}
}

View File

@@ -35,8 +35,8 @@ public class Card15_128 extends AbstractCompanion {
modifiers.add(
new KeywordModifier(self, self, new SpotCondition(3, PossessionClass.MOUNT), Keyword.DAMAGE, 1));
modifiers.add(
new CantDiscardFromPlayModifier(self, "Can't be discarded by a Shadow player", new SpotCondition(4, Side.FREE_PEOPLE, PossessionClass.MOUNT),
Filters.and(Side.FREE_PEOPLE, PossessionClass.MOUNT), Side.SHADOW));
new CantDiscardFromPlayByPlayerModifier(self, "Can't be discarded by a Shadow player", new SpotCondition(4, Side.FREE_PEOPLE, PossessionClass.MOUNT),
Filters.and(Side.FREE_PEOPLE, PossessionClass.MOUNT), self.getOwner()));
return modifiers;
}
}

View File

@@ -60,8 +60,7 @@ public class Card5_060 extends AbstractPermanent {
public List<? extends ActivateCardAction> getOptionalInPlayBeforeActions(String playerId, LotroGame game, Effect effect, PhysicalCard self) {
if (TriggerConditions.isGettingDiscarded(effect, game, Keyword.MACHINE)) {
DiscardCardsFromPlayEffect discardEffect = (DiscardCardsFromPlayEffect) effect;
if (discardEffect.getSource() != null
&& discardEffect.getSource().getOwner().equals(game.getGameState().getCurrentPlayerId())) {
if (!discardEffect.getPerformingPlayer().equals(self.getOwner())) {
ActivateCardAction action = new ActivateCardAction(self);
action.appendCost(
new SelfDiscardEffect(self));

View File

@@ -387,7 +387,16 @@ public class Filters {
return new Filter() {
@Override
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
return modifiersQuerying.canBeDiscardedFromPlay(gameState, physicalCard, source);
return modifiersQuerying.canBeDiscardedFromPlay(gameState, source.getOwner(), physicalCard, source);
}
};
}
public static final Filter canBeDiscarded(final String performingPlayer, final PhysicalCard source) {
return new Filter() {
@Override
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
return modifiersQuerying.canBeDiscardedFromPlay(gameState, performingPlayer, physicalCard, source);
}
};
}

View File

@@ -253,7 +253,7 @@ public abstract class AbstractModifier implements Modifier {
}
@Override
public boolean canBeDiscardedFromPlay(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard card, PhysicalCard source) {
public boolean canBeDiscardedFromPlay(GameState gameState, ModifiersQuerying modifiersQuerying, String performingPlayer, PhysicalCard card, PhysicalCard source) {
return true;
}

View File

@@ -0,0 +1,26 @@
package com.gempukku.lotro.logic.modifiers;
import com.gempukku.lotro.common.Filterable;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.GameState;
public class CantDiscardFromPlayByPlayerModifier extends AbstractModifier {
private String _notPlayer;
public CantDiscardFromPlayByPlayerModifier(PhysicalCard source, String text, Filterable affectFilter, String notPlayer) {
super(source, text, affectFilter, ModifierEffect.DISCARD_FROM_PLAY_MODIFIER);
_notPlayer = notPlayer;
}
public CantDiscardFromPlayByPlayerModifier(PhysicalCard source, String text, Condition condition, Filterable affectFilter, String notPlayer) {
super(source, text, affectFilter, condition, ModifierEffect.DISCARD_FROM_PLAY_MODIFIER);
_notPlayer = notPlayer;
}
@Override
public boolean canBeDiscardedFromPlay(GameState gameState, ModifiersQuerying modifiersQuerying, String performingPlayer, PhysicalCard card, PhysicalCard source) {
if (!_notPlayer.equals(performingPlayer))
return false;
return true;
}
}

View File

@@ -19,7 +19,7 @@ public class CantDiscardFromPlayModifier extends AbstractModifier {
}
@Override
public boolean canBeDiscardedFromPlay(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard card, PhysicalCard source) {
public boolean canBeDiscardedFromPlay(GameState gameState, ModifiersQuerying modifiersQuerying, String performingPlayer, PhysicalCard card, PhysicalCard source) {
if (Filters.and(_sourceFilter).accepts(gameState, modifiersQuerying, source))
return false;
return true;

View File

@@ -102,7 +102,7 @@ public interface Modifier {
public boolean isPreventedFromBeingAssignedToSkirmish(GameState gameState, Side sidePlayer, ModifiersQuerying modifiersQuerying, PhysicalCard card);
public boolean canBeDiscardedFromPlay(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard card, PhysicalCard source);
public boolean canBeDiscardedFromPlay(GameState gameState, ModifiersQuerying modifiersQuerying, String performingPlayer, PhysicalCard card, PhysicalCard source);
public boolean canBeReturnedToHand(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard card, PhysicalCard source);

View File

@@ -743,11 +743,11 @@ public class ModifiersLogic implements ModifiersEnvironment, ModifiersQuerying {
}
@Override
public boolean canBeDiscardedFromPlay(GameState gameState, PhysicalCard card, PhysicalCard source) {
public boolean canBeDiscardedFromPlay(GameState gameState, String performingPlayer, PhysicalCard card, PhysicalCard source) {
LoggingThreadLocal.logMethodStart(card, "canBeDiscardedFromPlay");
try {
for (Modifier modifier : getModifiersAffectingCard(gameState, ModifierEffect.DISCARD_FROM_PLAY_MODIFIER, card))
if (!modifier.canBeDiscardedFromPlay(gameState, this, card, source))
if (!modifier.canBeDiscardedFromPlay(gameState, this, performingPlayer, card, source))
return false;
return true;
} finally {

View File

@@ -108,7 +108,7 @@ public interface ModifiersQuerying {
public List<? extends Effect> getExtraCostsToPlay(GameState gameState, Action action, PhysicalCard target);
// Others
public boolean canBeDiscardedFromPlay(GameState gameState, PhysicalCard card, PhysicalCard source);
public boolean canBeDiscardedFromPlay(GameState gameState, String performingPlayer, PhysicalCard card, PhysicalCard source);
public boolean canBeReturnedToHand(GameState gameState, PhysicalCard card, PhysicalCard source);

View File

@@ -1,4 +1,8 @@
<pre style="font-size:80%">
<b>30 May 2012</b>
- "Pippin, Friend to Frodo" now prevents only Shadow player from discarding Tales, not the FP player, if a Shadow card
makes FP player to discard it.
<b>25 May 2012</b>
- If a game is cancelled due to an error or players agreeing to cancel it, it is treated as finished, and players can
start a new game.