From 033401195e85844c547239c09b151e40308684fa Mon Sep 17 00:00:00 2001 From: "marcins78@gmail.com" Date: Tue, 6 Sep 2011 09:00:10 +0000 Subject: [PATCH] "Stout and Sturdy" --- .../gempukku/lotro/cards/AbstractEvent.java | 31 +++++++----- .../gempukku/lotro/cards/PlayConditions.java | 20 ++++++++ .../lotro/cards/set1/shire/Card1_315.java | 50 +++++++++++++++++++ 3 files changed, 88 insertions(+), 13 deletions(-) create mode 100644 gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set1/shire/Card1_315.java diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/AbstractEvent.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/AbstractEvent.java index a4c1710dc..f8a2e4d3f 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/AbstractEvent.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/AbstractEvent.java @@ -10,24 +10,29 @@ import java.util.Collections; import java.util.List; public abstract class AbstractEvent extends AbstractLotroCardBlueprint { - private Phase _playableInPhase; + private Phase[] _playableInPhases; - public AbstractEvent(Side side, Culture culture, String name, Phase playableInPhase) { + public AbstractEvent(Side side, Culture culture, String name, Phase... playableInPhases) { super(side, CardType.EVENT, culture, name); - _playableInPhase = playableInPhase; - if (_playableInPhase == Phase.FELLOWSHIP) + _playableInPhases = playableInPhases; + for (Phase playableInPhase : _playableInPhases) + processPhase(playableInPhase); + } + + private void processPhase(Phase phase) { + if (phase == Phase.FELLOWSHIP) addKeyword(Keyword.FELLOWSHIP); - else if (_playableInPhase == Phase.SHADOW) + else if (phase == Phase.SHADOW) addKeyword(Keyword.SHADOW); - else if (_playableInPhase == Phase.MANEUVER) + else if (phase == Phase.MANEUVER) addKeyword(Keyword.MANEUVER); - else if (_playableInPhase == Phase.ARCHERY) + else if (phase == Phase.ARCHERY) addKeyword(Keyword.ARCHERY); - else if (_playableInPhase == Phase.ASSIGNMENT) + else if (phase == Phase.ASSIGNMENT) addKeyword(Keyword.ASSIGNMENT); - else if (_playableInPhase == Phase.SKIRMISH) + else if (phase == Phase.SKIRMISH) addKeyword(Keyword.SKIRMISH); - else if (_playableInPhase == Phase.REGROUP) + else if (phase == Phase.REGROUP) addKeyword(Keyword.REGROUP); else addKeyword(Keyword.RESPONSE); @@ -35,10 +40,10 @@ public abstract class AbstractEvent extends AbstractLotroCardBlueprint { @Override public final List getPhaseActions(String playerId, LotroGame game, PhysicalCard self) { - if (_playableInPhase != null) { + if (_playableInPhases != null) { Side side = self.getBlueprint().getSide(); - if ((side == Side.FREE_PEOPLE && PlayConditions.canPlayFPCardDuringPhase(game, _playableInPhase, self)) - || (side == Side.SHADOW && PlayConditions.canPlayShadowCardDuringPhase(game, _playableInPhase, self))) { + if ((side == Side.FREE_PEOPLE && PlayConditions.canPlayFPCardDuringPhase(game, _playableInPhases, self)) + || (side == Side.SHADOW && PlayConditions.canPlayShadowCardDuringPhase(game, _playableInPhases, self))) { if (checkPlayRequirements(playerId, game, self)) return Collections.singletonList(getPlayCardAction(playerId, game, self, 0)); } diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/PlayConditions.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/PlayConditions.java index 702cb1271..57fa5ce91 100644 --- a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/PlayConditions.java +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/PlayConditions.java @@ -29,12 +29,32 @@ public class PlayConditions { && (!self.getBlueprint().isUnique() || !Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), Filters.name(self.getBlueprint().getName()))); } + private static boolean containsPhase(Phase[] phases, Phase phase) { + for (Phase phase1 : phases) { + if (phase1 == phase) + return true; + } + return false; + } + + public static boolean canPlayFPCardDuringPhase(LotroGame game, Phase[] phases, PhysicalCard self) { + return (phases == null || containsPhase(phases, game.getGameState().getCurrentPhase())) + && self.getZone() == Zone.HAND + && (!self.getBlueprint().isUnique() || !Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), Filters.name(self.getBlueprint().getName()))); + } + public static boolean canPlayShadowCardDuringPhase(LotroGame game, Phase phase, PhysicalCard self) { return (phase == null || game.getGameState().getCurrentPhase() == phase) && self.getZone() == Zone.HAND && game.getModifiersQuerying().getTwilightCost(game.getGameState(), self) <= game.getGameState().getTwilightPool() && (!self.getBlueprint().isUnique() || !Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), Filters.name(self.getBlueprint().getName()))); } + public static boolean canPlayShadowCardDuringPhase(LotroGame game, Phase[] phases, PhysicalCard self) { + return (phases == null || containsPhase(phases, game.getGameState().getCurrentPhase())) && self.getZone() == Zone.HAND + && game.getModifiersQuerying().getTwilightCost(game.getGameState(), self) <= game.getGameState().getTwilightPool() + && (!self.getBlueprint().isUnique() || !Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), Filters.name(self.getBlueprint().getName()))); + } + public static boolean canUseFPCardDuringPhase(GameState gameState, Phase phase, PhysicalCard self) { return (phase == null || gameState.getCurrentPhase() == phase) && (self.getZone() == Zone.FREE_SUPPORT || self.getZone() == Zone.FREE_CHARACTERS || self.getZone() == Zone.ATTACHED); } diff --git a/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set1/shire/Card1_315.java b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set1/shire/Card1_315.java new file mode 100644 index 000000000..502354d63 --- /dev/null +++ b/gemp-lotr/gemp-lotr-cards/src/main/java/com/gempukku/lotro/cards/set1/shire/Card1_315.java @@ -0,0 +1,50 @@ +package com.gempukku.lotro.cards.set1.shire; + +import com.gempukku.lotro.cards.AbstractEvent; +import com.gempukku.lotro.cards.actions.PlayEventAction; +import com.gempukku.lotro.common.Culture; +import com.gempukku.lotro.common.Keyword; +import com.gempukku.lotro.common.Phase; +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.ChooseActiveCardEffect; +import com.gempukku.lotro.logic.effects.HealCharacterEffect; + +/** + * Set: The Fellowship of the Ring + * Side: Free + * Culture: Shire + * Twilight Cost: 1 + * Type: Event + * Game Text: Maneuver or Skirmish: Heal a Hobbit. + */ +public class Card1_315 extends AbstractEvent { + public Card1_315() { + super(Side.FREE_PEOPLE, Culture.SHIRE, "Stout and Sturdy", Phase.MANEUVER, Phase.SKIRMISH); + } + + @Override + public PlayEventAction getPlayCardAction(String playerId, LotroGame game, PhysicalCard self, int twilightModifier) { + final PlayEventAction action = new PlayEventAction(self); + action.addEffect( + new ChooseActiveCardEffect(playerId, "Choose a Hobbit", Filters.keyword(Keyword.HOBBIT)) { + @Override + protected void cardSelected(PhysicalCard hobbit) { + action.addEffect(new HealCharacterEffect(hobbit)); + } + }); + return action; + } + + @Override + public int getTwilightCost() { + return 1; + } + + @Override + public boolean checkPlayRequirements(String playerId, LotroGame game, PhysicalCard self) { + return true; + } +}