From a460e992ad4223de8b56a12ce51907f612c5940b Mon Sep 17 00:00:00 2001 From: "marcin.sciesinski" Date: Mon, 13 Nov 2017 17:33:53 -0800 Subject: [PATCH] Refactored "Underground Lake" --- .../CheckPhaseLimitPerPlayerEffect.java | 56 +++++++++++++++++++ .../lotro/cards/set31/site/Card31_048.java | 3 +- 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/CheckPhaseLimitPerPlayerEffect.java diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/CheckPhaseLimitPerPlayerEffect.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/CheckPhaseLimitPerPlayerEffect.java new file mode 100644 index 000000000..ba165f23e --- /dev/null +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/effects/CheckPhaseLimitPerPlayerEffect.java @@ -0,0 +1,56 @@ +package com.gempukku.lotro.cards.effects; + +import com.gempukku.lotro.common.Phase; +import com.gempukku.lotro.game.PhysicalCard; +import com.gempukku.lotro.game.state.LotroGame; +import com.gempukku.lotro.logic.actions.SubAction; +import com.gempukku.lotro.logic.timing.Action; +import com.gempukku.lotro.logic.timing.Effect; +import com.gempukku.lotro.logic.timing.UnrespondableEffect; + +public class CheckPhaseLimitPerPlayerEffect extends UnrespondableEffect { + private Action _action; + private PhysicalCard _card; + private String _limitPrefix; + private String _playerId; + private int _limit; + private Phase _phase; + private Effect _limitedEffect; + + public CheckPhaseLimitPerPlayerEffect(Action action, PhysicalCard card, int limit, Effect limitedEffect) { + this(action, card, limit, null, limitedEffect); + } + + public CheckPhaseLimitPerPlayerEffect(Action action, PhysicalCard card, int limit, Phase phase, Effect limitedEffect) { + this(action, card, "", limit, phase, limitedEffect); + } + + public CheckPhaseLimitPerPlayerEffect(Action action, PhysicalCard card, String limitPrefix, int limit, Phase phase, Effect limitedEffect) { + this(action, card, limitPrefix, "", limit, phase, limitedEffect); + } + + public CheckPhaseLimitPerPlayerEffect(Action action, PhysicalCard card, String limitPrefix, String playerId, int limit, Phase phase, Effect limitedEffect) { + _card = card; + _limitPrefix = limitPrefix; + _playerId = playerId; + _limit = limit; + _phase = phase; + _limitedEffect = limitedEffect; + _action = action; + } + + @Override + public void doPlayEffect(LotroGame game) { + Phase phase = _phase; + if (phase == null) + phase = game.getGameState().getCurrentPhase(); + + int incrementedBy = game.getModifiersQuerying().getUntilEndOfPhaseLimitCounter(_card, _playerId + "-" + _limitPrefix, phase).incrementToLimit(_limit, 1); + if (incrementedBy > 0) { + SubAction subAction = new SubAction(_action); + subAction.appendEffect( + _limitedEffect); + game.getActionsEnvironment().addActionToStack(subAction); + } + } +} diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set31/site/Card31_048.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set31/site/Card31_048.java index fd900802c..521a7ac9b 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set31/site/Card31_048.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set31/site/Card31_048.java @@ -2,6 +2,7 @@ package com.gempukku.lotro.cards.set31.site; import com.gempukku.lotro.cards.AbstractSite; import com.gempukku.lotro.cards.PlayConditions; +import com.gempukku.lotro.cards.effects.CheckPhaseLimitPerPlayerEffect; import com.gempukku.lotro.cards.effects.CheckTurnLimitEffect; import com.gempukku.lotro.cards.effects.CheckTurnLimitPerPlayerEffect; import com.gempukku.lotro.cards.effects.choose.ChooseAndExertCharactersEffect; @@ -35,7 +36,7 @@ public class Card31_048 extends AbstractSite { public List getPhaseActions(final String playerId, final LotroGame game, final PhysicalCard self) { if (PlayConditions.canUseSiteDuringPhase(game, Phase.MANEUVER, self)) { final ActivateCardAction action = new ActivateCardAction(self); - action.appendEffect(new CheckTurnLimitPerPlayerEffect(action, self, playerId, 1, + action.appendEffect(new CheckPhaseLimitPerPlayerEffect(action, self, "", playerId, 1, Phase.MANEUVER, new ChooseAndPlayCardFromDeckEffect(playerId, Filters.or(Filters.and(Side.SHADOW, CardType.CONDITION), Filters.name("The One Ring"))))); return Collections.singletonList(action); }