"So Polite"
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package com.gempukku.lotro.cards.modifiers.evaluator;
|
||||
|
||||
import com.gempukku.lotro.game.PhysicalCard;
|
||||
import com.gempukku.lotro.game.state.GameState;
|
||||
import com.gempukku.lotro.logic.modifiers.ModifiersQuerying;
|
||||
import com.gempukku.lotro.logic.modifiers.evaluator.Evaluator;
|
||||
|
||||
public class ForEachThreatEvaluator implements Evaluator {
|
||||
@Override
|
||||
public int evaluateExpression(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard self) {
|
||||
return gameState.getThreats();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.gempukku.lotro.cards.set7.gollum;
|
||||
|
||||
import com.gempukku.lotro.cards.AbstractEvent;
|
||||
import com.gempukku.lotro.cards.PlayConditions;
|
||||
import com.gempukku.lotro.cards.actions.PlayEventAction;
|
||||
import com.gempukku.lotro.cards.effects.choose.ChooseAndPlayCardFromDiscardEffect;
|
||||
import com.gempukku.lotro.cards.modifiers.evaluator.ForEachThreatEvaluator;
|
||||
import com.gempukku.lotro.common.Culture;
|
||||
import com.gempukku.lotro.common.Phase;
|
||||
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.AddTwilightEffect;
|
||||
|
||||
/**
|
||||
* Set: The Return of the King
|
||||
* Side: Shadow
|
||||
* Culture: Gollum
|
||||
* Twilight Cost: 0
|
||||
* Type: Event • Shadow
|
||||
* Game Text: Play Gollum from your discard pile to add (1) for each threat you spot.
|
||||
*/
|
||||
public class Card7_074 extends AbstractEvent {
|
||||
public Card7_074() {
|
||||
super(Side.SHADOW, 0, Culture.GOLLUM, "So Polite", Phase.SHADOW);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkPlayRequirements(String playerId, LotroGame game, PhysicalCard self, int twilightModifier) {
|
||||
return super.checkPlayRequirements(playerId, game, self, twilightModifier)
|
||||
&& PlayConditions.canPlayFromDiscard(playerId, game, Filters.gollum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayEventAction getPlayCardAction(String playerId, LotroGame game, PhysicalCard self, int twilightModifier) {
|
||||
PlayEventAction action = new PlayEventAction(self);
|
||||
action.appendCost(
|
||||
new ChooseAndPlayCardFromDiscardEffect(playerId, game.getGameState().getDiscard(playerId), Filters.gollum));
|
||||
action.appendEffect(
|
||||
new AddTwilightEffect(self, new ForEachThreatEvaluator()));
|
||||
return action;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@ package com.gempukku.lotro.logic.effects;
|
||||
|
||||
import com.gempukku.lotro.game.PhysicalCard;
|
||||
import com.gempukku.lotro.game.state.LotroGame;
|
||||
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;
|
||||
import com.gempukku.lotro.logic.timing.Preventable;
|
||||
@@ -11,12 +13,17 @@ import java.util.Collections;
|
||||
|
||||
public class AddTwilightEffect extends AbstractEffect implements Preventable {
|
||||
private PhysicalCard _source;
|
||||
private int _twilight;
|
||||
private Evaluator _twilight;
|
||||
private int _resultTwilight;
|
||||
private int _prevented;
|
||||
|
||||
public AddTwilightEffect(PhysicalCard source, int twilight) {
|
||||
public AddTwilightEffect(PhysicalCard source, Evaluator twilightEvaluator) {
|
||||
_source = source;
|
||||
_twilight = twilight;
|
||||
_twilight = twilightEvaluator;
|
||||
}
|
||||
|
||||
public AddTwilightEffect(PhysicalCard source, int twilight) {
|
||||
this(source, new ConstantEvaluator(twilight));
|
||||
}
|
||||
|
||||
public PhysicalCard getSource() {
|
||||
@@ -25,7 +32,7 @@ public class AddTwilightEffect extends AbstractEffect implements Preventable {
|
||||
|
||||
@Override
|
||||
public String getText(LotroGame game) {
|
||||
return "Add (" + _twilight + ")";
|
||||
return "Add (" + _twilight.evaluateExpression(game.getGameState(), game.getModifiersQuerying(), null) + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -35,12 +42,12 @@ public class AddTwilightEffect extends AbstractEffect implements Preventable {
|
||||
|
||||
@Override
|
||||
public boolean isPrevented() {
|
||||
return _prevented == _twilight;
|
||||
return _prevented == _resultTwilight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prevent() {
|
||||
_prevented = _twilight;
|
||||
_prevented = _resultTwilight;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -50,9 +57,10 @@ public class AddTwilightEffect extends AbstractEffect implements Preventable {
|
||||
|
||||
@Override
|
||||
protected FullEffectResult playEffectReturningResult(LotroGame game) {
|
||||
_resultTwilight = _twilight.evaluateExpression(game.getGameState(), game.getModifiersQuerying(), null);
|
||||
if (!isPrevented()) {
|
||||
game.getGameState().sendMessage(_twilight + " gets added to the twilight pool");
|
||||
game.getGameState().addTwilight(_twilight);
|
||||
game.getGameState().sendMessage(_resultTwilight + " gets added to the twilight pool");
|
||||
game.getGameState().addTwilight(_resultTwilight);
|
||||
return new FullEffectResult(Collections.singleton(new AddTwilightResult(_source)), true, _prevented == 0);
|
||||
}
|
||||
return new FullEffectResult(null, true, false);
|
||||
|
||||
Reference in New Issue
Block a user