"Gandalf's Hat"

This commit is contained in:
marcins78@gmail.com
2011-12-09 11:50:08 +00:00
parent 8620a31f8e
commit f846aad3f8
3 changed files with 88 additions and 7 deletions

View File

@@ -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);
}
}

View File

@@ -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<RequiredTriggerAction> 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<? extends Action> 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;
}
}

View File

@@ -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);
}