"Gandalf's Cart"
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package com.gempukku.lotro.cards.effects;
|
||||
|
||||
import com.gempukku.lotro.game.PhysicalCard;
|
||||
import com.gempukku.lotro.game.state.LotroGame;
|
||||
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
|
||||
|
||||
public class StackCardFromHandEffect extends UnrespondableEffect {
|
||||
private PhysicalCard _card;
|
||||
private PhysicalCard _stackOn;
|
||||
|
||||
public StackCardFromHandEffect(PhysicalCard card, PhysicalCard stackOn) {
|
||||
_card = card;
|
||||
_stackOn = stackOn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playEffect(LotroGame game) {
|
||||
game.getGameState().removeCardFromZone(_card);
|
||||
game.getGameState().stackCard(_card, _stackOn);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.gempukku.lotro.cards.set1.gandalf;
|
||||
|
||||
import com.gempukku.lotro.cards.AbstractLotroCardBlueprint;
|
||||
import com.gempukku.lotro.cards.PlayConditions;
|
||||
import com.gempukku.lotro.cards.actions.PlayPermanentAction;
|
||||
import com.gempukku.lotro.cards.effects.ChoiceEffect;
|
||||
import com.gempukku.lotro.cards.effects.StackCardFromHandEffect;
|
||||
import com.gempukku.lotro.common.*;
|
||||
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.DefaultCostToEffectAction;
|
||||
import com.gempukku.lotro.logic.effects.ChooseArbitraryCardsEffect;
|
||||
import com.gempukku.lotro.logic.effects.ChooseCardsFromHandEffect;
|
||||
import com.gempukku.lotro.logic.timing.Action;
|
||||
import com.gempukku.lotro.logic.timing.Effect;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Set: The Fellowship of the Ring
|
||||
* Side: Free
|
||||
* Culture: Gandalf
|
||||
* Twilight Cost: 1
|
||||
* Type: Possession
|
||||
* Game Text: Plays to your support area. Fellowship: Stack a Free Peoples artifact (or possession) from hand on this
|
||||
* card, or play a card stacked here as if played from hand.
|
||||
*/
|
||||
public class Card1_073 extends AbstractLotroCardBlueprint {
|
||||
public Card1_073() {
|
||||
super(Side.FREE_PEOPLE, CardType.POSSESSION, Culture.GANDALF, "Gandalf's Cart", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkPlayRequirements(String playerId, LotroGame game, PhysicalCard self) {
|
||||
return PlayConditions.checkUniqueness(game.getGameState(), game.getModifiersQuerying(), self);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTwilightCost() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Action getPlayCardAction(String playerId, LotroGame game, PhysicalCard self, int twilightModifier) {
|
||||
return new PlayPermanentAction(self, Zone.FREE_SUPPORT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Action> getPhaseActions(final String playerId, final LotroGame game, final PhysicalCard self) {
|
||||
if (PlayConditions.canPlayFPCardDuringPhase(game, Phase.FELLOWSHIP, self)
|
||||
&& checkPlayRequirements(playerId, game, self)) {
|
||||
return Collections.singletonList(getPlayCardAction(playerId, game, self, 0));
|
||||
}
|
||||
|
||||
if (PlayConditions.canUseFPCardDuringPhase(game.getGameState(), Phase.FELLOWSHIP, self)
|
||||
&& (
|
||||
game.getGameState().getStackedCards(self).size() > 0
|
||||
|| Filters.filter(game.getGameState().getHand(playerId), game.getGameState(), game.getModifiersQuerying(), Filters.side(Side.FREE_PEOPLE), Filters.or(Filters.type(CardType.ARTIFACT), Filters.type(CardType.POSSESSION))).size() > 0)) {
|
||||
final DefaultCostToEffectAction action = new DefaultCostToEffectAction(self, Keyword.FELLOWSHIP, "Stack a Free Peoples artifact (or possession) from hand on this card, or play a card stacked here as if played from hand.");
|
||||
|
||||
List<Effect> possibleChoices = new LinkedList<Effect>();
|
||||
possibleChoices.add(
|
||||
new ChooseCardsFromHandEffect(playerId, "Choose Free Peoples artifact or possession", 1, 1, Filters.side(Side.FREE_PEOPLE), Filters.or(Filters.type(CardType.ARTIFACT), Filters.type(CardType.POSSESSION))) {
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Stack a Free Peoples artifact or possession";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cardsSelected(List<PhysicalCard> selectedCards) {
|
||||
action.addEffect(new StackCardFromHandEffect(selectedCards.get(0), self));
|
||||
}
|
||||
});
|
||||
possibleChoices.add(
|
||||
new ChooseArbitraryCardsEffect(playerId, "Choose artifact or possession to play", game.getGameState().getStackedCards(self), Filters.playable(game), 1, 1) {
|
||||
@Override
|
||||
protected void cardsSelected(List<PhysicalCard> selectedCards) {
|
||||
PhysicalCard selectedCard = selectedCards.get(0);
|
||||
game.getActionsEnvironment().addActionToStack(selectedCard.getBlueprint().getPlayCardAction(playerId, game, selectedCard, 0));
|
||||
}
|
||||
});
|
||||
|
||||
action.addCost(
|
||||
new ChoiceEffect(action, playerId, possibleChoices, false));
|
||||
|
||||
return Collections.singletonList(action);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,6 @@ package com.gempukku.lotro.common;
|
||||
public enum Zone {
|
||||
FREE_CHARACTERS, FREE_SUPPORT, SHADOW_CHARACTERS, SHADOW_SUPPORT,
|
||||
ADVENTURE_PATH,
|
||||
HAND, DECK, ATTACHED,
|
||||
HAND, DECK, ATTACHED, STACKED,
|
||||
DISCARD, DEAD
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ public interface PhysicalCard {
|
||||
|
||||
public PhysicalCard getAttachedTo();
|
||||
|
||||
public PhysicalCard getStackedOn();
|
||||
|
||||
public void storeData(Object object);
|
||||
|
||||
public Object getData();
|
||||
|
||||
@@ -13,6 +13,7 @@ public class PhysicalCardImpl implements PhysicalCard {
|
||||
private LotroCardBlueprint _blueprint;
|
||||
|
||||
private PhysicalCardImpl _attachedTo;
|
||||
private PhysicalCardImpl _stackedOn;
|
||||
|
||||
private ModifierHook _modifierHook;
|
||||
|
||||
@@ -77,6 +78,15 @@ public class PhysicalCardImpl implements PhysicalCard {
|
||||
return _attachedTo;
|
||||
}
|
||||
|
||||
public void stackOn(PhysicalCardImpl physicalCard) {
|
||||
_stackedOn = physicalCard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PhysicalCard getStackedOn() {
|
||||
return _stackedOn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void storeData(Object object) {
|
||||
_data = object;
|
||||
|
||||
@@ -16,6 +16,7 @@ public class GameState {
|
||||
private Map<String, List<PhysicalCardImpl>> _hands = new HashMap<String, List<PhysicalCardImpl>>();
|
||||
private Map<String, List<PhysicalCardImpl>> _discards = new HashMap<String, List<PhysicalCardImpl>>();
|
||||
private Map<String, List<PhysicalCardImpl>> _deadPiles = new HashMap<String, List<PhysicalCardImpl>>();
|
||||
private Map<String, List<PhysicalCardImpl>> _stacked = new HashMap<String, List<PhysicalCardImpl>>();
|
||||
|
||||
private Map<String, List<PhysicalCardImpl>> _inPlay = new HashMap<String, List<PhysicalCardImpl>>();
|
||||
|
||||
@@ -155,7 +156,7 @@ public class GameState {
|
||||
|
||||
private boolean isZonePublic(Zone zone) {
|
||||
return zone == Zone.FREE_CHARACTERS || zone == Zone.FREE_SUPPORT || zone == Zone.SHADOW_CHARACTERS || zone == Zone.SHADOW_SUPPORT
|
||||
|| zone == Zone.ADVENTURE_PATH || zone == Zone.ATTACHED || zone == Zone.DEAD;
|
||||
|| zone == Zone.ADVENTURE_PATH || zone == Zone.ATTACHED || zone == Zone.STACKED || zone == Zone.DEAD;
|
||||
}
|
||||
|
||||
private boolean isZonePrivate(Zone zone) {
|
||||
@@ -171,6 +172,11 @@ public class GameState {
|
||||
addCardToZone(card, Zone.ATTACHED);
|
||||
}
|
||||
|
||||
public void stackCard(PhysicalCard card, PhysicalCard stackOn) {
|
||||
((PhysicalCardImpl) card).stackOn((PhysicalCardImpl) stackOn);
|
||||
addCardToZone(card, Zone.STACKED);
|
||||
}
|
||||
|
||||
public void setRingBearer(PhysicalCard card) {
|
||||
_ringBearers.put(card.getOwner(), card);
|
||||
}
|
||||
@@ -390,6 +396,17 @@ public class GameState {
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<PhysicalCard> getStackedCards(PhysicalCard card) {
|
||||
List<PhysicalCard> result = new LinkedList<PhysicalCard>();
|
||||
for (List<PhysicalCardImpl> physicalCardList : _stacked.values()) {
|
||||
for (PhysicalCardImpl physicalCard : physicalCardList) {
|
||||
if (physicalCard.getStackedOn() == card)
|
||||
result.add(physicalCard);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int getWounds(PhysicalCard physicalCard) {
|
||||
return getTokenCount(physicalCard, Token.WOUND);
|
||||
}
|
||||
|
||||
@@ -40,6 +40,12 @@ public class DiscardCardsFromPlayEffect extends UnrespondableEffect {
|
||||
gameState.removeCardFromZone(attachedCard);
|
||||
gameState.addCardToZone(attachedCard, Zone.DISCARD);
|
||||
}
|
||||
|
||||
List<PhysicalCard> stackedCards = gameState.getStackedCards(card);
|
||||
for (PhysicalCard stackedCard : stackedCards) {
|
||||
gameState.removeCardFromZone(stackedCard);
|
||||
gameState.addCardToZone(stackedCard, Zone.DISCARD);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,6 +116,9 @@ public class GameEvent {
|
||||
PhysicalCard attachedTo = physicalCard.getAttachedTo();
|
||||
if (attachedTo != null)
|
||||
gameEvent = gameEvent.targetCardId(attachedTo.getCardId());
|
||||
PhysicalCard stackedOn = physicalCard.getStackedOn();
|
||||
if (stackedOn != null)
|
||||
gameEvent = gameEvent.targetCardId(stackedOn.getCardId());
|
||||
if (physicalCard.getBlueprint().getCardType() == CardType.SITE)
|
||||
gameEvent = gameEvent.index(physicalCard.getBlueprint().getSiteNumber());
|
||||
return gameEvent;
|
||||
|
||||
Reference in New Issue
Block a user