"Denethor"

This commit is contained in:
marcins78@gmail.com
2011-11-16 15:34:20 +00:00
parent 591d3b50d9
commit 7bcd7b5a1f
4 changed files with 217 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
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 com.gempukku.lotro.logic.timing.results.DrawCardOrPutIntoHandResult;
import java.util.Collections;
public class PutCardFromDeckIntoHandEffect extends AbstractEffect {
private PhysicalCard _card;
public PutCardFromDeckIntoHandEffect(PhysicalCard card) {
_card = card;
}
@Override
public String getText(LotroGame game) {
return "Put card from deck into hand";
}
@Override
public Type getType() {
return null;
}
@Override
public boolean isPlayableInFull(LotroGame game) {
return _card.getZone() == Zone.DECK;
}
@Override
protected FullEffectResult playEffectReturningResult(LotroGame game) {
if (game.getModifiersQuerying().canDrawCardAndIncrement(game.getGameState(), _card.getOwner())
&& _card.getZone() == Zone.DECK) {
GameState gameState = game.getGameState();
gameState.sendMessage(_card.getOwner() + " puts " + GameUtils.getCardLink(_card) + " from deck into his or her hand");
gameState.removeCardsFromZone(_card.getOwner(), Collections.singleton(_card));
gameState.addCardToZone(game, _card, Zone.HAND);
return new FullEffectResult(Collections.singleton(new DrawCardOrPutIntoHandResult(_card.getOwner(), 1)), true, true);
}
return new FullEffectResult(null, false, false);
}
}

View File

@@ -0,0 +1,29 @@
package com.gempukku.lotro.cards.effects.choose;
import com.gempukku.lotro.cards.effects.PutCardFromDeckIntoHandEffect;
import com.gempukku.lotro.common.Filterable;
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.timing.Action;
import java.util.Collection;
public class ChooseAndPutCardFromDeckIntoHandEffect extends ChooseCardsFromDeckEffect {
private Action _action;
public ChooseAndPutCardFromDeckIntoHandEffect(Action action, String playerId, int minimum, int maximum, Filterable... filters) {
super(playerId, minimum, maximum, filters);
_action = action;
}
@Override
protected void cardsSelected(LotroGame game, Collection<PhysicalCard> cards) {
if (cards.size() > 0) {
SubAction subAction = new SubAction(_action);
for (PhysicalCard card : cards)
subAction.appendEffect(new PutCardFromDeckIntoHandEffect(card));
game.getActionsEnvironment().addActionToStack(subAction);
}
}
}

View File

@@ -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 ChooseCardsFromDeckEffect extends AbstractEffect {
private String _playerId;
private int _minimum;
private int _maximum;
private Filter _filter;
public ChooseCardsFromDeckEffect(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 deck";
}
@Override
public Type getType() {
return null;
}
@Override
public boolean isPlayableInFull(LotroGame game) {
Collection<PhysicalCard> cards = Filters.filter(game.getGameState().getDeck(_playerId), game.getGameState(), game.getModifiersQuerying(), _filter);
return cards.size() >= _minimum;
}
@Override
protected FullEffectResult playEffectReturningResult(final LotroGame game) {
Collection<PhysicalCard> cards = Filters.filter(game.getGameState().getDeck(_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 deck", 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);
}

View File

@@ -0,0 +1,69 @@
package com.gempukku.lotro.cards.set10.gondor;
import com.gempukku.lotro.cards.AbstractCompanion;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.effects.ExertCharactersEffect;
import com.gempukku.lotro.cards.effects.OptionalEffect;
import com.gempukku.lotro.cards.effects.ShuffleDeckEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseAndPutCardFromDeckIntoHandEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseOpponentEffect;
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.ActivateCardAction;
import com.gempukku.lotro.logic.effects.DrawCardEffect;
import java.util.Collections;
import java.util.List;
/**
* Set: Mount Doom
* Side: Free
* Culture: Gondor
* Twilight Cost: 2
* Type: Companion • Man
* Strength: 8
* Vitality: 3
* Resistance: 6
* Signet: Aragorn
* Game Text: To play, spot 2 [GONDOR] Men. Fellowship: If at a sanctuary, exert Denethor to take a [GONDOR] card into
* hand from your draw deck, then reshuffle. Choose an opponent who may draw 2 cards.
*/
public class Card10_028 extends AbstractCompanion {
public Card10_028() {
super(2, 8, 3, Culture.GONDOR, Race.MAN, Signet.ARAGORN, "Denethor", true);
}
@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, 2, Culture.GONDOR, Race.MAN);
}
@Override
protected List<ActivateCardAction> getExtraInPlayPhaseActions(String playerId, LotroGame game, PhysicalCard self) {
if (PlayConditions.canUseFPCardDuringPhase(game, Phase.FELLOWSHIP, self)
&& Filters.keyword(Keyword.SANCTUARY).accepts(game.getGameState(), game.getModifiersQuerying(), game.getGameState().getCurrentSite())
&& PlayConditions.canSelfExert(self, game)) {
final ActivateCardAction action = new ActivateCardAction(self);
action.appendCost(
new ExertCharactersEffect(self, self));
action.appendEffect(
new ChooseAndPutCardFromDeckIntoHandEffect(action, playerId, 1, 1, Culture.GONDOR));
action.appendEffect(
new ShuffleDeckEffect(playerId));
action.appendEffect(
new ChooseOpponentEffect(playerId) {
@Override
protected void opponentChosen(String opponentId) {
action.insertEffect(
new OptionalEffect(action, opponentId,
new DrawCardEffect(opponentId, 2)));
}
});
return Collections.singletonList(action);
}
return null;
}
}