"Borne Far Away"
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
package com.gempukku.lotro.cards.effects.choose;
|
||||
|
||||
import com.gempukku.lotro.common.Filterable;
|
||||
import com.gempukku.lotro.filters.Filter;
|
||||
import com.gempukku.lotro.filters.Filters;
|
||||
import com.gempukku.lotro.game.PhysicalCard;
|
||||
import com.gempukku.lotro.game.state.LotroGame;
|
||||
import com.gempukku.lotro.logic.decisions.ArbitraryCardsSelectionDecision;
|
||||
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
|
||||
import com.gempukku.lotro.logic.timing.AbstractEffect;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public abstract class ChooseCardsFromDeadPileEffect extends AbstractEffect {
|
||||
private String _playerId;
|
||||
private int _minimum;
|
||||
private int _maximum;
|
||||
private Filter _filter;
|
||||
|
||||
public ChooseCardsFromDeadPileEffect(String playerId, int minimum, int maximum, Filterable... filters) {
|
||||
_playerId = playerId;
|
||||
_minimum = minimum;
|
||||
_maximum = maximum;
|
||||
_filter = Filters.and(filters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(LotroGame game) {
|
||||
return "Choose card from dead pile";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayableInFull(LotroGame game) {
|
||||
Collection<PhysicalCard> cards = Filters.filter(game.getGameState().getDeadPile(_playerId), game.getGameState(), game.getModifiersQuerying(), _filter);
|
||||
return cards.size() >= _minimum;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FullEffectResult playEffectReturningResult(final LotroGame game) {
|
||||
Collection<PhysicalCard> cards = Filters.filter(game.getGameState().getDeadPile(_playerId), game.getGameState(), game.getModifiersQuerying(), _filter);
|
||||
|
||||
boolean success = cards.size() >= _minimum;
|
||||
|
||||
int minimum = Math.min(_minimum, cards.size());
|
||||
|
||||
if (_maximum == 0) {
|
||||
cardsSelected(game, Collections.<PhysicalCard>emptySet());
|
||||
} else if (cards.size() == minimum) {
|
||||
cardsSelected(game, cards);
|
||||
} else {
|
||||
game.getUserFeedback().sendAwaitingDecision(_playerId,
|
||||
new ArbitraryCardsSelectionDecision(1, "Choose card from dead pile", new LinkedList<PhysicalCard>(cards), minimum, _maximum) {
|
||||
@Override
|
||||
public void decisionMade(String result) throws DecisionResultInvalidException {
|
||||
cardsSelected(game, getSelectedCardsByResponse(result));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return new FullEffectResult(null, success, success);
|
||||
}
|
||||
|
||||
protected abstract void cardsSelected(LotroGame game, Collection<PhysicalCard> cards);
|
||||
}
|
||||
@@ -29,7 +29,7 @@ public abstract class ChooseCardsFromDiscardEffect extends AbstractEffect {
|
||||
|
||||
@Override
|
||||
public String getText(LotroGame game) {
|
||||
return null;
|
||||
return "Choose card from discard";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.gempukku.lotro.cards.set10.gandalf;
|
||||
|
||||
import com.gempukku.lotro.cards.AbstractEvent;
|
||||
import com.gempukku.lotro.cards.PlayConditions;
|
||||
import com.gempukku.lotro.cards.actions.PlayEventAction;
|
||||
import com.gempukku.lotro.cards.effects.ChoiceEffect;
|
||||
import com.gempukku.lotro.cards.effects.choose.ChooseCardsFromDeadPileEffect;
|
||||
import com.gempukku.lotro.cards.effects.choose.ChooseCardsFromDiscardEffect;
|
||||
import com.gempukku.lotro.cards.effects.choose.ChooseCardsFromHandEffect;
|
||||
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.GameUtils;
|
||||
import com.gempukku.lotro.logic.timing.Effect;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Set: Mount Doom
|
||||
* Side: Free
|
||||
* Culture: Gandalf
|
||||
* Twilight Cost: 1
|
||||
* Type: Event • Fellowship
|
||||
* Game Text: Spot your Wizard to exchange a companion in hand with a companion in your dead pile or discard pile.
|
||||
*/
|
||||
public class Card10_014 extends AbstractEvent {
|
||||
public Card10_014() {
|
||||
super(Side.FREE_PEOPLE, 1, Culture.GANDALF, "Borne Far Away", Phase.FELLOWSHIP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkPlayRequirements(String playerId, LotroGame game, PhysicalCard self, int twilightModifier, boolean ignoreRoamingPenalty) {
|
||||
return super.checkPlayRequirements(playerId, game, self, twilightModifier, ignoreRoamingPenalty)
|
||||
&& PlayConditions.canSpot(game, Filters.owner(playerId), Race.WIZARD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayEventAction getPlayCardAction(final String playerId, LotroGame game, final PhysicalCard self, int twilightModifier, boolean ignoreRoamingPenalty) {
|
||||
final PlayEventAction action = new PlayEventAction(self);
|
||||
action.appendEffect(
|
||||
new ChooseCardsFromHandEffect(playerId, 1, 1, CardType.COMPANION) {
|
||||
@Override
|
||||
protected void cardsSelected(LotroGame game, Collection<PhysicalCard> selectedCards) {
|
||||
for (final PhysicalCard cardInHand : selectedCards) {
|
||||
List<Effect> possibleEffects = new LinkedList<Effect>();
|
||||
possibleEffects.add(
|
||||
new ChooseCardsFromDiscardEffect(playerId, 1, 1, CardType.COMPANION) {
|
||||
@Override
|
||||
protected void cardsSelected(LotroGame game, Collection<PhysicalCard> cards) {
|
||||
for (PhysicalCard cardInDiscard : cards) {
|
||||
Set<PhysicalCard> cardsToRemove = new HashSet<PhysicalCard>();
|
||||
cardsToRemove.add(cardInHand);
|
||||
cardsToRemove.add(cardInDiscard);
|
||||
|
||||
game.getGameState().sendMessage(playerId + " exchanges " + GameUtils.getCardLink(cardInDiscard) + " from discard with " + GameUtils.getCardLink(cardInHand) + " in hand");
|
||||
game.getGameState().removeCardsFromZone(playerId, cardsToRemove);
|
||||
game.getGameState().addCardToZone(game, cardInDiscard, Zone.HAND);
|
||||
game.getGameState().addCardToZone(game, cardInHand, Zone.DISCARD);
|
||||
}
|
||||
}
|
||||
});
|
||||
possibleEffects.add(
|
||||
new ChooseCardsFromDeadPileEffect(playerId, 1, 1, CardType.COMPANION) {
|
||||
@Override
|
||||
protected void cardsSelected(LotroGame game, Collection<PhysicalCard> cards) {
|
||||
for (PhysicalCard cardInDeadPile : cards) {
|
||||
Set<PhysicalCard> cardsToRemove = new HashSet<PhysicalCard>();
|
||||
cardsToRemove.add(cardInHand);
|
||||
cardsToRemove.add(cardInDeadPile);
|
||||
|
||||
game.getGameState().sendMessage(playerId + " exchanges " + GameUtils.getCardLink(cardInDeadPile) + " from dead pile with " + GameUtils.getCardLink(cardInHand) + " in hand");
|
||||
game.getGameState().removeCardsFromZone(playerId, cardsToRemove);
|
||||
game.getGameState().addCardToZone(game, cardInDeadPile, Zone.HAND);
|
||||
game.getGameState().addCardToZone(game, cardInHand, Zone.DEAD);
|
||||
}
|
||||
}
|
||||
});
|
||||
action.appendEffect(
|
||||
new ChoiceEffect(action, playerId, possibleEffects));
|
||||
}
|
||||
}
|
||||
});
|
||||
return action;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user