"Dunlending Looter"

Activating cards stacked on other cards.
This commit is contained in:
marcins78@gmail.com
2011-10-05 15:41:37 +00:00
parent dfcf30da39
commit e76e435173
11 changed files with 137 additions and 7 deletions

View File

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

View File

@@ -133,6 +133,10 @@ public class PlayConditions {
return canExert(source, gameState, modifiersQuerying, Filters.sameCard(card));
}
public static boolean controllsSite(GameState gameState, ModifiersQuerying modifiersQuerying, String playerId) {
return Filters.findFirstActive(gameState, modifiersQuerying, Filters.siteControlled(playerId)) != null;
}
public static boolean winsSkirmish(EffectResult effectResult, PhysicalCard character) {
EffectResult.Type effectType = effectResult.getType();
if (effectType == EffectResult.Type.RESOLVE_SKIRMISH || effectType == EffectResult.Type.OVERWHELM_IN_SKIRMISH) {

View File

@@ -0,0 +1,62 @@
package com.gempukku.lotro.cards.set4.dunland;
import com.gempukku.lotro.cards.AbstractMinion;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.effects.StackCardFromPlayEffect;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Race;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import com.gempukku.lotro.logic.actions.OptionalTriggerAction;
import com.gempukku.lotro.logic.effects.ChooseActiveCardEffect;
import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.EffectResult;
import java.util.Collections;
import java.util.List;
/**
* Set: The Two Towers
* Side: Shadow
* Culture: Dunland
* Twilight Cost: 3
* Type: Minion • Man
* Strength: 9
* Vitality: 1
* Site: 3
* Game Text: When this minion wins a skirmish, you may stack him on a site you control. Shadow: If stacked on a site
* you control, play this minion. His twilight cost is -2.
*/
public class Card4_011 extends AbstractMinion {
public Card4_011() {
super(3, 9, 1, 3, Race.MAN, Culture.DUNLAND, "Dunlending Looter");
}
@Override
public List<OptionalTriggerAction> getOptionalAfterTriggers(String playerId, LotroGame game, EffectResult effectResult, final PhysicalCard self) {
if (PlayConditions.winsSkirmish(effectResult, self)
&& PlayConditions.controllsSite(game.getGameState(), game.getModifiersQuerying(), playerId)) {
final OptionalTriggerAction action = new OptionalTriggerAction(self);
action.appendEffect(
new ChooseActiveCardEffect(self, playerId, "Choose site you control", Filters.siteControlled(playerId)) {
@Override
protected void cardSelected(PhysicalCard card) {
action.insertEffect(
new StackCardFromPlayEffect(self, card));
}
});
return Collections.singletonList(action);
}
return null;
}
@Override
public List<? extends Action> getPhaseActionsFromStacked(String playerId, LotroGame game, PhysicalCard self) {
if (playerId.equals(self.getStackedOn().getSiteController())
&& checkPlayRequirements(playerId, game, self, -2)) {
return Collections.singletonList(getPlayCardAction(playerId, game, self, -2));
}
return null;
}
}

View File

@@ -363,7 +363,7 @@ public class Filters {
return new Filter() {
@Override
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
return physicalCard.getBlueprint().getCardType() == CardType.SITE && playerId.equals(physicalCard.getController());
return physicalCard.getBlueprint().getCardType() == CardType.SITE && playerId.equals(physicalCard.getSiteController());
}
};
}

View File

@@ -46,6 +46,8 @@ public interface LotroCardBlueprint {
public List<? extends Action> getPhaseActions(String playerId, LotroGame game, PhysicalCard self);
public List<? extends Action> getPhaseActionsFromStacked(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

@@ -9,7 +9,7 @@ public interface PhysicalCard {
public String getOwner();
public String getController();
public String getSiteController();
public int getCardId();

View File

@@ -12,7 +12,7 @@ public class PhysicalCardImpl implements PhysicalCard {
private int _cardId;
private String _blueprintId;
private String _owner;
private String _controller;
private String _siteController;
private Zone _zone;
private LotroCardBlueprint _blueprint;
@@ -50,13 +50,13 @@ public class PhysicalCardImpl implements PhysicalCard {
return _owner;
}
public void setController(String controller) {
_controller = controller;
public void setSiteController(String siteController) {
_siteController = siteController;
}
@Override
public String getController() {
return _controller;
public String getSiteController() {
return _siteController;
}
public void startAffectingGame(ModifiersEnvironment modifiersEnvironment) {

View File

@@ -378,6 +378,14 @@ public class GameState {
return false;
}
public boolean iterateStackedActivableCards(String player, PhysicalCardVisitor physicalCardVisitor) {
for (PhysicalCardImpl physicalCard : _stacked.get(player)) {
if (physicalCardVisitor.visitPhysicalCard(physicalCard))
return true;
}
return false;
}
public boolean iterateActiveCards(String player, PhysicalCardVisitor physicalCardVisitor) {
for (int i = 1; i <= 9; i++) {
PhysicalCard site = getSite(i);

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 GatherPlayableActionsFromStackedVisitor extends CompletePhysicalCardVisitor {
private LotroGame _game;
private String _playerId;
private List<Action> _actions = new LinkedList<Action>();
public GatherPlayableActionsFromStackedVisitor(LotroGame game, String playerId) {
_game = game;
_playerId = playerId;
}
@Override
protected void doVisitPhysicalCard(PhysicalCard physicalCard) {
List<? extends Action> list = physicalCard.getBlueprint().getPhaseActionsFromStacked(_playerId, _game, physicalCard);
if (list != null)
_actions.addAll(list);
}
public List<? extends Action> getActions() {
return _actions;
}
}

View File

@@ -5,6 +5,7 @@ import com.gempukku.lotro.logic.decisions.CardActionSelectionDecision;
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.processes.GameProcess;
import com.gempukku.lotro.logic.timing.processes.GatherPlayableActionsFromStackedVisitor;
import com.gempukku.lotro.logic.timing.processes.GatherPlayableActionsVisitor;
import java.util.LinkedList;
@@ -28,11 +29,19 @@ public class PlayerPlaysPhaseActionsUntilPassesGameProcess implements GameProces
GatherPlayableActionsVisitor visitor = new GatherPlayableActionsVisitor(_game, _playerId);
_game.getGameState().iterateActivableCards(_playerId, visitor);
GatherPlayableActionsFromStackedVisitor stackedVisitor = new GatherPlayableActionsFromStackedVisitor(_game, _playerId);
_game.getGameState().iterateStackedActivableCards(_playerId, stackedVisitor);
List<Action> playableActions = new LinkedList<Action>();
for (Action action : visitor.getActions())
if (_game.getModifiersQuerying().canPlayAction(_game.getGameState(), action))
playableActions.add(action);
for (Action action : stackedVisitor.getActions())
if (_game.getModifiersQuerying().canPlayAction(_game.getGameState(), action))
playableActions.add(action);
_game.getUserFeedback().sendAwaitingDecision(_playerId,
new CardActionSelectionDecision(_game, 1, "Choose action to play or Pass", playableActions, true) {
@Override

View File

@@ -8,6 +8,7 @@ import com.gempukku.lotro.logic.decisions.CardActionSelectionDecision;
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.processes.GameProcess;
import com.gempukku.lotro.logic.timing.processes.GatherPlayableActionsFromStackedVisitor;
import com.gempukku.lotro.logic.timing.processes.GatherPlayableActionsVisitor;
import java.util.LinkedList;
@@ -38,9 +39,13 @@ public class PlayersPlayPhaseActionsInOrderGameProcess implements GameProcess {
_nextProcess = _followingGameProcess;
} else {
String playerId = _playOrder.getNextPlayer();
GatherPlayableActionsVisitor visitor = new GatherPlayableActionsVisitor(_game, playerId);
_game.getGameState().iterateActivableCards(playerId, visitor);
GatherPlayableActionsFromStackedVisitor stackedVisitor = new GatherPlayableActionsFromStackedVisitor(_game, playerId);
_game.getGameState().iterateStackedActivableCards(playerId, stackedVisitor);
List<? extends Action> actions = visitor.getActions();
List<Action> playableActions = new LinkedList<Action>();
@@ -48,6 +53,10 @@ public class PlayersPlayPhaseActionsInOrderGameProcess implements GameProcess {
if (_game.getModifiersQuerying().canPlayAction(_game.getGameState(), action))
playableActions.add(action);
for (Action action : stackedVisitor.getActions())
if (_game.getModifiersQuerying().canPlayAction(_game.getGameState(), action))
playableActions.add(action);
_game.getUserFeedback().sendAwaitingDecision(playerId,
new CardActionSelectionDecision(_game, 1, "Choose action to play or Pass", playableActions, true) {
@Override