"Gimli's Armor"

This commit is contained in:
marcins78@gmail.com
2011-10-27 10:49:19 +00:00
parent 35c78cf633
commit dd0c81564c
2 changed files with 68 additions and 0 deletions

View File

@@ -136,6 +136,10 @@ public class PlayConditions {
return Filters.countSpottable(game.getGameState(), game.getModifiersQuerying(), filters) >= count;
}
public static boolean hasInitiative(LotroGame game, Side side) {
return game.getGameState().getInitiativeSide() == side;
}
public static boolean canAddThreat(LotroGame game, PhysicalCard card, int count) {
return Filters.countActive(game.getGameState(), game.getModifiersQuerying(), CardType.COMPANION) - game.getGameState().getThreats() >= count;
}

View File

@@ -0,0 +1,64 @@
package com.gempukku.lotro.cards.set7.dwarven;
import com.gempukku.lotro.cards.AbstractAttachableFPPossession;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.effects.PreventCardEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseAndDiscardCardsFromHandEffect;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Filterable;
import com.gempukku.lotro.common.PossessionClass;
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.actions.ActivateCardAction;
import com.gempukku.lotro.logic.effects.ChooseActiveCardEffect;
import com.gempukku.lotro.logic.effects.WoundCharactersEffect;
import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.Effect;
import java.util.Collections;
import java.util.List;
/**
* Set: The Return of the King
* Side: Free
* Culture: Dwarven
* Twilight Cost: 2
* Type: Possession • Armor
* Game Text: Bearer must be Gimli. Response: If you have initiative and Gimli is about to take a wound, discard
* 2 cards from hand to prevent that wound.
*/
public class Card7_008 extends AbstractAttachableFPPossession {
public Card7_008() {
super(2, 0, 0, Culture.DWARVEN, PossessionClass.ARMOR, "Gimli's Armor", true);
}
@Override
protected Filterable getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) {
return Filters.name("Gimli");
}
@Override
public List<? extends Action> getOptionalInPlayBeforeActions(String playerId, LotroGame game, Effect effect, PhysicalCard self) {
if (PlayConditions.hasInitiative(game, Side.FREE_PEOPLE)
&& PlayConditions.isGettingWounded(effect, game, Filters.name("Gimli"))
&& PlayConditions.canDiscardFromHand(game, playerId, 2, Filters.any)) {
final WoundCharactersEffect woundEffect = (WoundCharactersEffect) effect;
final ActivateCardAction action = new ActivateCardAction(self);
action.appendCost(
new ChooseAndDiscardCardsFromHandEffect(action, playerId, false, 2));
action.appendEffect(
new ChooseActiveCardEffect(self, playerId, "Choose Gimli", Filters.name("Gimli")) {
@Override
protected void cardSelected(LotroGame game, PhysicalCard card) {
action.insertEffect(
new PreventCardEffect(woundEffect, card));
}
});
return Collections.singletonList(action);
}
return null;
}
}