Adding twilight now is a preventable effect, due to some card...
This commit is contained in:
@@ -6,9 +6,11 @@ import com.gempukku.lotro.logic.timing.Cost;
|
||||
import com.gempukku.lotro.logic.timing.CostResolution;
|
||||
import com.gempukku.lotro.logic.timing.Effect;
|
||||
import com.gempukku.lotro.logic.timing.EffectResult;
|
||||
import com.gempukku.lotro.logic.timing.results.AddTwilightResult;
|
||||
|
||||
public class AddTwilightEffect implements Effect, Cost {
|
||||
private PhysicalCard _source;
|
||||
private boolean _prevented;
|
||||
private int _twilight;
|
||||
|
||||
public AddTwilightEffect(PhysicalCard source, int twilight) {
|
||||
@@ -27,20 +29,34 @@ public class AddTwilightEffect implements Effect, Cost {
|
||||
|
||||
@Override
|
||||
public EffectResult.Type getType() {
|
||||
return null;
|
||||
return EffectResult.Type.ADD_TWILIGHT;
|
||||
}
|
||||
|
||||
public void prevent() {
|
||||
_prevented = true;
|
||||
}
|
||||
|
||||
public boolean isPrevented() {
|
||||
return _prevented;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EffectResult[] playEffect(LotroGame game) {
|
||||
game.getGameState().sendMessage(_twilight + " gets added to the twilight pool");
|
||||
game.getGameState().addTwilight(_twilight);
|
||||
if (!isPrevented()) {
|
||||
game.getGameState().sendMessage(_twilight + " gets added to the twilight pool");
|
||||
game.getGameState().addTwilight(_twilight);
|
||||
return new EffectResult[]{new AddTwilightResult(_source)};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CostResolution playCost(LotroGame game) {
|
||||
game.getGameState().sendMessage(_twilight + " gets added to the twilight pool");
|
||||
game.getGameState().addTwilight(_twilight);
|
||||
if (!isPrevented()) {
|
||||
game.getGameState().sendMessage(_twilight + " gets added to the twilight pool");
|
||||
game.getGameState().addTwilight(_twilight);
|
||||
return new CostResolution(new EffectResult[]{new AddTwilightResult(_source)}, true);
|
||||
}
|
||||
return new CostResolution(null, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.gempukku.lotro.cards.set3.shire;
|
||||
|
||||
import com.gempukku.lotro.cards.AbstractPermanent;
|
||||
import com.gempukku.lotro.cards.PlayConditions;
|
||||
import com.gempukku.lotro.cards.costs.ChooseAndExertCharactersCost;
|
||||
import com.gempukku.lotro.cards.effects.AddTwilightEffect;
|
||||
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.ActivateCardAction;
|
||||
import com.gempukku.lotro.logic.timing.Action;
|
||||
import com.gempukku.lotro.logic.timing.Effect;
|
||||
import com.gempukku.lotro.logic.timing.EffectResult;
|
||||
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Set: Realms of Elf-lords
|
||||
* Side: Free
|
||||
* Culture: Shire
|
||||
* Twilight Cost: 0
|
||||
* Type: Condition
|
||||
* Game Text: Tale. Plays to your support area. Response: If a Shadow card is about to add any number of twilight
|
||||
* tokens, exert a Hobbit ally to prevent this.
|
||||
*/
|
||||
public class Card3_114 extends AbstractPermanent {
|
||||
public Card3_114() {
|
||||
super(Side.FREE_PEOPLE, 0, CardType.CONDITION, Culture.SHIRE, Zone.FREE_SUPPORT, "Three Monstrous Trolls");
|
||||
addKeyword(Keyword.TALE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Action> getOptionalBeforeActions(String playerId, LotroGame game, Effect effect, PhysicalCard self) {
|
||||
if (effect.getType() == EffectResult.Type.ADD_TWILIGHT
|
||||
&& PlayConditions.canExert(self, game.getGameState(), game.getModifiersQuerying(), Filters.race(Race.HOBBIT), Filters.type(CardType.ALLY))) {
|
||||
final AddTwilightEffect addTwilightEffect = (AddTwilightEffect) effect;
|
||||
PhysicalCard source = addTwilightEffect.getSource();
|
||||
if (!addTwilightEffect.isPrevented() && source != null && source.getBlueprint().getSide() == Side.SHADOW) {
|
||||
ActivateCardAction action = new ActivateCardAction(self, Keyword.RESPONSE);
|
||||
action.appendCost(
|
||||
new ChooseAndExertCharactersCost(action, playerId, 1, 1, Filters.race(Race.HOBBIT), Filters.type(CardType.ALLY)));
|
||||
action.appendEffect(
|
||||
new UnrespondableEffect() {
|
||||
@Override
|
||||
protected void doPlayEffect(LotroGame game) {
|
||||
addTwilightEffect.prevent();
|
||||
}
|
||||
});
|
||||
return Collections.singletonList(action);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,8 @@ public abstract class EffectResult {
|
||||
|
||||
ASSIGNMENT, OVERWHELM_IN_SKIRMISH, RESOLVE_SKIRMISH,
|
||||
|
||||
ADD_TWILIGHT,
|
||||
|
||||
START_OF_PHASE,
|
||||
END_OF_PHASE,
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.gempukku.lotro.logic.timing.results;
|
||||
|
||||
import com.gempukku.lotro.game.PhysicalCard;
|
||||
import com.gempukku.lotro.logic.timing.EffectResult;
|
||||
|
||||
public class AddTwilightResult extends EffectResult {
|
||||
private PhysicalCard _source;
|
||||
|
||||
public AddTwilightResult(PhysicalCard source) {
|
||||
super(EffectResult.Type.ADD_TWILIGHT);
|
||||
_source = source;
|
||||
}
|
||||
|
||||
public PhysicalCard getSource() {
|
||||
return _source;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user