"Discoveries"
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package com.gempukku.lotro.cards.effects;
|
||||
|
||||
import com.gempukku.lotro.common.Zone;
|
||||
import com.gempukku.lotro.game.PhysicalCard;
|
||||
import com.gempukku.lotro.game.state.GameState;
|
||||
import com.gempukku.lotro.game.state.LotroGame;
|
||||
import com.gempukku.lotro.logic.GameUtils;
|
||||
import com.gempukku.lotro.logic.timing.AbstractEffect;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public class PutCardFromDeckOnTopOfDeckEffect extends AbstractEffect {
|
||||
private PhysicalCard _source;
|
||||
private PhysicalCard _physicalCard;
|
||||
|
||||
public PutCardFromDeckOnTopOfDeckEffect(PhysicalCard source, PhysicalCard physicalCard) {
|
||||
_physicalCard = physicalCard;
|
||||
_source = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayableInFull(LotroGame game) {
|
||||
return _physicalCard.getZone() == Zone.DECK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(LotroGame game) {
|
||||
return "Put " + GameUtils.getCardLink(_physicalCard) + " on the top of draw deck";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FullEffectResult playEffectReturningResult(LotroGame game) {
|
||||
if (isPlayableInFull(game)) {
|
||||
GameState gameState = game.getGameState();
|
||||
gameState.removeCardsFromZone(_source.getOwner(), Collections.singleton(_physicalCard));
|
||||
gameState.putCardOnTopOfDeck(_physicalCard);
|
||||
return new FullEffectResult(true, true);
|
||||
}
|
||||
return new FullEffectResult(false, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.gempukku.lotro.cards.effects;
|
||||
|
||||
import com.gempukku.lotro.game.PhysicalCard;
|
||||
import com.gempukku.lotro.game.state.LotroGame;
|
||||
import com.gempukku.lotro.logic.actions.SubAction;
|
||||
import com.gempukku.lotro.logic.effects.ChooseArbitraryCardsEffect;
|
||||
import com.gempukku.lotro.logic.timing.AbstractSubActionEffect;
|
||||
import com.gempukku.lotro.logic.timing.Action;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ReorderTopCardsOfDeckEffect extends AbstractSubActionEffect {
|
||||
private Action _action;
|
||||
private String _playerId;
|
||||
private int _count;
|
||||
|
||||
public ReorderTopCardsOfDeckEffect(Action action, String playerId, int count) {
|
||||
_action = action;
|
||||
_playerId = playerId;
|
||||
_count = count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText(LotroGame game) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayableInFull(LotroGame game) {
|
||||
return game.getGameState().getDeck(_playerId).size() >= _count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playEffect(LotroGame game) {
|
||||
final List<? extends PhysicalCard> deck = game.getGameState().getDeck(_playerId);
|
||||
int count = Math.min(deck.size(), _count);
|
||||
Set<PhysicalCard> cards = new HashSet<PhysicalCard>(deck.subList(0, count));
|
||||
|
||||
game.getGameState().sendMessage(_playerId + " reorders top " + count + " cards of draw deck");
|
||||
|
||||
SubAction subAction = new SubAction(_action);
|
||||
subAction.appendEffect(
|
||||
new ChooseAndPutNextCardFromDeckOnTopOfDeck(subAction, cards));
|
||||
processSubAction(game, subAction);
|
||||
}
|
||||
|
||||
private class ChooseAndPutNextCardFromDeckOnTopOfDeck extends ChooseArbitraryCardsEffect {
|
||||
private Collection<PhysicalCard> _remainingCards;
|
||||
private SubAction _subAction;
|
||||
|
||||
public ChooseAndPutNextCardFromDeckOnTopOfDeck(SubAction subAction, Collection<PhysicalCard> remainingCards) {
|
||||
super(_playerId, "Choose a card to put on top of your deck", remainingCards, 1, 1);
|
||||
_subAction = subAction;
|
||||
_remainingCards = remainingCards;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cardsSelected(LotroGame game, Collection<PhysicalCard> selectedCards) {
|
||||
for (PhysicalCard selectedCard : selectedCards) {
|
||||
_subAction.appendEffect(
|
||||
new PutCardFromDeckOnTopOfDeckEffect(_action.getActionSource(), selectedCard));
|
||||
_remainingCards.remove(selectedCard);
|
||||
if (_remainingCards.size() > 0)
|
||||
_subAction.appendEffect(
|
||||
new ChooseAndPutNextCardFromDeckOnTopOfDeck(_subAction, _remainingCards));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.gempukku.lotro.cards.set12.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.ForEachYouSpotEffect;
|
||||
import com.gempukku.lotro.cards.effects.ReorderTopCardsOfDeckEffect;
|
||||
import com.gempukku.lotro.common.*;
|
||||
import com.gempukku.lotro.filters.Filters;
|
||||
import com.gempukku.lotro.game.PhysicalCard;
|
||||
import com.gempukku.lotro.game.state.LotroGame;
|
||||
|
||||
/**
|
||||
* Set: Black Rider
|
||||
* Side: Free
|
||||
* Culture: Gandalf
|
||||
* Twilight Cost: 7
|
||||
* Type: Event • Fellowship
|
||||
* Game Text: Toil 3. (For each [GANDALF] character you exert when playing this, its twilight cost is -3)
|
||||
* Spot a [GANDALF] wizard and X other companions to examine the top X cards of your draw deck. Replace those cards
|
||||
* in any order.
|
||||
*/
|
||||
public class Card12_026 extends AbstractEvent {
|
||||
public Card12_026() {
|
||||
super(Side.FREE_PEOPLE, 7, Culture.GANDALF, "Discoveries", Phase.FELLOWSHIP);
|
||||
addKeyword(Keyword.TOIL, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkPlayRequirements(String playerId, LotroGame game, PhysicalCard self, int withTwilightRemoved, int twilightModifier, boolean ignoreRoamingPenalty, boolean ignoreCheckingDeadPile) {
|
||||
return super.checkPlayRequirements(playerId, game, self, withTwilightRemoved, twilightModifier, ignoreRoamingPenalty, ignoreCheckingDeadPile)
|
||||
&& PlayConditions.canSpot(game, Culture.GANDALF, Race.WIZARD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayEventAction getPlayCardAction(final String playerId, LotroGame game, PhysicalCard self, int twilightModifier, boolean ignoreRoamingPenalty) {
|
||||
final PlayEventAction action = new PlayEventAction(self);
|
||||
action.appendEffect(
|
||||
new ForEachYouSpotEffect(playerId, CardType.COMPANION, Filters.not(Culture.GANDALF, Race.WIZARD)) {
|
||||
@Override
|
||||
protected void spottedCards(int spotCount) {
|
||||
action.appendEffect(
|
||||
new ReorderTopCardsOfDeckEffect(action playerId, spotCount));
|
||||
}
|
||||
});
|
||||
return action;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user