diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/decisions/ForEachBurdenYouSpotDecision.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/decisions/ForEachBurdenYouSpotDecision.java new file mode 100644 index 000000000..27b9de080 --- /dev/null +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/decisions/ForEachBurdenYouSpotDecision.java @@ -0,0 +1,26 @@ +package com.gempukku.lotro.cards.decisions; + +import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException; +import com.gempukku.lotro.logic.decisions.IntegerAwaitingDecision; + +import java.util.Map; + +public abstract class ForEachBurdenYouSpotDecision extends IntegerAwaitingDecision { + protected ForEachBurdenYouSpotDecision(int id, int burdens) { + super(id, "Choose number of burdens you wish to spot", 0, burdens); + } + + @Override + public Map getDecisionParameters() { + Map result = super.getDecisionParameters(); + result.put("defaultValue", result.get("max")); + return result; + } + + @Override + public void decisionMade(String result) throws DecisionResultInvalidException { + burdensSpotted(getValidatedResult(result)); + } + + protected abstract void burdensSpotted(int burdensSpotted); +} \ No newline at end of file diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/ForEachBurdenYouSpotEffect.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/ForEachBurdenYouSpotEffect.java new file mode 100644 index 000000000..5256f727f --- /dev/null +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/ForEachBurdenYouSpotEffect.java @@ -0,0 +1,42 @@ +package com.gempukku.lotro.cards.effects; + +import com.gempukku.lotro.cards.decisions.ForEachBurdenYouSpotDecision; +import com.gempukku.lotro.game.state.LotroGame; +import com.gempukku.lotro.logic.timing.Effect; +import com.gempukku.lotro.logic.timing.EffectResult; + +public abstract class ForEachBurdenYouSpotEffect implements Effect { + private String _playerId; + + protected ForEachBurdenYouSpotEffect(String playerId) { + _playerId = playerId; + } + + @Override + public String getText(LotroGame game) { + return null; + } + + @Override + public EffectResult.Type getType() { + return null; + } + + @Override + public EffectResult[] playEffect(LotroGame game) { + int burdens = game.getGameState().getBurdens(); + if (burdens == 0) + burdensSpotted(0); + else + game.getUserFeedback().sendAwaitingDecision(_playerId, + new ForEachBurdenYouSpotDecision(1, burdens) { + @Override + protected void burdensSpotted(int burdensSpotted) { + ForEachBurdenYouSpotEffect.this.burdensSpotted(burdensSpotted); + } + }); + return null; + } + + protected abstract void burdensSpotted(int burdensSpotted); +} diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set1/isengard/Card1_120.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set1/isengard/Card1_120.java index 8317b3867..383b0c51f 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set1/isengard/Card1_120.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set1/isengard/Card1_120.java @@ -5,6 +5,7 @@ import com.gempukku.lotro.cards.GameUtils; import com.gempukku.lotro.cards.PlayConditions; import com.gempukku.lotro.cards.actions.PlayPermanentAction; import com.gempukku.lotro.cards.costs.ChooseAndExertCharactersCost; +import com.gempukku.lotro.cards.effects.ForEachBurdenYouSpotEffect; import com.gempukku.lotro.cards.effects.RemoveTwilightEffect; import com.gempukku.lotro.common.*; import com.gempukku.lotro.filters.Filters; @@ -50,7 +51,7 @@ public class Card1_120 extends AbstractPermanent { } @Override - public List getExtraPhaseActions(String playerId, LotroGame game, PhysicalCard self) { + public List getExtraPhaseActions(final String playerId, final LotroGame game, PhysicalCard self) { final GameState gameState = game.getGameState(); if (PlayConditions.canUseShadowCardDuringPhase(gameState, Phase.SHADOW, self, 3)) { final ActivateCardAction action = new ActivateCardAction(self, Keyword.SHADOW); @@ -58,15 +59,21 @@ public class Card1_120 extends AbstractPermanent { final String fpPlayer = gameState.getCurrentPlayerId(); if (game.getModifiersQuerying().canLookOrRevealCardsInHand(game.getGameState(), fpPlayer)) { action.appendEffect( - new PlayoutDecisionEffect(game.getUserFeedback(), playerId, - new ArbitraryCardsSelectionDecision(1, "Choose card to discard", GameUtils.getRandomCards(gameState.getHand(fpPlayer), gameState.getBurdens()), 0, 1) { - @Override - public void decisionMade(String result) throws DecisionResultInvalidException { - List cards = getSelectedCardsByResponse(result); - if (cards.size() > 0) - action.appendEffect(new DiscardCardFromHandEffect(cards.get(0))); - } - })); + new ForEachBurdenYouSpotEffect(playerId) { + @Override + protected void burdensSpotted(int burdensSpotted) { + action.insertEffect( + new PlayoutDecisionEffect(game.getUserFeedback(), playerId, + new ArbitraryCardsSelectionDecision(1, "Choose card to discard", GameUtils.getRandomCards(gameState.getHand(fpPlayer), burdensSpotted), 0, 1) { + @Override + public void decisionMade(String result) throws DecisionResultInvalidException { + List cards = getSelectedCardsByResponse(result); + if (cards.size() > 0) + action.appendEffect(new DiscardCardFromHandEffect(cards.get(0))); + } + })); + } + }); } return Collections.singletonList(action); } diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set1/sauron/Card1_246.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set1/sauron/Card1_246.java index 2daa3e1cf..19701b5ea 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set1/sauron/Card1_246.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set1/sauron/Card1_246.java @@ -4,6 +4,7 @@ import com.gempukku.lotro.cards.AbstractEvent; import com.gempukku.lotro.cards.actions.PlayEventAction; import com.gempukku.lotro.cards.effects.AddUntilEndOfPhaseModifierEffect; import com.gempukku.lotro.cards.effects.CardAffectsCardEffect; +import com.gempukku.lotro.cards.effects.ForEachBurdenYouSpotEffect; import com.gempukku.lotro.cards.modifiers.StrengthModifier; import com.gempukku.lotro.common.Culture; import com.gempukku.lotro.common.Phase; @@ -28,17 +29,23 @@ public class Card1_246 extends AbstractEvent { } @Override - public PlayEventAction getPlayCardAction(String playerId, LotroGame game, PhysicalCard self, int twilightModifier) { - PlayEventAction action = new PlayEventAction(self); - Skirmish skirmish = game.getGameState().getSkirmish(); + public PlayEventAction getPlayCardAction(String playerId, LotroGame game, final PhysicalCard self, int twilightModifier) { + final PlayEventAction action = new PlayEventAction(self); + final Skirmish skirmish = game.getGameState().getSkirmish(); if (skirmish != null && Filters.filter(skirmish.getShadowCharacters(), game.getGameState(), game.getModifiersQuerying(), Filters.culture(Culture.SAURON), Filters.race(Race.ORC)).size() > 0 && skirmish.getFellowshipCharacter() != null) { int burdens = game.getGameState().getBurdens(); action.appendEffect(new CardAffectsCardEffect(self, skirmish.getFellowshipCharacter())); action.appendEffect( - new AddUntilEndOfPhaseModifierEffect( - new StrengthModifier(self, Filters.sameCard(skirmish.getFellowshipCharacter()), -burdens), Phase.SKIRMISH)); + new ForEachBurdenYouSpotEffect(playerId) { + @Override + protected void burdensSpotted(int burdensSpotted) { + action.insertEffect( + new AddUntilEndOfPhaseModifierEffect( + new StrengthModifier(self, Filters.sameCard(skirmish.getFellowshipCharacter()), -burdensSpotted), Phase.SKIRMISH)); + } + }); } return action; } diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set2/isengard/Card2_041.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set2/isengard/Card2_041.java index 502e5ab9f..e6fb92576 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set2/isengard/Card2_041.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set2/isengard/Card2_041.java @@ -5,15 +5,13 @@ import com.gempukku.lotro.cards.PlayConditions; import com.gempukku.lotro.cards.actions.PlayEventAction; import com.gempukku.lotro.cards.costs.ChooseAndExertCharactersCost; import com.gempukku.lotro.cards.effects.ChooseCardsFromDiscardEffect; +import com.gempukku.lotro.cards.effects.ForEachBurdenYouSpotEffect; import com.gempukku.lotro.cards.effects.PutCardFromDiscardOnBottomOfDeckEffect; import com.gempukku.lotro.cards.effects.ShuffleDeckEffect; 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.decisions.DecisionResultInvalidException; -import com.gempukku.lotro.logic.decisions.IntegerAwaitingDecision; -import com.gempukku.lotro.logic.effects.PlayoutDecisionEffect; import java.util.Collection; @@ -47,26 +45,24 @@ public class Card2_041 extends AbstractEvent { final PlayEventAction action = new PlayEventAction(self); action.appendCost( new ChooseAndExertCharactersCost(action, playerId, 1, 1, Filters.race(Race.URUK_HAI))); - action.appendCost( - new PlayoutDecisionEffect(game.getUserFeedback(), playerId, - new IntegerAwaitingDecision(1, "Choose number of burdens to spot", 0, game.getGameState().getBurdens()) { - @Override - public void decisionMade(String result) throws DecisionResultInvalidException { - int numberOfSpotted = getValidatedResult(result); - action.appendEffect( - new ChooseCardsFromDiscardEffect(playerId, numberOfSpotted, numberOfSpotted, Filters.type(CardType.MINION)) { - @Override - protected void cardsSelected(Collection cards) { - for (PhysicalCard card : cards) { - action.appendEffect( - new PutCardFromDiscardOnBottomOfDeckEffect(card)); - } - action.appendEffect( - new ShuffleDeckEffect(playerId)); - } - }); - } - })); + action.appendEffect( + new ForEachBurdenYouSpotEffect(playerId) { + @Override + protected void burdensSpotted(int burdensSpotted) { + action.insertEffect( + new ChooseCardsFromDiscardEffect(playerId, burdensSpotted, burdensSpotted, Filters.type(CardType.MINION)) { + @Override + protected void cardsSelected(Collection cards) { + for (PhysicalCard card : cards) { + action.appendEffect( + new PutCardFromDiscardOnBottomOfDeckEffect(card)); + } + action.appendEffect( + new ShuffleDeckEffect(playerId)); + } + }); + } + }); return action; } } diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set2/moria/Card2_072.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set2/moria/Card2_072.java index f3f0a0c26..26089adfb 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set2/moria/Card2_072.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set2/moria/Card2_072.java @@ -5,6 +5,7 @@ import com.gempukku.lotro.cards.PlayConditions; import com.gempukku.lotro.cards.actions.PlayEventAction; import com.gempukku.lotro.cards.costs.ChooseAndExertCharactersCost; import com.gempukku.lotro.cards.effects.AddTwilightEffect; +import com.gempukku.lotro.cards.effects.ForEachBurdenYouSpotEffect; import com.gempukku.lotro.common.CardType; import com.gempukku.lotro.common.Culture; import com.gempukku.lotro.common.Phase; @@ -12,9 +13,6 @@ 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.decisions.DecisionResultInvalidException; -import com.gempukku.lotro.logic.decisions.IntegerAwaitingDecision; -import com.gempukku.lotro.logic.effects.PlayoutDecisionEffect; /** * Set: Mines of Moria @@ -46,16 +44,14 @@ public class Card2_072 extends AbstractEvent { action.appendCost( new ChooseAndExertCharactersCost(action, playerId, 1, 1, Filters.culture(Culture.MORIA), Filters.type(CardType.MINION))); action.appendEffect( - new PlayoutDecisionEffect(game.getUserFeedback(), playerId, - new IntegerAwaitingDecision(1, "Choose number of burdens you wish to spot", 0, game.getGameState().getBurdens()) { - @Override - public void decisionMade(String result) throws DecisionResultInvalidException { - int spotBurdens = getValidatedResult(result); - int addTwilight = Math.min(5, spotBurdens); - action.appendEffect( - new AddTwilightEffect(addTwilight)); - } - })); + new ForEachBurdenYouSpotEffect(playerId) { + @Override + protected void burdensSpotted(int burdensSpotted) { + int addTwilight = Math.min(5, burdensSpotted); + action.insertEffect( + new AddTwilightEffect(addTwilight)); + } + }); return action; } } diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set2/sauron/Card2_087.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set2/sauron/Card2_087.java new file mode 100644 index 000000000..fa77feb06 --- /dev/null +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set2/sauron/Card2_087.java @@ -0,0 +1,54 @@ +package com.gempukku.lotro.cards.set2.sauron; + +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.ForEachBurdenYouSpotEffect; +import com.gempukku.lotro.common.Culture; +import com.gempukku.lotro.common.Phase; +import com.gempukku.lotro.common.Race; +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.DrawCardEffect; + +/** + * Set: Mines of Moria + * Side: Shadow + * Culture: Sauron + * Twilight Cost: 1 + * Type: Event + * Game Text: Shadow: Exert a [SAURON] Orc and spot X burdens to draw X cards (limit 5). + */ +public class Card2_087 extends AbstractEvent { + public Card2_087() { + super(Side.SHADOW, Culture.SAURON, "The Eye of Sauron", Phase.SHADOW); + } + + @Override + public boolean checkPlayRequirements(String playerId, LotroGame game, PhysicalCard self, int twilightModifier) { + return super.checkPlayRequirements(playerId, game, self, twilightModifier) + && PlayConditions.canExert(self, game.getGameState(), game.getModifiersQuerying(), Filters.culture(Culture.SAURON), Filters.race(Race.ORC)); + } + + @Override + public int getTwilightCost() { + return 1; + } + + @Override + public PlayEventAction getPlayCardAction(final String playerId, LotroGame game, PhysicalCard self, int twilightModifier) { + final PlayEventAction action = new PlayEventAction(self); + action.appendEffect( + new ForEachBurdenYouSpotEffect(playerId) { + @Override + protected void burdensSpotted(int burdensSpotted) { + int cardsDrawn = Math.min(5, burdensSpotted); + action.insertEffect( + new DrawCardEffect(playerId, cardsDrawn)); + } + }); + return action; + } +} diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set2/wraith/Card2_081.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set2/wraith/Card2_081.java index 3c4f57282..a47b4da40 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set2/wraith/Card2_081.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set2/wraith/Card2_081.java @@ -5,13 +5,11 @@ import com.gempukku.lotro.cards.PlayConditions; import com.gempukku.lotro.cards.actions.PlayEventAction; import com.gempukku.lotro.cards.costs.ChooseAndExertCharactersCost; import com.gempukku.lotro.cards.effects.ChooseAndExertCharactersEffect; +import com.gempukku.lotro.cards.effects.ForEachBurdenYouSpotEffect; 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.decisions.DecisionResultInvalidException; -import com.gempukku.lotro.logic.decisions.IntegerAwaitingDecision; -import com.gempukku.lotro.logic.effects.PlayoutDecisionEffect; /** * Set: Mines of Moria @@ -43,15 +41,13 @@ public class Card2_081 extends AbstractEvent { action.appendCost( new ChooseAndExertCharactersCost(action, playerId, 2, 2, Filters.race(Race.NAZGUL))); action.appendEffect( - new PlayoutDecisionEffect(game.getUserFeedback(), playerId, - new IntegerAwaitingDecision(1, "Choose number of burdens you wish to spot", 0, game.getGameState().getBurdens()) { - @Override - public void decisionMade(String result) throws DecisionResultInvalidException { - int spottedBurdens = getValidatedResult(result); - action.insertEffect( - new ChooseAndExertCharactersEffect(action, playerId, spottedBurdens, spottedBurdens, Filters.type(CardType.COMPANION))); - } - })); + new ForEachBurdenYouSpotEffect(playerId) { + @Override + protected void burdensSpotted(int burdensSpotted) { + action.insertEffect( + new ChooseAndExertCharactersEffect(action, playerId, burdensSpotted, burdensSpotted, Filters.type(CardType.COMPANION))); + } + }); return action; } }