"Stout and Sturdy"

This commit is contained in:
marcins78@gmail.com
2011-09-06 09:00:10 +00:00
parent ba12a98d60
commit 033401195e
3 changed files with 88 additions and 13 deletions

View File

@@ -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<? extends Action> 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));
}

View File

@@ -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);
}

View File

@@ -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;
}
}