From f846aad3f815b19ffedf716c8290c512eed84276 Mon Sep 17 00:00:00 2001 From: "marcins78@gmail.com" Date: Fri, 9 Dec 2011 11:50:08 +0000 Subject: [PATCH] "Gandalf's Hat" --- .../cards/effects/RemoveTwilightEffect.java | 19 +++-- .../lotro/cards/set12/gandalf/Card12_028.java | 74 +++++++++++++++++++ .../com/gempukku/lotro/logic/GameUtils.java | 2 +- 3 files changed, 88 insertions(+), 7 deletions(-) create mode 100644 gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set12/gandalf/Card12_028.java diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/RemoveTwilightEffect.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/RemoveTwilightEffect.java index 0a3af1097..131d1a212 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/RemoveTwilightEffect.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/RemoveTwilightEffect.java @@ -2,19 +2,25 @@ package com.gempukku.lotro.cards.effects; import com.gempukku.lotro.game.state.LotroGame; import com.gempukku.lotro.logic.GameUtils; +import com.gempukku.lotro.logic.modifiers.evaluator.ConstantEvaluator; +import com.gempukku.lotro.logic.modifiers.evaluator.Evaluator; import com.gempukku.lotro.logic.timing.AbstractEffect; import com.gempukku.lotro.logic.timing.Effect; public class RemoveTwilightEffect extends AbstractEffect { - private int _twilight; + private Evaluator _twilight; public RemoveTwilightEffect(int twilight) { + this(new ConstantEvaluator(twilight)); + } + + public RemoveTwilightEffect(Evaluator twilight) { _twilight = twilight; } @Override public String getText(LotroGame game) { - return "Remove (" + _twilight + ")"; + return "Remove (" + _twilight.evaluateExpression(game.getGameState(), game.getModifiersQuerying(), null) + ")"; } @Override @@ -24,15 +30,16 @@ public class RemoveTwilightEffect extends AbstractEffect { @Override public boolean isPlayableInFull(LotroGame game) { - return game.getGameState().getTwilightPool() >= _twilight; + return game.getGameState().getTwilightPool() >= _twilight.evaluateExpression(game.getGameState(), game.getModifiersQuerying(), null); } @Override protected FullEffectResult playEffectReturningResult(LotroGame game) { - int toRemove = Math.min(game.getGameState().getTwilightPool(), _twilight); - game.getGameState().sendMessage(GameUtils.formatNumber(toRemove, _twilight) + " twilight gets removed from twilight pool"); + int requestedToRemove = _twilight.evaluateExpression(game.getGameState(), game.getModifiersQuerying(), null); + int toRemove = Math.min(game.getGameState().getTwilightPool(), requestedToRemove); + game.getGameState().sendMessage(GameUtils.formatNumber(toRemove, requestedToRemove) + " twilight gets removed from twilight pool"); game.getGameState().removeTwilight(toRemove); - return new FullEffectResult(toRemove == _twilight, toRemove == _twilight); + return new FullEffectResult(toRemove == requestedToRemove, toRemove == requestedToRemove); } } diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set12/gandalf/Card12_028.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set12/gandalf/Card12_028.java new file mode 100644 index 000000000..d3acac16b --- /dev/null +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set12/gandalf/Card12_028.java @@ -0,0 +1,74 @@ +package com.gempukku.lotro.cards.set12.gandalf; + +import com.gempukku.lotro.cards.AbstractAttachableFPPossession; +import com.gempukku.lotro.cards.PlayConditions; +import com.gempukku.lotro.cards.TriggerConditions; +import com.gempukku.lotro.cards.effects.AddBurdenEffect; +import com.gempukku.lotro.cards.effects.RemoveTwilightEffect; +import com.gempukku.lotro.common.Culture; +import com.gempukku.lotro.common.Filterable; +import com.gempukku.lotro.common.Keyword; +import com.gempukku.lotro.common.Phase; +import com.gempukku.lotro.filters.Filters; +import com.gempukku.lotro.game.PhysicalCard; +import com.gempukku.lotro.game.state.GameState; +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.modifiers.ModifiersQuerying; +import com.gempukku.lotro.logic.modifiers.evaluator.Evaluator; +import com.gempukku.lotro.logic.timing.Action; +import com.gempukku.lotro.logic.timing.EffectResult; + +import java.util.Collections; +import java.util.List; + +/** + * Set: Black Rider + * Side: Free + * Culture: Gandalf + * Twilight Cost: 0 + * Type: Possession + * Game Text: Bearer must be Gandalf. Each time the fellowship moves from a battleground site, add a burden. + * Regroup: Add 2 burdens to remove all twilight tokens from the twilight pool. + */ +public class Card12_028 extends AbstractAttachableFPPossession { + public Card12_028() { + super(0, 0, 0, Culture.GANDALF, null, "Gandalf's Hat", true); + } + + @Override + protected Filterable getValidTargetFilter(String playerId, LotroGame game, PhysicalCard self) { + return Filters.gandalf; + } + + @Override + public List getRequiredAfterTriggers(LotroGame game, EffectResult effectResult, PhysicalCard self) { + if (TriggerConditions.movesFrom(game, effectResult, Keyword.BATTLEGROUND)) { + RequiredTriggerAction action = new RequiredTriggerAction(self); + action.appendEffect( + new AddBurdenEffect(self, 1)); + return Collections.singletonList(action); + } + return null; + } + + @Override + protected List getExtraInPlayPhaseActions(String playerId, LotroGame game, PhysicalCard self) { + if (PlayConditions.canUseFPCardDuringPhase(game, Phase.REGROUP, self)) { + ActivateCardAction action = new ActivateCardAction(self); + action.appendCost( + new AddBurdenEffect(self, 2)); + action.appendEffect( + new RemoveTwilightEffect( + new Evaluator() { + @Override + public int evaluateExpression(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard cardAffected) { + return gameState.getTwilightPool(); + } + })); + return Collections.singletonList(action); + } + return null; + } +} diff --git a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/logic/GameUtils.java b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/logic/GameUtils.java index 24d1e390b..504c260f0 100644 --- a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/logic/GameUtils.java +++ b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/logic/GameUtils.java @@ -87,7 +87,7 @@ public class GameUtils { public static String formatNumber(int effective, int requested) { if (effective != requested) - return effective + "(" + requested + ")"; + return effective + "(out of " + requested + ")"; else return String.valueOf(effective); }