- "Gimli, Feared Axeman" should now properly be usable when a card is discarded by an action of an opponent.

This commit is contained in:
marcins78@gmail.com
2012-03-16 13:44:24 +00:00
parent 89560820be
commit 70659e8af5
5 changed files with 25 additions and 2 deletions

View File

@@ -270,6 +270,15 @@ public class TriggerConditions {
return false;
}
public static boolean isGettingDiscardedByOpponent(Effect effect, LotroGame game, String playerId, Filterable... filters) {
if (effect.getType() == Effect.Type.BEFORE_DISCARD_FROM_PLAY) {
DiscardCardsFromPlayEffect discardEffect = (DiscardCardsFromPlayEffect) effect;
if (discardEffect.getSource() != null && !discardEffect.getPerformingPlayer().equals(playerId))
return Filters.filter(discardEffect.getAffectedCardsMinusPrevented(game), game.getGameState(), game.getModifiersQuerying(), filters).size() > 0;
}
return false;
}
public static boolean isGettingDiscarded(Effect effect, LotroGame game, Filterable... filters) {
if (effect.getType() == Effect.Type.BEFORE_DISCARD_FROM_PLAY) {
DiscardCardsFromPlayEffect discardEffect = (DiscardCardsFromPlayEffect) effect;

View File

@@ -36,7 +36,7 @@ public class ChooseAndDiscardCardsFromPlayEffect extends ChooseActiveCardsEffect
@Override
protected void cardsSelected(LotroGame game, Collection<PhysicalCard> cards) {
_resultSubAction = new SubAction(_action);
_resultSubAction.appendEffect(new DiscardCardsFromPlayEffect(_action.getActionSource(), Filters.in(cards)));
_resultSubAction.appendEffect(new DiscardCardsFromPlayEffect(_action.getPerformingPlayer(), _action.getActionSource(), Filters.in(cards)));
game.getActionsEnvironment().addActionToStack(_resultSubAction);
cardsToBeDiscardedCallback(cards);
}

View File

@@ -42,7 +42,7 @@ public class Card7_007 extends AbstractCompanion {
@Override
public List<? extends ActivateCardAction> getOptionalInPlayBeforeActions(String playerId, LotroGame game, Effect effect, PhysicalCard self) {
if (TriggerConditions.isGettingDiscardedBy(effect, game, Side.SHADOW, Culture.DWARVEN, CardType.CONDITION)
if (TriggerConditions.isGettingDiscardedByOpponent(effect, game, playerId, Culture.DWARVEN, CardType.CONDITION)
&& (PlayConditions.canExert(self, game, Race.DWARF)
|| PlayConditions.canDiscardFromHand(game, playerId, 1, Culture.DWARVEN))) {
final DiscardCardsFromPlayEffect discardEffect = (DiscardCardsFromPlayEffect) effect;

View File

@@ -30,6 +30,12 @@ public class DiscardCardsFromPlayEffect extends AbstractPreventableCardEffect {
_source = source;
}
public DiscardCardsFromPlayEffect(String performingPlayer, PhysicalCard source, Filterable... filters) {
super(filters);
_performingPlayer = performingPlayer;
_source = source;
}
public PhysicalCard getSource() {
return _source;
}
@@ -44,6 +50,13 @@ public class DiscardCardsFromPlayEffect extends AbstractPreventableCardEffect {
};
}
public String getPerformingPlayer() {
final String performingPlayer = _performingPlayer;
if (performingPlayer != null)
return performingPlayer;
return _source.getOwner();
}
@Override
public Effect.Type getType() {
return Type.BEFORE_DISCARD_FROM_PLAY;

View File

@@ -1,6 +1,7 @@
<pre style="font-size:80%">
<b>16 Mar. 2012</b>
- When "Mountain-troll" is played with discarding 5 minions, now it should properly gain Fierce.
- "Gimli, Feared Axeman" should now properly be usable when a card is discarded by an action of an opponent.
<b>15 Mar. 2012</b>
- "Mount Doom" should finally work.