"The One Ring"

This commit is contained in:
marcins78@gmail.com
2011-11-30 11:12:03 +00:00
parent ddb476da39
commit 3639a9d118

View File

@@ -0,0 +1,106 @@
package com.gempukku.lotro.cards.set11;
import com.gempukku.lotro.cards.AbstractAttachable;
import com.gempukku.lotro.cards.TriggerConditions;
import com.gempukku.lotro.cards.effects.AddBurdenEffect;
import com.gempukku.lotro.cards.effects.PreventCardEffect;
import com.gempukku.lotro.cards.effects.PutOnTheOneRingEffect;
import com.gempukku.lotro.cards.effects.TakeOffTheOneRingEffect;
import com.gempukku.lotro.cards.modifiers.ResistanceModifier;
import com.gempukku.lotro.common.CardType;
import com.gempukku.lotro.common.Keyword;
import com.gempukku.lotro.common.Phase;
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.actions.RequiredTriggerAction;
import com.gempukku.lotro.logic.effects.WoundCharactersEffect;
import com.gempukku.lotro.logic.modifiers.KeywordModifier;
import com.gempukku.lotro.logic.modifiers.Modifier;
import com.gempukku.lotro.logic.modifiers.ModifierFlag;
import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.Effect;
import com.gempukku.lotro.logic.timing.EffectResult;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
/**
* Set: Shadows
* Type: The One Ring
* Resistance: +2
* Game Text: Response: If the Ring-bearer is about to take a wound, he or she wears The One Ring until the regroup
* phase. While the Ring-bearer is wearing The One Ring, each time he or she is about to take a wound, add a burden
* instead.
*/
public class Card11_001 extends AbstractAttachable {
public Card11_001() {
super(null, CardType.THE_ONE_RING, 0, null, null, "The One Ring", true);
}
@Override
protected Filter getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.none;
}
@Override
public List<? extends Modifier> getAlwaysOnModifiers(LotroGame game, PhysicalCard self) {
List<Modifier> modifiers = new LinkedList<Modifier>();
modifiers.add(new ResistanceModifier(self, Filters.hasAttached(self), 1));
modifiers.add(new KeywordModifier(self, Filters.hasAttached(self), Keyword.RING_BEARER));
modifiers.add(new KeywordModifier(self, Filters.hasAttached(self), Keyword.RING_BOUND));
return modifiers;
}
@Override
public List<? extends Action> getOptionalInPlayBeforeActions(final String playerId, LotroGame game, Effect effect, final PhysicalCard self) {
if (TriggerConditions.isGettingWounded(effect, game, Filters.hasAttached(self))
&& !game.getModifiersQuerying().hasFlagActive(game.getGameState(), ModifierFlag.RING_TEXT_INACTIVE)) {
WoundCharactersEffect woundEffect = (WoundCharactersEffect) effect;
if (woundEffect.getAffectedCardsMinusPrevented(game).contains(self.getAttachedTo())) {
List<Action> actions = new LinkedList<Action>();
ActivateCardAction action = new ActivateCardAction(self);
action.appendEffect(new PreventCardEffect(woundEffect, self.getAttachedTo()));
action.appendEffect(new AddBurdenEffect(self, 1));
action.appendEffect(new PutOnTheOneRingEffect());
actions.add(action);
return actions;
}
}
return null;
}
@Override
public List<RequiredTriggerAction> getRequiredBeforeTriggers(LotroGame game, Effect effect, PhysicalCard self) {
if (TriggerConditions.isGettingWounded(effect, game, Filters.hasAttached(self))
&& game.getGameState().isWearingRing()
&& !game.getModifiersQuerying().hasFlagActive(game.getGameState(), ModifierFlag.RING_TEXT_INACTIVE)) {
WoundCharactersEffect woundEffect = (WoundCharactersEffect) effect;
if (woundEffect.getAffectedCardsMinusPrevented(game).contains(self.getAttachedTo())) {
List<RequiredTriggerAction> actions = new LinkedList<RequiredTriggerAction>();
RequiredTriggerAction action = new RequiredTriggerAction(self);
action.appendEffect(new PreventCardEffect(woundEffect, self.getAttachedTo()));
action.appendEffect(new AddBurdenEffect(self, 1));
return actions;
}
}
return null;
}
@Override
public List<RequiredTriggerAction> getRequiredAfterTriggers(LotroGame game, EffectResult effectResult, PhysicalCard self) {
if (game.getGameState().getCurrentPhase() == Phase.REGROUP
&& game.getGameState().isWearingRing()
&& (effectResult.getType() == EffectResult.Type.END_OF_PHASE || effectResult.getType() == EffectResult.Type.START_OF_PHASE)) {
RequiredTriggerAction action = new RequiredTriggerAction(self);
action.appendEffect(new TakeOffTheOneRingEffect());
return Collections.singletonList(action);
}
return null;
}
}