"Held Ground"

This commit is contained in:
marcins78@gmail.com
2011-11-06 15:10:06 +00:00
parent faf63ba2a5
commit 69f7d1ad60
2 changed files with 81 additions and 1 deletions

View File

@@ -44,7 +44,7 @@ public class Card7_067 extends AbstractPermanent {
@Override
public PlayPermanentAction getPlayCardAction(final String playerId, LotroGame game, final PhysicalCard self, int twilightModifier) {
final PlayPermanentAction playCardAction = super.getPlayCardAction(playerId, game, self, twilightModifier);
int maxThreats = Filters.countActive(game.getGameState(), game.getModifiersQuerying(), CardType.COMPANION) - game.getGameState().getThreats();
int maxThreats = Math.min(9, Filters.countActive(game.getGameState(), game.getModifiersQuerying(), CardType.COMPANION) - game.getGameState().getThreats());
playCardAction.appendCost(
new PlayoutDecisionEffect(game.getUserFeedback(), playerId,
new IntegerAwaitingDecision(1, "Choose how many threats to add", 0, maxThreats) {

View File

@@ -0,0 +1,80 @@
package com.gempukku.lotro.cards.set7.wraith;
import com.gempukku.lotro.cards.AbstractPermanent;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.actions.PlayPermanentAction;
import com.gempukku.lotro.cards.effects.choose.ChooseAndDiscardCardsFromPlayEffect;
import com.gempukku.lotro.common.*;
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.OptionalTriggerAction;
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
import com.gempukku.lotro.logic.decisions.IntegerAwaitingDecision;
import com.gempukku.lotro.logic.effects.AddThreatsEffect;
import com.gempukku.lotro.logic.effects.KillEffect;
import com.gempukku.lotro.logic.effects.PlayoutDecisionEffect;
import com.gempukku.lotro.logic.effects.RemoveThreatsEffect;
import com.gempukku.lotro.logic.timing.Effect;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
/**
* Set: The Return of the King
* Side: Shadow
* Culture: Wraith
* Twilight Cost: 1
* Type: Condition • Support Area
* Game Text: To play, spot 2 Nazgul and add up to 3 threats. Each time a companion is about to be killed, you may
* remove a threat to discard up to 2 possessions. Discard this condition and remove 3 threats during the regroup phase.
*/
public class Card7_181 extends AbstractPermanent {
public Card7_181() {
super(Side.SHADOW, 1, CardType.CONDITION, Culture.WRAITH, Zone.SUPPORT, "Held Ground", true);
}
@Override
public boolean checkPlayRequirements(String playerId, LotroGame game, PhysicalCard self, int twilightModifier) {
return super.checkPlayRequirements(playerId, game, self, twilightModifier)
&& PlayConditions.canSpot(game, 2, Race.NAZGUL);
}
@Override
public PlayPermanentAction getPlayCardAction(final String playerId, LotroGame game, final PhysicalCard self, int twilightModifier) {
final PlayPermanentAction permanentAction = super.getPlayCardAction(playerId, game, self, twilightModifier);
int maxThreats = Math.min(3, Filters.countActive(game.getGameState(), game.getModifiersQuerying(), CardType.COMPANION) - game.getGameState().getThreats());
permanentAction.appendCost(
new PlayoutDecisionEffect(game.getUserFeedback(), playerId,
new IntegerAwaitingDecision(1, "Choose how many threats to add", 0, maxThreats) {
@Override
public void decisionMade(String result) throws DecisionResultInvalidException {
int threats = getValidatedResult(result);
permanentAction.appendCost(
new AddThreatsEffect(playerId, self, threats));
}
})
);
return permanentAction;
}
@Override
public List<OptionalTriggerAction> getOptionalBeforeTriggers(String playerId, LotroGame game, Effect effect, PhysicalCard self) {
if (PlayConditions.isGettingKilled(effect, game, CardType.COMPANION)) {
KillEffect killEffect = (KillEffect) effect;
Collection<PhysicalCard> companionsKilled = Filters.filter(killEffect.getCharactersToBeKilled(), game.getGameState(), game.getModifiersQuerying(), CardType.COMPANION);
List<OptionalTriggerAction> actions = new LinkedList<OptionalTriggerAction>();
for (PhysicalCard physicalCard : companionsKilled) {
OptionalTriggerAction action = new OptionalTriggerAction(self);
action.appendCost(
new RemoveThreatsEffect(self, 1));
action.appendEffect(
new ChooseAndDiscardCardsFromPlayEffect(action, playerId, 0, 2, CardType.POSSESSION));
actions.add(action);
}
return actions;
}
return null;
}
}