"Denethor"

This commit is contained in:
marcins78@gmail.com
2012-01-03 15:58:52 +00:00
parent a0b9d46764
commit c06abc0281
13 changed files with 203 additions and 45 deletions

View File

@@ -0,0 +1,59 @@
package com.gempukku.lotro.cards.effects;
import com.gempukku.lotro.common.Zone;
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.AbstractEffect;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
public class RemoveCardsFromTheGameEffect extends AbstractEffect {
private String _playerPerforming;
private PhysicalCard _source;
private Collection<PhysicalCard> _cardsToRemove;
public RemoveCardsFromTheGameEffect(String playerPerforming, PhysicalCard source, Collection<PhysicalCard> cardsToRemove) {
_playerPerforming = playerPerforming;
_source = source;
_cardsToRemove = cardsToRemove;
}
@Override
public String getText(LotroGame game) {
return null;
}
@Override
public Type getType() {
return null;
}
@Override
public boolean isPlayableInFull(LotroGame game) {
for (PhysicalCard physicalCard : _cardsToRemove) {
if (!physicalCard.getZone().isInPlay())
return false;
}
return true;
}
@Override
protected FullEffectResult playEffectReturningResult(LotroGame game) {
Set<PhysicalCard> removedCards = new HashSet<PhysicalCard>();
for (PhysicalCard physicalCard : _cardsToRemove)
if (physicalCard.getZone().isInPlay())
removedCards.add(physicalCard);
game.getGameState().removeCardsFromZone(_playerPerforming, removedCards);
for (PhysicalCard removedCard : removedCards)
game.getGameState().addCardToZone(game, removedCard, Zone.REMOVED);
game.getGameState().sendMessage(_playerPerforming + " removed " + GameUtils.getAppendedNames(removedCards) + " from the game using " + GameUtils.getCardLink(_source));
return new FullEffectResult(_cardsToRemove.size() == removedCards.size(), _cardsToRemove.size() == removedCards.size());
}
}

View File

@@ -34,11 +34,11 @@ public class ChooseAndDiscardCardsFromPlayEffect extends ChooseActiveCardsEffect
@Override
public boolean wasSuccessful() {
return _resultSubAction != null && _resultSubAction.wasSuccessful();
return super.wasSuccessful() && _resultSubAction != null && _resultSubAction.wasSuccessful();
}
@Override
public boolean wasCarriedOut() {
return _resultSubAction != null && _resultSubAction.wasCarriedOut();
return super.wasCarriedOut() && _resultSubAction != null && _resultSubAction.wasCarriedOut();
}
}

View File

@@ -58,11 +58,11 @@ public class ChooseAndExertCharactersEffect extends ChooseActiveCardsEffect {
@Override
public boolean wasSuccessful() {
return _resultSubAction != null && _resultSubAction.wasSuccessful();
return super.wasSuccessful() && _resultSubAction != null && _resultSubAction.wasSuccessful();
}
@Override
public boolean wasCarriedOut() {
return _resultSubAction != null && _resultSubAction.wasCarriedOut();
return super.wasCarriedOut() && _resultSubAction != null && _resultSubAction.wasCarriedOut();
}
}

View File

@@ -26,11 +26,11 @@ public class ChooseAndPutCardFromPlayOnTopOfDeckEffect extends ChooseActiveCardE
@Override
public boolean wasSuccessful() {
return _resultSubAction != null && _resultSubAction.wasSuccessful();
return super.wasSuccessful() && _resultSubAction != null && _resultSubAction.wasSuccessful();
}
@Override
public boolean wasCarriedOut() {
return _resultSubAction != null && _resultSubAction.wasCarriedOut();
return super.wasCarriedOut() && _resultSubAction != null && _resultSubAction.wasCarriedOut();
}
}

View File

@@ -10,20 +10,21 @@ import com.gempukku.lotro.logic.decisions.ArbitraryCardsSelectionDecision;
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
import com.gempukku.lotro.logic.timing.AbstractSubActionEffect;
import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
import java.util.Collection;
import java.util.List;
public class ChooseAndRemoveCardsFromDiscardEffect extends AbstractSubActionEffect {
public class ChooseAndRemoveFromTheGameCardsInDiscardEffect extends AbstractSubActionEffect {
private Action _action;
private PhysicalCard _source;
private String _playerId;
private int _minimum;
private int _maximum;
private Filterable[] _filters;
private SubAction _resultSubAction;
private boolean _success;
public ChooseAndRemoveCardsFromDiscardEffect(Action action, PhysicalCard source, String playerId, int minimum, int maximum, Filterable... filters) {
public ChooseAndRemoveFromTheGameCardsInDiscardEffect(Action action, PhysicalCard source, String playerId, int minimum, int maximum, Filterable... filters) {
_action = action;
_source = source;
_playerId = playerId;
@@ -48,47 +49,40 @@ public class ChooseAndRemoveCardsFromDiscardEffect extends AbstractSubActionEffe
}
@Override
public void playEffect(LotroGame game) {
public void playEffect(final LotroGame game) {
final Collection<PhysicalCard> possibleTargets = Filters.filter(game.getGameState().getDiscard(_playerId), game.getGameState(), game.getModifiersQuerying(), _filters);
if (possibleTargets.size() <= _minimum) {
processForCards(possibleTargets);
processForCards(game, possibleTargets);
} else {
int min = _minimum;
int max = Math.min(_maximum, possibleTargets.size());
game.getUserFeedback().sendAwaitingDecision(_playerId,
new ArbitraryCardsSelectionDecision(1, "Choose cards to remove from play", possibleTargets, min, max) {
new ArbitraryCardsSelectionDecision(1, "Choose cards to remove from the game", possibleTargets, min, max) {
@Override
public void decisionMade(String result) throws DecisionResultInvalidException {
final List<PhysicalCard> selectedCards = getSelectedCardsByResponse(result);
processForCards(selectedCards);
processForCards(game, selectedCards);
}
});
}
}
private void processForCards(Collection<PhysicalCard> cards) {
SubAction subAction = new SubAction(_action);
subAction.appendEffect(
private void processForCards(LotroGame game, Collection<PhysicalCard> cards) {
_resultSubAction = new SubAction(_action);
_resultSubAction.appendEffect(
new RemoveCardsFromDiscardEffect(_playerId, _source, cards));
if (cards.size() < _minimum) {
// It has failed...
subAction.appendEffect(
new UnrespondableEffect() {
@Override
protected void doPlayEffect(LotroGame game) {
}
processSubAction(game, _resultSubAction);
_success = cards.size() >= _minimum;
}
@Override
public boolean wasCarriedOut() {
return false;
}
@Override
public boolean wasSuccessful() {
return super.wasSuccessful() && _success;
}
@Override
public boolean wasSuccessful() {
return false;
}
});
}
@Override
public boolean wasCarriedOut() {
return super.wasCarriedOut() && _success;
}
}

View File

@@ -0,0 +1,40 @@
package com.gempukku.lotro.cards.effects.choose;
import com.gempukku.lotro.cards.effects.RemoveCardsFromTheGameEffect;
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.effects.ChooseActiveCardsEffect;
import com.gempukku.lotro.logic.timing.Action;
import java.util.Collection;
public class ChooseAndRemoveFromTheGameCardsInPlayEffect extends ChooseActiveCardsEffect {
private Action _action;
private String _playerId;
private SubAction _resultSubAction;
public ChooseAndRemoveFromTheGameCardsInPlayEffect(Action action, String playerId, int minimum, int maximum, Filterable... filters) {
super(action.getActionSource(), playerId, "Choose cards to remove from play", minimum, maximum, filters);
_action = action;
_playerId = playerId;
}
@Override
protected void cardsSelected(LotroGame game, Collection<PhysicalCard> cards) {
_resultSubAction = new SubAction(_action);
_resultSubAction.appendEffect(new RemoveCardsFromTheGameEffect(_playerId, _action.getActionSource(), cards));
game.getActionsEnvironment().addActionToStack(_resultSubAction);
}
@Override
public boolean wasSuccessful() {
return super.wasSuccessful() && _resultSubAction != null && _resultSubAction.wasSuccessful();
}
@Override
public boolean wasCarriedOut() {
return super.wasCarriedOut() && _resultSubAction != null && _resultSubAction.wasCarriedOut();
}
}

View File

@@ -5,7 +5,7 @@ import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.actions.PlayEventAction;
import com.gempukku.lotro.cards.effects.RemovePlayedEventFromGameEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseAndAddUntilEOPStrengthBonusEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseAndRemoveCardsFromDiscardEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseAndRemoveFromTheGameCardsInDiscardEffect;
import com.gempukku.lotro.common.*;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
@@ -44,7 +44,7 @@ public class Card13_004 extends AbstractEvent {
&& PlayConditions.canRemoveFromDiscardToPlay(self, game, playerId, 4, Culture.DWARVEN)) {
final PlayEventAction action = getPlayCardAction(playerId, game, self, 0, false);
action.appendCost(
new ChooseAndRemoveCardsFromDiscardEffect(action, self, playerId, 4, 4, Culture.DWARVEN));
new ChooseAndRemoveFromTheGameCardsInDiscardEffect(action, self, playerId, 4, 4, Culture.DWARVEN));
action.appendEffect(
new RemovePlayedEventFromGameEffect(action));
return Collections.singletonList(action);

View File

@@ -5,7 +5,7 @@ import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.actions.PlayEventAction;
import com.gempukku.lotro.cards.effects.RemovePlayedEventFromGameEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseAndAddUntilEOPStrengthBonusEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseAndRemoveCardsFromDiscardEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseAndRemoveFromTheGameCardsInDiscardEffect;
import com.gempukku.lotro.common.*;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
@@ -46,7 +46,7 @@ public class Card13_017 extends AbstractEvent {
&& PlayConditions.canRemoveFromDiscardToPlay(self, game, playerId, 4, Culture.ELVEN)) {
final PlayEventAction action = getPlayCardAction(playerId, game, self, 0, false);
action.appendCost(
new ChooseAndRemoveCardsFromDiscardEffect(action, self, playerId, 4, 4, Culture.ELVEN));
new ChooseAndRemoveFromTheGameCardsInDiscardEffect(action, self, playerId, 4, 4, Culture.ELVEN));
action.appendEffect(
new RemovePlayedEventFromGameEffect(action));
return Collections.singletonList(action);

View File

@@ -5,7 +5,7 @@ import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.actions.PlayEventAction;
import com.gempukku.lotro.cards.effects.RemovePlayedEventFromGameEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseAndAddUntilEOPStrengthBonusEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseAndRemoveCardsFromDiscardEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseAndRemoveFromTheGameCardsInDiscardEffect;
import com.gempukku.lotro.common.CardType;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Phase;
@@ -53,7 +53,7 @@ public class Card13_034 extends AbstractEvent {
&& PlayConditions.canRemoveFromDiscardToPlay(self, game, playerId, 4, Culture.GANDALF)) {
final PlayEventAction action = getPlayCardAction(playerId, game, self, 0, false);
action.appendCost(
new ChooseAndRemoveCardsFromDiscardEffect(action, self, playerId, 4, 4, Culture.GANDALF));
new ChooseAndRemoveFromTheGameCardsInDiscardEffect(action, self, playerId, 4, 4, Culture.GANDALF));
action.appendEffect(
new RemovePlayedEventFromGameEffect(action));
return Collections.singletonList(action);

View File

@@ -3,7 +3,7 @@ package com.gempukku.lotro.cards.set13.gollum;
import com.gempukku.lotro.cards.AbstractMinion;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.effects.choose.ChooseAndPlayCardFromDiscardEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseAndRemoveCardsFromDiscardEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseAndRemoveFromTheGameCardsInDiscardEffect;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Keyword;
import com.gempukku.lotro.common.Phase;
@@ -75,7 +75,7 @@ public class Card13_050 extends AbstractMinion {
&& PlayConditions.canPlayFromDiscard(playerId, game, self)) {
ActivateCardAction action = new ActivateCardAction(self);
action.appendCost(
new ChooseAndRemoveCardsFromDiscardEffect(action, self, playerId, 1, 1, Filters.name("Deagol")));
new ChooseAndRemoveFromTheGameCardsInDiscardEffect(action, self, playerId, 1, 1, Filters.name("Deagol")));
action.appendEffect(
new ChooseAndPlayCardFromDiscardEffect(playerId, game, self));
return Collections.singletonList(action);

View File

@@ -5,7 +5,7 @@ import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.actions.PlayEventAction;
import com.gempukku.lotro.cards.effects.RemovePlayedEventFromGameEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseAndAddUntilEOPStrengthBonusEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseAndRemoveCardsFromDiscardEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseAndRemoveFromTheGameCardsInDiscardEffect;
import com.gempukku.lotro.common.*;
import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
@@ -50,7 +50,7 @@ public class Card13_053 extends AbstractEvent {
&& PlayConditions.canRemoveFromDiscardToPlay(self, game, playerId, 4, Culture.GOLLUM)) {
final PlayEventAction action = getPlayCardAction(playerId, game, self, 0, false);
action.appendCost(
new ChooseAndRemoveCardsFromDiscardEffect(action, self, playerId, 4, 4, Culture.GOLLUM));
new ChooseAndRemoveFromTheGameCardsInDiscardEffect(action, self, playerId, 4, 4, Culture.GOLLUM));
action.appendEffect(
new RemovePlayedEventFromGameEffect(action));
return Collections.singletonList(action);

View File

@@ -5,7 +5,7 @@ import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.actions.PlayEventAction;
import com.gempukku.lotro.cards.effects.RemovePlayedEventFromGameEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseAndAddUntilEOPStrengthBonusEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseAndRemoveCardsFromDiscardEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseAndRemoveFromTheGameCardsInDiscardEffect;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Phase;
import com.gempukku.lotro.common.Race;
@@ -47,7 +47,7 @@ public class Card13_061 extends AbstractEvent {
&& PlayConditions.canRemoveFromDiscardToPlay(self, game, playerId, 4, Culture.GONDOR)) {
final PlayEventAction action = getPlayCardAction(playerId, game, self, 0, false);
action.appendCost(
new ChooseAndRemoveCardsFromDiscardEffect(action, self, playerId, 4, 4, Culture.GONDOR));
new ChooseAndRemoveFromTheGameCardsInDiscardEffect(action, self, playerId, 4, 4, Culture.GONDOR));
action.appendEffect(
new RemovePlayedEventFromGameEffect(action));
return Collections.singletonList(action);

View File

@@ -0,0 +1,65 @@
package com.gempukku.lotro.cards.set13.gondor;
import com.gempukku.lotro.cards.AbstractCompanion;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.effects.choose.ChooseAndExertCharactersEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseAndRemoveFromTheGameCardsInPlayEffect;
import com.gempukku.lotro.cards.modifiers.ResistanceModifier;
import com.gempukku.lotro.common.CardType;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Phase;
import com.gempukku.lotro.common.Race;
import com.gempukku.lotro.filters.Filters;
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.actions.ActivateCardAction;
import com.gempukku.lotro.logic.modifiers.Modifier;
import com.gempukku.lotro.logic.modifiers.ModifiersQuerying;
import com.gempukku.lotro.logic.modifiers.evaluator.Evaluator;
import java.util.Collections;
import java.util.List;
/**
* Set: Bloodlines
* Side: Free
* Culture: Gondor
* Twilight Cost: 3
* Type: Companion • Man
* Strength: 7
* Vitality: 3
* Resistance: 5
* Game Text: Denethor is resistance +1 for each [GONDOR] possession in your discard pile. Maneuver: Spot a [GONDOR]
* possession borne by a companion and remove that possession from the game to exert a minion twice.
*/
public class Card13_064 extends AbstractCompanion {
public Card13_064() {
super(3, 7, 3, 5, Culture.GONDOR, Race.MAN, null, "Denethor", true);
}
@Override
public Modifier getAlwaysOnModifier(final PhysicalCard self) {
return new ResistanceModifier(self, self,
new Evaluator() {
@Override
public int evaluateExpression(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard cardAffected) {
return Filters.filter(gameState.getDiscard(self.getOwner()), gameState, modifiersQuerying, Culture.GONDOR, CardType.POSSESSION).size();
}
});
}
@Override
protected List<ActivateCardAction> getExtraInPlayPhaseActions(String playerId, LotroGame game, PhysicalCard self) {
if (PlayConditions.canUseFPCardDuringPhase(game, Phase.MANEUVER, self)
&& PlayConditions.canSpot(game, Culture.GONDOR, CardType.POSSESSION, Filters.attachedTo(CardType.COMPANION))) {
ActivateCardAction action = new ActivateCardAction(self);
action.appendCost(
new ChooseAndRemoveFromTheGameCardsInPlayEffect(action, playerId, 1, 1, Culture.GONDOR, CardType.POSSESSION, Filters.attachedTo(CardType.COMPANION)));
action.appendEffect(
new ChooseAndExertCharactersEffect(action, playerId, 1, 1, 2, CardType.MINION));
return Collections.singletonList(action);
}
return null;
}
}