diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set12/gandalf/Card12_032.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set12/gandalf/Card12_032.java new file mode 100644 index 000000000..f946a6181 --- /dev/null +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set12/gandalf/Card12_032.java @@ -0,0 +1,62 @@ +package com.gempukku.lotro.cards.set12.gandalf; + +import com.gempukku.lotro.cards.AbstractAttachable; +import com.gempukku.lotro.cards.PlayConditions; +import com.gempukku.lotro.cards.TriggerConditions; +import com.gempukku.lotro.cards.effects.PreventCardEffect; +import com.gempukku.lotro.cards.effects.SelfDiscardEffect; +import com.gempukku.lotro.common.*; +import com.gempukku.lotro.filters.Filter; +import com.gempukku.lotro.filters.Filters; +import com.gempukku.lotro.game.PhysicalCard; +import com.gempukku.lotro.game.state.LotroGame; +import com.gempukku.lotro.logic.actions.ActivateCardAction; +import com.gempukku.lotro.logic.effects.AbstractPreventableCardEffect; +import com.gempukku.lotro.logic.timing.Action; +import com.gempukku.lotro.logic.timing.Effect; + +import java.util.Collections; +import java.util.List; + +/** + * Set: Black Rider + * Side: Free + * Culture: Gandalf + * Twilight Cost: 0 + * Type: Condition + * Game Text: Spell. To play, spot a [GANDALF] Wizard. Bearer must be a companion. Limit 1 per bearer. + * Response: If bearer is about to take a wound that would kill him or her, discard this condition to prevent that + * wound. + */ +public class Card12_032 extends AbstractAttachable { + public Card12_032() { + super(Side.FREE_PEOPLE, CardType.CONDITION, 0, Culture.GANDALF, null, "Salve"); + addKeyword(Keyword.SPELL); + } + + @Override + public boolean checkPlayRequirements(String playerId, LotroGame game, PhysicalCard self, Filter additionalAttachmentFilter, int twilightModifier) { + return super.checkPlayRequirements(playerId, game, self, additionalAttachmentFilter, twilightModifier) + && PlayConditions.canSpot(game, Culture.GANDALF, Race.WIZARD); + } + + @Override + protected Filterable getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) { + return Filters.and(CardType.COMPANION, Filters.not(Filters.hasAttached(Filters.name(getName())))); + } + + @Override + public List getOptionalInPlayBeforeActions(String playerId, LotroGame game, Effect effect, PhysicalCard self) { + if (TriggerConditions.isGettingWounded(effect, game, self.getAttachedTo()) + && PlayConditions.canSelfDiscard(self, game) + && Filters.exhausted.accepts(game.getGameState(), game.getModifiersQuerying(), self.getAttachedTo())) { + ActivateCardAction action = new ActivateCardAction(self); + action.appendCost( + new SelfDiscardEffect(self)); + action.appendEffect( + new PreventCardEffect((AbstractPreventableCardEffect) effect, self.getAttachedTo())); + return Collections.singletonList(action); + } + return null; + } +}