This commit is contained in:
marcins78@gmail.com
2011-11-01 12:30:03 +00:00
parent ef2a285b70
commit e8ddc86754
7 changed files with 107 additions and 2 deletions

View File

@@ -152,10 +152,16 @@ public abstract class AbstractLotroCardBlueprint implements LotroCardBlueprint {
return null;
}
@Override
public List<? extends Action> getPhaseActionsFromStacked(String playerId, LotroGame game, PhysicalCard self) {
return null;
}
@Override
public List<? extends Action> getPhaseActionsFromDiscard(String playerId, LotroGame game, PhysicalCard self) {
return null;
}
@Override
public List<RequiredTriggerAction> getRequiredBeforeTriggers(LotroGame game, Effect effect, PhysicalCard self) {
return null;

View File

@@ -75,6 +75,10 @@ public class PlayConditions {
&& twilightCost <= gameState.getTwilightPool();
}
public static boolean isPhase(LotroGame game, Phase phase) {
return (game.getGameState().getCurrentPhase() == phase);
}
public static boolean canUseStackedFPCardDuringPhase(GameState gameState, Phase phase, PhysicalCard self) {
return (phase == null || gameState.getCurrentPhase() == phase) && self.getZone() == Zone.STACKED;
}

View File

@@ -0,0 +1,45 @@
package com.gempukku.lotro.cards.set7.gollum;
import com.gempukku.lotro.cards.AbstractMinion;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Phase;
import com.gempukku.lotro.common.Side;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.actions.ActivateCardAction;
import com.gempukku.lotro.logic.effects.PlayCardEffect;
import com.gempukku.lotro.logic.timing.Action;
import java.util.Collections;
import java.util.List;
/**
* Set: The Return of the King
* Side: Shadow
* Culture: Gollum
* Twilight Cost: 2
* Type: Minion
* Strength: 5
* Vitality: 4
* Site: 3
* Game Text: If you have initiative during the Shadow phase, you may play this minion from your discard pile.
*/
public class Card7_058 extends AbstractMinion {
public Card7_058() {
super(2, 5, 4, 3, null, Culture.GOLLUM, "Gollum", true);
}
@Override
public List<? extends Action> getPhaseActionsFromDiscard(String playerId, LotroGame game, PhysicalCard self) {
if (PlayConditions.isPhase(game, Phase.SHADOW)
&& PlayConditions.hasInitiative(game, Side.SHADOW)
&& PlayConditions.canPlayFromDiscard(playerId, game, self)) {
ActivateCardAction action = new ActivateCardAction(self);
action.appendEffect(
new PlayCardEffect(self));
return Collections.singletonList(action);
}
return null;
}
}

View File

@@ -56,6 +56,8 @@ public interface LotroCardBlueprint {
public List<? extends Action> getPhaseActionsFromStacked(String playerId, LotroGame game, PhysicalCard self);
public List<? extends Action> getPhaseActionsFromDiscard(String playerId, LotroGame game, PhysicalCard self);
public List<RequiredTriggerAction> getRequiredBeforeTriggers(LotroGame game, Effect effect, PhysicalCard self);
public List<OptionalTriggerAction> getOptionalBeforeTriggers(String playerId, LotroGame game, Effect effect, PhysicalCard self);

View File

@@ -462,8 +462,20 @@ public class GameState {
public boolean iterateStackedActivableCards(String player, PhysicalCardVisitor physicalCardVisitor) {
for (PhysicalCardImpl physicalCard : _stacked.get(player)) {
if (physicalCardVisitor.visitPhysicalCard(physicalCard))
return true;
Side playerSide = player.equals(getCurrentPlayerId()) ? Side.FREE_PEOPLE : Side.SHADOW;
if (physicalCard.getBlueprint().getSide() == playerSide)
if (physicalCardVisitor.visitPhysicalCard(physicalCard))
return true;
}
return false;
}
public boolean iterateDiscardActivableCards(String player, PhysicalCardVisitor physicalCardVisitor) {
for (PhysicalCardImpl physicalCard : _discards.get(player)) {
Side playerSide = player.equals(getCurrentPlayerId()) ? Side.FREE_PEOPLE : Side.SHADOW;
if (physicalCard.getBlueprint().getSide() == playerSide)
if (physicalCardVisitor.visitPhysicalCard(physicalCard))
return true;
}
return false;
}

View File

@@ -11,6 +11,7 @@ import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.ActionStack;
import com.gempukku.lotro.logic.timing.Effect;
import com.gempukku.lotro.logic.timing.EffectResult;
import com.gempukku.lotro.logic.timing.processes.GatherPlayableActionsFromDiscardVisitor;
import com.gempukku.lotro.logic.timing.processes.GatherPlayableActionsFromStackedVisitor;
import com.gempukku.lotro.logic.timing.processes.GatherPlayableActionsVisitor;
import com.gempukku.lotro.logic.timing.rules.CharacterDeathRule;
@@ -204,6 +205,9 @@ public class DefaultActionsEnvironment implements ActionsEnvironment {
GatherPlayableActionsFromStackedVisitor stackedVisitor = new GatherPlayableActionsFromStackedVisitor(_lotroGame, playerId);
_lotroGame.getGameState().iterateStackedActivableCards(playerId, stackedVisitor);
GatherPlayableActionsFromDiscardVisitor discardVisitor = new GatherPlayableActionsFromDiscardVisitor(_lotroGame, playerId);
_lotroGame.getGameState().iterateDiscardActivableCards(playerId, discardVisitor);
List<Action> playableActions = new LinkedList<Action>();
for (Action action : visitor.getActions()) {

View File

@@ -0,0 +1,32 @@
package com.gempukku.lotro.logic.timing.processes;
import com.gempukku.lotro.game.CompletePhysicalCardVisitor;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.timing.Action;
import java.util.LinkedList;
import java.util.List;
public class GatherPlayableActionsFromDiscardVisitor extends CompletePhysicalCardVisitor {
private LotroGame _game;
private String _playerId;
private List<Action> _actions = new LinkedList<Action>();
public GatherPlayableActionsFromDiscardVisitor(LotroGame game, String playerId) {
_game = game;
_playerId = playerId;
}
@Override
protected void doVisitPhysicalCard(PhysicalCard physicalCard) {
List<? extends Action> list = physicalCard.getBlueprint().getPhaseActionsFromDiscard(_playerId, _game, physicalCard);
if (list != null)
_actions.addAll(list);
}
public List<? extends Action> getActions() {
return _actions;
}
}