"Mudeseld"

This commit is contained in:
marcins78@gmail.com
2011-10-22 21:05:39 +00:00
parent 6457d8940c
commit 34725eb26e
4 changed files with 128 additions and 15 deletions

View File

@@ -84,7 +84,7 @@ public class PlayConditions {
return (!blueprint.isUnique()
|| (
!Filters.canSpot(gameState, modifiersQuerying, Filters.name(blueprint.getName()))
&& (Filters.filter(gameState.getDeadPile(self.getOwner()), gameState, modifiersQuerying, Filters.name(blueprint.getName())).size() == 0)));
&& (self.getZone() == Zone.DEAD || (Filters.filter(gameState.getDeadPile(self.getOwner()), gameState, modifiersQuerying, Filters.name(blueprint.getName())).size() == 0))));
}
private static int getTotalCompanions(String playerId, GameState gameState, ModifiersQuerying modifiersQuerying) {
@@ -93,7 +93,10 @@ public class PlayConditions {
}
public static boolean checkRuleOfNine(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard self) {
return (getTotalCompanions(self.getOwner(), gameState, modifiersQuerying) < 9);
if (self.getZone() == Zone.DEAD)
return (getTotalCompanions(self.getOwner(), gameState, modifiersQuerying) <= 9);
else
return (getTotalCompanions(self.getOwner(), gameState, modifiersQuerying) < 9);
}
public static boolean canHealByDiscarding(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard self) {
@@ -162,6 +165,10 @@ public class PlayConditions {
return Filters.filter(game.getGameState().getHand(playerId), game.getGameState(), game.getModifiersQuerying(), Filters.and(filters, Filters.playable(game, twilightModifier))).size() > 0;
}
public static boolean canPlayFromDeadPile(String playerId, LotroGame game, Filterable... filters) {
return Filters.filter(game.getGameState().getDeadPile(playerId), game.getGameState(), game.getModifiersQuerying(), Filters.and(filters, Filters.playable(game))).size() > 0;
}
public static boolean canPlayFromDiscard(String playerId, LotroGame game, Filterable... filters) {
return Filters.filter(game.getGameState().getDiscard(playerId), game.getGameState(), game.getModifiersQuerying(), Filters.and(filters, Filters.playable(game))).size() > 0;
}

View File

@@ -0,0 +1,70 @@
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.LinkedList;
import java.util.List;
public class ChooseAndPlayCardFromDeadPileEffect extends AbstractEffect {
private String _playerId;
private Filter _filter;
private int _twilightModifier;
public ChooseAndPlayCardFromDeadPileEffect(String playerId, List<? extends PhysicalCard> cardsInDeadPileAtStart, Filterable... filter) {
this(playerId, cardsInDeadPileAtStart, 0, filter);
}
public ChooseAndPlayCardFromDeadPileEffect(String playerId, List<? extends PhysicalCard> cardsInDeadPileAtStart, int twilightModifier, Filterable... filter) {
_playerId = playerId;
// Card has to be in dead pile when you start playing the card (we need to copy the collection)
_filter = Filters.and(filter, Filters.in(new LinkedList<PhysicalCard>(cardsInDeadPileAtStart)));
_twilightModifier = twilightModifier;
}
@Override
public String getText(LotroGame game) {
return "Play card from dead pile";
}
@Override
public boolean isPlayableInFull(LotroGame game) {
return getPlayableInDeadPile(game).size() > 0;
}
@Override
public Type getType() {
return null;
}
@Override
protected FullEffectResult playEffectReturningResult(final LotroGame game) {
Collection<PhysicalCard> deadPile = getPlayableInDeadPile(game);
if (deadPile.size() > 0) {
game.getUserFeedback().sendAwaitingDecision(_playerId,
new ArbitraryCardsSelectionDecision(1, "Choose a card to play", new LinkedList<PhysicalCard>(deadPile), 1, 1) {
@Override
public void decisionMade(String result) throws DecisionResultInvalidException {
List<PhysicalCard> selectedCards = getSelectedCardsByResponse(result);
if (selectedCards.size() > 0) {
PhysicalCard selectedCard = selectedCards.get(0);
game.getActionsEnvironment().addActionToStack(selectedCard.getBlueprint().getPlayCardAction(_playerId, game, selectedCard, _twilightModifier));
}
}
});
return new FullEffectResult(null, true, true);
}
return new FullEffectResult(null, false, false);
}
private Collection<PhysicalCard> getPlayableInDeadPile(LotroGame game) {
return Filters.filter(game.getGameState().getDiscard(_playerId), game.getGameState(), game.getModifiersQuerying(), _filter, Filters.playable(game, _twilightModifier));
}
}

View File

@@ -1,8 +1,9 @@
package com.gempukku.lotro.cards.set4.gandalf;
import com.gempukku.lotro.cards.AbstractOldEvent;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.actions.PlayEventAction;
import com.gempukku.lotro.cards.effects.choose.ChooseArbitraryCardsEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseAndPlayCardFromDeadPileEffect;
import com.gempukku.lotro.common.Culture;
import com.gempukku.lotro.common.Phase;
import com.gempukku.lotro.common.Race;
@@ -11,8 +12,6 @@ import com.gempukku.lotro.filters.Filters;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.game.state.LotroGame;
import java.util.Collection;
/**
* Set: The Two Towers
* Side: Free
@@ -32,7 +31,7 @@ public class Card4_106 extends AbstractOldEvent {
&& Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), Filters.race(Race.ELF))
&& Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), Filters.culture(Culture.GONDOR), Filters.race(Race.MAN))
&& Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), Filters.race(Race.DWARF))
&& Filters.filter(game.getGameState().getDeadPile(playerId), game.getGameState(), game.getModifiersQuerying(), Filters.name("Gandalf")).size() > 0;
&& PlayConditions.canPlayFromDeadPile(playerId, game, Filters.name("Gandalf"));
}
@Override
@@ -44,15 +43,7 @@ public class Card4_106 extends AbstractOldEvent {
public PlayEventAction getPlayCardAction(final String playerId, LotroGame game, PhysicalCard self, int twilightModifier) {
PlayEventAction action = new PlayEventAction(self);
action.appendEffect(
new ChooseArbitraryCardsEffect(playerId, "Choose Gandalf in dead pile", game.getGameState().getDeadPile(playerId), Filters.name("Gandalf"), 1, 1) {
@Override
protected void cardsSelected(LotroGame game, Collection<PhysicalCard> selectedCards) {
if (selectedCards.size() > 0) {
PhysicalCard gandalf = selectedCards.iterator().next();
game.getActionsEnvironment().addActionToStack(gandalf.getBlueprint().getPlayCardAction(playerId, game, gandalf, 0));
}
}
});
new ChooseAndPlayCardFromDeadPileEffect(playerId, game.getGameState().getDeadPile(playerId), Filters.name("Gandalf")));
return action;
}
}

View File

@@ -0,0 +1,45 @@
package com.gempukku.lotro.cards.set6.site;
import com.gempukku.lotro.cards.AbstractSite;
import com.gempukku.lotro.cards.PlayConditions;
import com.gempukku.lotro.cards.effects.choose.ChooseAndExertCharactersEffect;
import com.gempukku.lotro.cards.effects.choose.ChooseAndPlayCardFromDeadPileEffect;
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.timing.Action;
import java.util.Collections;
import java.util.List;
/**
* Set: Ents of Fangorn
* Twilight Cost: 0
* Type: Site
* Site: 3T
* Game Text: Sanctuary. Fellowship: Exert 3 companions with the Gandalf signet to play an unbound companion from
* your dead pile.
*/
public class Card6_117 extends AbstractSite {
public Card6_117() {
super("Mudeseld", Block.TWO_TOWERS, 3, 0, Direction.RIGHT);
addKeyword(Keyword.SANCTUARY);
}
@Override
public List<? extends Action> getPhaseActions(String playerId, LotroGame game, PhysicalCard self) {
if (PlayConditions.canUseSiteDuringPhase(game.getGameState(), Phase.FELLOWSHIP, self)
&& PlayConditions.canExertMultiple(self, game, 1, 3, CardType.COMPANION, Signet.GANDALF)
&& PlayConditions.canPlayFromDeadPile(playerId, game, Filters.unboundCompanion)) {
ActivateCardAction action = new ActivateCardAction(self);
action.appendCost(
new ChooseAndExertCharactersEffect(action, playerId, 3, 3, CardType.COMPANION, Signet.GANDALF));
action.appendEffect(
new ChooseAndPlayCardFromDeadPileEffect(playerId, game.getGameState().getDeadPile(playerId), Filters.unboundCompanion));
return Collections.singletonList(action);
}
return null;
}
}