"Saruman's Reach", extracting the PutOnTheOneRing and TakeOffTheOneRing from The One Ring cards, as it's a more general game effect.

This commit is contained in:
marcins78@gmail.com
2011-08-30 23:24:16 +00:00
parent b2ea46d825
commit d175cc8c3c
16 changed files with 220 additions and 53 deletions

View File

@@ -0,0 +1,17 @@
package com.gempukku.lotro.cards.effects;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
public class PutOnTheOneRingEffect extends UnrespondableEffect {
@Override
public boolean canPlayEffect(LotroGame game) {
return !game.getGameState().isWearingRing();
}
@Override
public void playEffect(LotroGame game) {
game.getGameState().setWearingRing(true);
}
}

View File

@@ -0,0 +1,16 @@
package com.gempukku.lotro.cards.effects;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
public class TakeOffTheOneRingEffect extends UnrespondableEffect {
@Override
public boolean canPlayEffect(LotroGame game) {
return game.getGameState().isWearingRing();
}
@Override
public void playEffect(LotroGame game) {
game.getGameState().setWearingRing(false);
}
}

View File

@@ -1,9 +1,7 @@
package com.gempukku.lotro.cards.set1;
import com.gempukku.lotro.cards.AbstractLotroCardBlueprint;
import com.gempukku.lotro.cards.effects.AddBurdenEffect;
import com.gempukku.lotro.cards.effects.AddUntilStartOfPhaseActionProxyEffect;
import com.gempukku.lotro.cards.effects.CancelEffect;
import com.gempukku.lotro.cards.effects.*;
import com.gempukku.lotro.cards.modifiers.StrengthModifier;
import com.gempukku.lotro.cards.modifiers.VitalityModifier;
import com.gempukku.lotro.common.CardType;
@@ -21,8 +19,10 @@ import com.gempukku.lotro.logic.modifiers.Modifier;
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.results.StartOfPhaseResult;
import com.gempukku.lotro.logic.timing.results.WoundResult;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -60,23 +60,21 @@ public class Card1_001 extends AbstractLotroCardBlueprint {
action.addCost(new CancelEffect(effect));
action.addEffect(new AddBurdenEffect(playerId));
action.addEffect(new AddBurdenEffect(playerId));
action.addEffect(new AddUntilStartOfPhaseActionProxyEffect(
action.addEffect(new PutOnTheOneRingEffect());
action.addEffect(new AddUntilEndOfPhaseActionProxyEffect(
new AbstractActionProxy() {
@Override
public List<Action> getRequiredIsAboutToActions(LotroGame lotroGame, Effect effect, EffectResult effectResult) {
if (effectResult.getType() == EffectResult.Type.WOUND
&& ((WoundResult) effectResult).getWoundedCard() == self.getAttachedTo()) {
List<Action> actions = new LinkedList<Action>();
CostToEffectAction action = new CostToEffectAction(self, "Add 2 burdens instead of taking a wound");
action.addCost(new CancelEffect(effect));
action.addEffect(new AddBurdenEffect(playerId));
action.addEffect(new AddBurdenEffect(playerId));
return actions;
} else {
return null;
public List<? extends Action> getRequiredWhenActions(LotroGame lotroGame, EffectResult effectResult) {
if (effectResult.getType() == EffectResult.Type.START_OF_PHASE
&& ((StartOfPhaseResult) effectResult).getPhase() == Phase.REGROUP) {
CostToEffectAction action = new CostToEffectAction(self, "Take off The One Ring");
action.addEffect(new TakeOffTheOneRingEffect());
return Collections.singletonList(action);
}
return null;
}
}, Phase.REGROUP));
}
, Phase.REGROUP));
actions.add(action);
return actions;
@@ -85,6 +83,22 @@ public class Card1_001 extends AbstractLotroCardBlueprint {
}
}
@Override
public List<? extends Action> getRequiredIsAboutToActions(LotroGame game, Effect effect, EffectResult effectResult, PhysicalCard self) {
if (effectResult.getType() == EffectResult.Type.WOUND
&& game.getGameState().isWearingRing()
&& ((WoundResult) effectResult).getWoundedCard() == self.getAttachedTo()) {
List<Action> actions = new LinkedList<Action>();
CostToEffectAction action = new CostToEffectAction(self, "Add 2 burdens instead of taking a wound");
action.addCost(new CancelEffect(effect));
action.addEffect(new AddBurdenEffect(self.getOwner()));
action.addEffect(new AddBurdenEffect(self.getOwner()));
return actions;
} else {
return null;
}
}
@Override
public int getTwilightCost() {
throw new UnsupportedOperationException("This method should not be called on this card");

View File

@@ -1,9 +1,7 @@
package com.gempukku.lotro.cards.set1;
import com.gempukku.lotro.cards.AbstractLotroCardBlueprint;
import com.gempukku.lotro.cards.effects.AddBurdenEffect;
import com.gempukku.lotro.cards.effects.AddUntilStartOfPhaseActionProxyEffect;
import com.gempukku.lotro.cards.effects.CancelEffect;
import com.gempukku.lotro.cards.effects.*;
import com.gempukku.lotro.cards.modifiers.StrengthModifier;
import com.gempukku.lotro.common.CardType;
import com.gempukku.lotro.common.Keyword;
@@ -20,8 +18,10 @@ import com.gempukku.lotro.logic.modifiers.Modifier;
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.results.StartOfPhaseResult;
import com.gempukku.lotro.logic.timing.results.WoundResult;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -58,22 +58,21 @@ public class Card1_002 extends AbstractLotroCardBlueprint {
CostToEffectAction action = new CostToEffectAction(self, "Put on The One Ring until the Regroup phase");
action.addCost(new CancelEffect(effect));
action.addEffect(new AddBurdenEffect(playerId));
action.addEffect(new AddUntilStartOfPhaseActionProxyEffect(
action.addEffect(new PutOnTheOneRingEffect());
action.addEffect(new AddUntilEndOfPhaseActionProxyEffect(
new AbstractActionProxy() {
@Override
public List<Action> getRequiredIsAboutToActions(LotroGame lotroGame, Effect effect, EffectResult effectResult) {
if (effectResult.getType() == EffectResult.Type.WOUND
&& ((WoundResult) effectResult).getWoundedCard() == self.getAttachedTo()) {
List<Action> actions = new LinkedList<Action>();
CostToEffectAction action = new CostToEffectAction(self, "Add a burden instead of taking a wound");
action.addCost(new CancelEffect(effect));
action.addEffect(new AddBurdenEffect(playerId));
return actions;
} else {
return null;
public List<? extends Action> getRequiredWhenActions(LotroGame lotroGame, EffectResult effectResult) {
if (effectResult.getType() == EffectResult.Type.START_OF_PHASE
&& ((StartOfPhaseResult) effectResult).getPhase() == Phase.REGROUP) {
CostToEffectAction action = new CostToEffectAction(self, "Take off The One Ring");
action.addEffect(new TakeOffTheOneRingEffect());
return Collections.singletonList(action);
}
return null;
}
}, Phase.REGROUP));
}
, Phase.REGROUP));
actions.add(action);
return actions;
@@ -82,6 +81,21 @@ public class Card1_002 extends AbstractLotroCardBlueprint {
}
}
@Override
public List<? extends Action> getRequiredIsAboutToActions(LotroGame game, Effect effect, EffectResult effectResult, PhysicalCard self) {
if (effectResult.getType() == EffectResult.Type.WOUND
&& game.getGameState().isWearingRing()
&& ((WoundResult) effectResult).getWoundedCard() == self.getAttachedTo()) {
List<Action> actions = new LinkedList<Action>();
CostToEffectAction action = new CostToEffectAction(self, "Add a burden instead of taking a wound");
action.addCost(new CancelEffect(effect));
action.addEffect(new AddBurdenEffect(self.getOwner()));
return actions;
} else {
return null;
}
}
@Override
public int getTwilightCost() {
throw new UnsupportedOperationException("This method should not be called on this card");

View File

@@ -53,7 +53,7 @@ public class Card1_029 extends AbstractLotroCardBlueprint {
new AddUntilEndOfPhaseActionProxyEffect(
new AbstractActionProxy() {
@Override
public List<Action> getRequiredWhenActions(LotroGame lotroGame, EffectResult effectResult) {
public List<? extends Action> getRequiredWhenActions(LotroGame lotroGame, EffectResult effectResult) {
if (PlayConditions.winsSkirmish(effectResult, elf)) {
SkirmishResult skirmishResult = (SkirmishResult) effectResult;
List<PhysicalCard> losers = skirmishResult.getLosers();

View File

@@ -3,10 +3,12 @@ package com.gempukku.lotro.cards.set1.isengard;
import com.gempukku.lotro.cards.AbstractLotroCardBlueprint;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.actions.PlayEventAction;
import com.gempukku.lotro.cards.effects.ExertCharacterEffect;
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.effects.ChooseActiveCardEffect;
import com.gempukku.lotro.logic.effects.DiscardCardsFromPlayEffect;
import com.gempukku.lotro.logic.timing.Action;
@@ -37,7 +39,14 @@ public class Card1_136 extends AbstractLotroCardBlueprint {
public List<? extends Action> getPlayablePhaseActions(String playerId, LotroGame game, PhysicalCard self) {
if (PlayConditions.canPlayShadowCardDuringPhase(game, Phase.SHADOW, self)
&& Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), Filters.culture(Culture.ISENGARD), Filters.type(CardType.MINION), Filters.canExert())) {
PlayEventAction action = new PlayEventAction(self);
final PlayEventAction action = new PlayEventAction(self);
action.addCost(
new ChooseActiveCardEffect(playerId, "Choose an ISENGARD minion", Filters.culture(Culture.ISENGARD), Filters.type(CardType.MINION), Filters.canExert()) {
@Override
protected void cardSelected(LotroGame game, PhysicalCard isengardMinion) {
action.addCost(new ExertCharacterEffect(isengardMinion));
}
});
action.addEffect(
new DiscardCardsFromPlayEffect(Filters.type(CardType.CONDITION)));

View File

@@ -0,0 +1,82 @@
package com.gempukku.lotro.cards.set1.isengard;
import com.gempukku.lotro.cards.AbstractLotroCardBlueprint;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.actions.PlayEventAction;
import com.gempukku.lotro.cards.effects.ChoiceEffect;
import com.gempukku.lotro.cards.effects.ExertCharacterEffect;
import com.gempukku.lotro.cards.effects.PutOnTheOneRingEffect;
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.effects.ChooseActiveCardEffect;
import com.gempukku.lotro.logic.effects.ChooseActiveCardsEffect;
import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.Effect;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
/**
* Set: The Fellowship of the Ring
* Side: Shadow
* Culture: Isengard
* Twilight Cost: 0
* Type: Event
* Game Text: Search. Maneuver: Exert an Uruk-hai to make the opponent choose to either exert 2 companions or make the
* Ring-bearer put on The One Ring until the regroup phase.
*/
public class Card1_137 extends AbstractLotroCardBlueprint {
public Card1_137() {
super(Side.SHADOW, CardType.EVENT, Culture.ISENGARD, "Saruman's Reach", "1_137");
addKeyword(Keyword.SEARCH);
addKeyword(Keyword.MANEUVER);
}
@Override
public int getTwilightCost() {
return 0;
}
@Override
public List<? extends Action> getPlayablePhaseActions(String playerId, LotroGame game, PhysicalCard self) {
if (PlayConditions.canPlayShadowCardDuringPhase(game, Phase.MANEUVER, self)
&& Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), Filters.keyword(Keyword.URUK_HAI), Filters.canExert())) {
final PlayEventAction action = new PlayEventAction(self);
action.addCost(
new ChooseActiveCardEffect(playerId, "Choose an Uruk-hai", Filters.keyword(Keyword.URUK_HAI), Filters.canExert()) {
@Override
protected void cardSelected(LotroGame game, PhysicalCard urukHai) {
action.addCost(new ExertCharacterEffect(urukHai));
}
}
);
List<Effect> possibleEffects = new LinkedList<Effect>();
possibleEffects.add(
new ChooseActiveCardsEffect(playerId, "Choose characters to exert", 2, 2, Filters.type(CardType.COMPANION), Filters.canExert()) {
@Override
public String getText() {
return "Exert 2 companions";
}
@Override
protected void cardsSelected(List<PhysicalCard> cards) {
for (PhysicalCard card : cards)
action.addEffect(new ExertCharacterEffect(card));
}
});
possibleEffects.add(new PutOnTheOneRingEffect());
action.addEffect(
new ChoiceEffect(action, game.getGameState().getCurrentPlayerId(), possibleEffects, false));
return Collections.singletonList(action);
}
return null;
}
}

View File

@@ -10,7 +10,7 @@ public enum Keyword {
ROAMING("Roaming"),
WEATHER("Weather"), TALE("Tale"), SPELL("Spell"),
WEATHER("Weather"), TALE("Tale"), SPELL("Spell"), SEARCH("Search"),
RIVER("River"), PLAINS("Plains"), UNDERGROUND("Underground"), SANCTUARY("Sanctuary"),

View File

@@ -9,27 +9,27 @@ import java.util.List;
public abstract class AbstractActionProxy implements ActionProxy {
@Override
public List<Action> getRequiredIsAboutToActions(LotroGame lotroGame, Effect effect, EffectResult effectResult) {
public List<? extends Action> getRequiredIsAboutToActions(LotroGame lotroGame, Effect effect, EffectResult effectResult) {
return null;
}
@Override
public List<Action> getRequiredWhenActions(LotroGame lotroGame, EffectResult effectResult) {
public List<? extends Action> getRequiredWhenActions(LotroGame lotroGame, EffectResult effectResult) {
return null;
}
@Override
public List<Action> getPlayablePhaseActions(String playerId, LotroGame lotroGame) {
public List<? extends Action> getPlayablePhaseActions(String playerId, LotroGame lotroGame) {
return null;
}
@Override
public List<Action> getPlayableIsAboutToActions(String playerId, LotroGame lotroGame, Effect effect, EffectResult effectResult) {
public List<? extends Action> getPlayableIsAboutToActions(String playerId, LotroGame lotroGame, Effect effect, EffectResult effectResult) {
return null;
}
@Override
public List<Action> getPlayableWhenActions(String playerId, LotroGame lotroGame, EffectResult effectResult) {
public List<? extends Action> getPlayableWhenActions(String playerId, LotroGame lotroGame, EffectResult effectResult) {
return null;
}
}

View File

@@ -8,13 +8,13 @@ import com.gempukku.lotro.logic.timing.EffectResult;
import java.util.List;
public interface ActionProxy {
public List<Action> getRequiredIsAboutToActions(LotroGame game, Effect effect, EffectResult effectResult);
public List<? extends Action> getRequiredIsAboutToActions(LotroGame game, Effect effect, EffectResult effectResult);
public List<Action> getRequiredWhenActions(LotroGame game, EffectResult effectResult);
public List<? extends Action> getRequiredWhenActions(LotroGame game, EffectResult effectResult);
public List<Action> getPlayablePhaseActions(String playerId, LotroGame game);
public List<? extends Action> getPlayablePhaseActions(String playerId, LotroGame game);
public List<Action> getPlayableIsAboutToActions(String playerId, LotroGame game, Effect effect, EffectResult effectResult);
public List<? extends Action> getPlayableIsAboutToActions(String playerId, LotroGame game, Effect effect, EffectResult effectResult);
public List<Action> getPlayableWhenActions(String playerId, LotroGame game, EffectResult effectResult);
public List<? extends Action> getPlayableWhenActions(String playerId, LotroGame game, EffectResult effectResult);
}

View File

@@ -28,6 +28,7 @@ public class GameState {
private int _moveCount;
private boolean _fierceSkirmishes;
private boolean _wearingRing;
private Map<String, Integer> _playerPosition = new HashMap<String, Integer>();
private Map<PhysicalCard, Map<Token, Integer>> _cardTokens = new HashMap<PhysicalCard, Map<Token, Integer>>();
@@ -68,6 +69,14 @@ public class GameState {
_decks.get(playerId).add(new PhysicalCardImpl(nextCardId(), playerId, Zone.DECK, card));
}
public void setWearingRing(boolean wearingRing) {
_wearingRing = wearingRing;
}
public boolean isWearingRing() {
return _wearingRing;
}
public PlayerOrder getPlayerOrder() {
return _playerOrder;
}

View File

@@ -78,7 +78,7 @@ public class DefaultActionsEnvironment implements ActionsEnvironment {
List<Action> gatheredActions = gatherActions.getActions();
for (ActionProxy actionProxy : _actionProxies) {
List<Action> actions = actionProxy.getRequiredIsAboutToActions(_lotroGame, effect, effectResult);
List<? extends Action> actions = actionProxy.getRequiredIsAboutToActions(_lotroGame, effect, effectResult);
if (actions != null)
gatheredActions.addAll(actions);
}
@@ -105,7 +105,7 @@ public class DefaultActionsEnvironment implements ActionsEnvironment {
List<Action> gatheredActions = gatherActions.getActions();
for (ActionProxy actionProxy : _actionProxies) {
List<Action> actions = actionProxy.getPlayableIsAboutToActions(playerId, _lotroGame, effect, effectResult);
List<? extends Action> actions = actionProxy.getPlayableIsAboutToActions(playerId, _lotroGame, effect, effectResult);
if (actions != null)
gatheredActions.addAll(actions);
}
@@ -122,7 +122,7 @@ public class DefaultActionsEnvironment implements ActionsEnvironment {
List<Action> gatheredActions = gatherActions.getActions();
for (ActionProxy actionProxy : _actionProxies) {
List<Action> actions = actionProxy.getRequiredWhenActions(_lotroGame, effectResult);
List<? extends Action> actions = actionProxy.getRequiredWhenActions(_lotroGame, effectResult);
if (actions != null)
gatheredActions.addAll(actions);
}
@@ -149,7 +149,7 @@ public class DefaultActionsEnvironment implements ActionsEnvironment {
List<Action> gatheredActions = gatherActions.getActions();
for (ActionProxy actionProxy : _actionProxies) {
List<Action> actions = actionProxy.getPlayableWhenActions(playerId, _lotroGame, effectResult);
List<? extends Action> actions = actionProxy.getPlayableWhenActions(playerId, _lotroGame, effectResult);
if (actions != null)
gatheredActions.addAll(actions);
}

View File

@@ -13,25 +13,31 @@ import java.util.List;
public abstract class ChooseActiveCardsEffect extends UnrespondableEffect {
private String _playerId;
private String _choiceText;
private int _minimum;
private int _maximum;
private Filter[] _filters;
public ChooseActiveCardsEffect(String playerId, String choiceText, int maximum, Filter... filters) {
this(playerId, choiceText, 1, maximum, filters);
}
public ChooseActiveCardsEffect(String playerId, String choiceText, int minimum, int maximum, Filter... filters) {
_playerId = playerId;
_choiceText = choiceText;
_minimum = minimum;
_maximum = maximum;
_filters = filters;
}
@Override
public boolean canPlayEffect(LotroGame game) {
return Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), _filters);
return Filters.countActive(game.getGameState(), game.getModifiersQuerying(), _filters) >= _minimum;
}
@Override
public void playEffect(LotroGame game) {
game.getUserFeedback().sendAwaitingDecision(_playerId,
new CardsSelectionDecision(1, _choiceText, Filters.filterActive(game.getGameState(), game.getModifiersQuerying(), _filters), 1, _maximum) {
new CardsSelectionDecision(1, _choiceText, Filters.filterActive(game.getGameState(), game.getModifiersQuerying(), _filters), _minimum, _maximum) {
@Override
public void decisionMade(String result) throws DecisionResultInvalidException {
List<PhysicalCard> selectedCards = getSelectedCardsByResponse(result);

View File

@@ -25,7 +25,7 @@ public class CharacterDeathRule {
_actionsEnvironment.addAlwaysOnActionProxy(
new AbstractActionProxy() {
@Override
public List<Action> getRequiredWhenActions(LotroGame game, EffectResult effectResult) {
public List<? extends Action> getRequiredWhenActions(LotroGame game, EffectResult effectResult) {
List<Action> actions = new LinkedList<Action>();
GameState gameState = game.getGameState();

View File

@@ -27,7 +27,7 @@ public class EndEffectsAndActionsRule {
_actionsEnvironment.addAlwaysOnActionProxy(
new AbstractActionProxy() {
@Override
public List<Action> getRequiredIsAboutToActions(final LotroGame lotroGame, Effect effect, EffectResult effectResult) {
public List<? extends Action> getRequiredIsAboutToActions(final LotroGame lotroGame, Effect effect, EffectResult effectResult) {
if (effectResult.getType() == EffectResult.Type.START_OF_PHASE)
return Collections.<Action>singletonList(new SimpleEffectAction(
new UnrespondableEffect() {

View File

@@ -30,7 +30,7 @@ public class ResolveSkirmishRule {
_actionsEnvironment.addAlwaysOnActionProxy(
new AbstractActionProxy() {
@Override
public List<Action> getRequiredWhenActions(LotroGame lotroGame, EffectResult effectResult) {
public List<? extends Action> getRequiredWhenActions(LotroGame lotroGame, EffectResult effectResult) {
if (effectResult.getType() == EffectResult.Type.RESOLVE_SKIRMISH) {
NormalSkirmishResult skirmishResult = (NormalSkirmishResult) effectResult;
List<PhysicalCard> winners = skirmishResult.getWinners();