"Darkly Swift"

This commit is contained in:
marcins78
2013-02-04 17:58:57 +00:00
parent 16c224c11f
commit 460595564a
8 changed files with 74 additions and 17 deletions

View File

@@ -212,7 +212,7 @@ public class TriggerConditions {
public static boolean isTakingControlOfSite(Effect effect, LotroGame game, Filterable... sourceFilters) {
if (effect.getType() == Effect.Type.BEFORE_TAKE_CONTROL_OF_A_SITE) {
TakeControlOfASiteEffect takeControlOfASiteEffect = (TakeControlOfASiteEffect) effect;
return !takeControlOfASiteEffect.isPrevented() && Filters.and(sourceFilters).accepts(game.getGameState(), game.getModifiersQuerying(), takeControlOfASiteEffect.getSource());
return !takeControlOfASiteEffect.isPrevented(game) && Filters.and(sourceFilters).accepts(game.getGameState(), game.getModifiersQuerying(), takeControlOfASiteEffect.getSource());
}
return false;
}
@@ -228,7 +228,7 @@ public class TriggerConditions {
public static boolean isAddingBurden(Effect effect, LotroGame game, Filterable... filters) {
if (effect.getType() == Effect.Type.BEFORE_ADD_BURDENS) {
AddBurdenEffect addBurdenEffect = (AddBurdenEffect) effect;
return !addBurdenEffect.isPrevented() && Filters.and(filters).accepts(game.getGameState(), game.getModifiersQuerying(), addBurdenEffect.getSource());
return !addBurdenEffect.isPrevented(game) && Filters.and(filters).accepts(game.getGameState(), game.getModifiersQuerying(), addBurdenEffect.getSource());
}
return false;
}
@@ -236,7 +236,7 @@ public class TriggerConditions {
public static boolean isAddingTwilight(Effect effect, LotroGame game, Filterable... filters) {
if (effect.getType() == Effect.Type.BEFORE_ADD_TWILIGHT) {
AddTwilightEffect addTwilightEffect = (AddTwilightEffect) effect;
return !addTwilightEffect.isPrevented() && addTwilightEffect.getSource() != null && Filters.and(filters).accepts(game.getGameState(), game.getModifiersQuerying(), addTwilightEffect.getSource());
return !addTwilightEffect.isPrevented(game) && addTwilightEffect.getSource() != null && Filters.and(filters).accepts(game.getGameState(), game.getModifiersQuerying(), addTwilightEffect.getSource());
}
return false;
}

View File

@@ -3,6 +3,8 @@ package com.gempukku.lotro.cards.effects;
import com.gempukku.lotro.game.PhysicalCard;
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;
import com.gempukku.lotro.logic.timing.Preventable;
@@ -11,10 +13,14 @@ import com.gempukku.lotro.logic.timing.results.AddBurdenResult;
public class AddBurdenEffect extends AbstractEffect implements Preventable {
private String _performingPlayer;
private PhysicalCard _source;
private int _count;
private Evaluator _count;
private int _prevented;
public AddBurdenEffect(String performingPlayer, PhysicalCard source, int count) {
this(performingPlayer, source, new ConstantEvaluator(count));
}
public AddBurdenEffect(String performingPlayer, PhysicalCard source, Evaluator count) {
_performingPlayer = performingPlayer;
_source = source;
_count = count;
@@ -25,8 +31,8 @@ public class AddBurdenEffect extends AbstractEffect implements Preventable {
}
@Override
public boolean isPrevented() {
return _prevented == _count;
public boolean isPrevented(LotroGame game) {
return _prevented == getBurdensToAdd(game);
}
@Override
@@ -35,12 +41,16 @@ public class AddBurdenEffect extends AbstractEffect implements Preventable {
}
public void preventAll() {
_prevented = _count;
_prevented = Integer.MAX_VALUE;
}
private int getBurdensToAdd(LotroGame game) {
return _count.evaluateExpression(game.getGameState(), game.getModifiersQuerying(), null);
}
@Override
public String getText(LotroGame game) {
return "Add " + (_count - _prevented) + " burden" + (((_count - _prevented) > 1) ? "s" : "");
return "Add " + (getBurdensToAdd(game) - _prevented) + " burden" + (((getBurdensToAdd(game)- _prevented) > 1) ? "s" : "");
}
@Override
@@ -55,9 +65,10 @@ public class AddBurdenEffect extends AbstractEffect implements Preventable {
@Override
protected FullEffectResult playEffectReturningResult(LotroGame game) {
if (isPlayableInFull(game) && _prevented < _count) {
int toAdd = _count - _prevented;
game.getGameState().sendMessage(GameUtils.getCardLink(_source) + " adds " + GameUtils.formatNumber(toAdd, _count) + " burden" + ((toAdd > 1) ? "s" : ""));
int burdensEvaluated = getBurdensToAdd(game);
if (isPlayableInFull(game) && _prevented < burdensEvaluated) {
int toAdd = burdensEvaluated - _prevented;
game.getGameState().sendMessage(GameUtils.getCardLink(_source) + " adds " + GameUtils.formatNumber(toAdd, burdensEvaluated) + " burden" + ((toAdd > 1) ? "s" : ""));
game.getGameState().addBurdens(toAdd);
for (int i = 0; i < toAdd; i++)
game.getActionsEnvironment().emitEffectResult(new AddBurdenResult(_performingPlayer, _source));

View File

@@ -59,7 +59,7 @@ public class TakeControlOfASiteEffect extends AbstractEffect implements Preventa
}
@Override
public boolean isPrevented() {
public boolean isPrevented(LotroGame game) {
return _prevented;
}

View File

@@ -0,0 +1,44 @@
package com.gempukku.lotro.cards.set20.wraith;
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.AddBurdenEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseAndDiscardCardsFromPlayEffect;
import com.gempukku.lotro.cards.modifiers.evaluator.ConditionEvaluator;
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.modifiers.SpotCondition;
/**
* 1
* Darkly Swift
* Ringwraith Event • Regroup
* Discard a Nazgul and spot a companion with 3 resistance or less
* to add a burden (or two burdens if you can spot a companion with 0 resistance).
*/
public class Card20_289 extends AbstractEvent {
public Card20_289() {
super(Side.SHADOW, 1, Culture.WRAITH, "Darkly Swift", Phase.REGROUP);
}
@Override
public boolean checkPlayRequirements(String playerId, LotroGame game, PhysicalCard self, int withTwilightRemoved, int twilightModifier, boolean ignoreRoamingPenalty, boolean ignoreCheckingDeadPile) {
return super.checkPlayRequirements(playerId, game, self, withTwilightRemoved, twilightModifier, ignoreRoamingPenalty, ignoreCheckingDeadPile)
&& PlayConditions.canDiscardFromPlay(self, game, Race.NAZGUL)
&& PlayConditions.canSpot(game, CardType.COMPANION, Filters.maxResistance(3));
}
@Override
public PlayEventAction getPlayCardAction(String playerId, LotroGame game, PhysicalCard self, int twilightModifier, boolean ignoreRoamingPenalty) {
PlayEventAction action = new PlayEventAction(self);
action.appendCost(
new ChooseAndDiscardCardsFromPlayEffect(action, playerId, 1, 1, Race.NAZGUL));
action.appendEffect(
new AddBurdenEffect(playerId, self,
new ConditionEvaluator(1, 2, new SpotCondition(CardType.COMPANION, Filters.maxResistance(0)))));
return action;
}
}

View File

@@ -45,7 +45,7 @@ public class AddTwilightEffect extends AbstractEffect implements Preventable {
}
@Override
public boolean isPrevented() {
public boolean isPrevented(LotroGame game) {
return _prevented;
}
@@ -61,7 +61,7 @@ public class AddTwilightEffect extends AbstractEffect implements Preventable {
@Override
protected FullEffectResult playEffectReturningResult(LotroGame game) {
if (!isPrevented()) {
if (!isPrevented(game)) {
int count = _twilight.evaluateExpression(game.getGameState(), game.getModifiersQuerying(), null);
game.getGameState().sendMessage(_sourceText + " added " + count + " twilight");
game.getGameState().addTwilight(count);

View File

@@ -58,7 +58,7 @@ public class DrawOneCardEffect extends AbstractEffect implements Preventable {
}
@Override
public boolean isPrevented() {
public boolean isPrevented(LotroGame game) {
return _prevented;
}
}

View File

@@ -33,6 +33,6 @@ public class PreventEffect extends AbstractEffect {
@Override
public boolean isPlayableInFull(LotroGame game) {
return !_preventable.isPrevented();
return !_preventable.isPrevented(game);
}
}

View File

@@ -1,7 +1,9 @@
package com.gempukku.lotro.logic.timing;
import com.gempukku.lotro.game.state.LotroGame;
public interface Preventable {
public void prevent();
public boolean isPrevented();
public boolean isPrevented(LotroGame game);
}