"On Guard"

This commit is contained in:
marcins78@gmail.com
2011-11-30 12:07:58 +00:00
parent 522dc47e7e
commit f47b83ac26
2 changed files with 61 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
package com.gempukku.lotro.cards.set11.dwarven;
import com.gempukku.lotro.cards.AbstractResponseEvent;
import com.gempukku.lotro.cards.TriggerConditions;
import com.gempukku.lotro.cards.actions.PlayEventAction;
import com.gempukku.lotro.cards.effects.PreventCardEffect;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Race;
import com.gempukku.lotro.common.Side;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.effects.ChooseActiveCardEffect;
import com.gempukku.lotro.logic.effects.WoundCharactersEffect;
import com.gempukku.lotro.logic.timing.Effect;
import java.util.Collections;
import java.util.List;
/**
* Set: Shadows
* Side: Free
* Culture: Dwarven
* Twilight Cost: 1
* Type: Event • Response
* Game Text: If a Dwarf who has resistance 3 or more is about to take a wound, prevent that.
*/
public class Card11_013 extends AbstractResponseEvent {
public Card11_013() {
super(Side.FREE_PEOPLE, 1, Culture.DWARVEN, "On Guard");
}
@Override
public List<PlayEventAction> getOptionalBeforeActions(String playerId, LotroGame game, Effect effect, PhysicalCard self) {
if (TriggerConditions.isGettingWounded(effect, game, Race.DWARF, Filters.minResistance(3))
&& checkPlayRequirements(playerId, game, self, 0, false, false)) {
final WoundCharactersEffect woundEffect = (WoundCharactersEffect) effect;
final PlayEventAction action = new PlayEventAction(self);
action.appendEffect(
new ChooseActiveCardEffect(self, playerId, "Choose a Dwarf", Race.DWARF, Filters.minResistance(3), Filters.in(woundEffect.getAffectedCardsMinusPrevented(game))) {
@Override
protected void cardSelected(LotroGame game, PhysicalCard card) {
action.appendEffect(
new PreventCardEffect(woundEffect, card));
}
});
return Collections.singletonList(action);
}
return null;
}
}

View File

@@ -126,6 +126,15 @@ public class Filters {
};
}
public static Filter minResistance(final int resistance) {
return new Filter() {
@Override
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
return modifiersQuerying.getResistance(gameState, physicalCard) >= resistance;
}
};
}
public static Filter lessStrengthThan(final int strength) {
return new Filter() {
@Override