"Eye of Barad-Dur"

This commit is contained in:
marcins78@gmail.com
2011-10-19 13:52:46 +00:00
parent a7ec959522
commit 2dd8cad8ab
11 changed files with 190 additions and 14 deletions

View File

@@ -4,16 +4,19 @@ 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.GameUtils;
import com.gempukku.lotro.logic.actions.SubAction;
import com.gempukku.lotro.logic.decisions.ArbitraryCardsSelectionDecision;
import com.gempukku.lotro.logic.decisions.DecisionResultInvalidException;
import com.gempukku.lotro.logic.timing.UnrespondableEffect;
import com.gempukku.lotro.logic.timing.AbstractEffect;
import com.gempukku.lotro.logic.timing.Action;
import com.gempukku.lotro.logic.timing.EffectResult;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
public abstract class RevealAndChooseCardsFromOpponentHandEffect extends UnrespondableEffect {
public abstract class RevealAndChooseCardsFromOpponentHandEffect extends AbstractEffect {
private Action _action;
private String _playerId;
private String _opponentId;
private PhysicalCard _source;
@@ -22,7 +25,8 @@ public abstract class RevealAndChooseCardsFromOpponentHandEffect extends Unrespo
private int _minChosen;
private int _maxChosen;
protected RevealAndChooseCardsFromOpponentHandEffect(String playerId, String opponentId, PhysicalCard source, String text, Filter selectionFilter, int minChosen, int maxChosen) {
protected RevealAndChooseCardsFromOpponentHandEffect(Action action, String playerId, String opponentId, PhysicalCard source, String text, Filter selectionFilter, int minChosen, int maxChosen) {
_action = action;
_playerId = playerId;
_opponentId = opponentId;
_source = source;
@@ -33,10 +37,21 @@ public abstract class RevealAndChooseCardsFromOpponentHandEffect extends Unrespo
}
@Override
public void doPlayEffect(LotroGame game) {
public boolean isPlayableInFull(LotroGame game) {
return (game.getModifiersQuerying().canLookOrRevealCardsInHand(game.getGameState(), _opponentId))
&& game.getGameState().getHand(_opponentId).size() >= _minChosen;
}
@Override
protected FullEffectResult playEffectReturningResult(LotroGame game) {
if (game.getModifiersQuerying().canLookOrRevealCardsInHand(game.getGameState(), _opponentId)) {
List<PhysicalCard> opponentHand = new LinkedList<PhysicalCard>(game.getGameState().getHand(_opponentId));
game.getGameState().sendMessage(GameUtils.getCardLink(_source) + " revealed " + _opponentId + " hand - " + getAppendedNames(opponentHand));
SubAction subAction = new SubAction(_action);
subAction.appendEffect(
new RevealCardsFromHandEffect(_source, _opponentId, opponentHand));
game.getActionsEnvironment().addActionToStack(subAction);
Collection<PhysicalCard> selectable = Filters.filter(opponentHand, game.getGameState(), game.getModifiersQuerying(), _selectionFilter);
game.getUserFeedback().sendAwaitingDecision(_playerId,
@@ -47,7 +62,19 @@ public abstract class RevealAndChooseCardsFromOpponentHandEffect extends Unrespo
cardsSelected(selectedCards);
}
});
return new FullEffectResult(null, true, true);
}
return new FullEffectResult(null, false, false);
}
@Override
public String getText(LotroGame game) {
return null;
}
@Override
public EffectResult.Type getType() {
return null;
}
protected abstract void cardsSelected(List<PhysicalCard> selectedCards);

View File

@@ -0,0 +1,50 @@
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 com.gempukku.lotro.logic.timing.EffectResult;
import com.gempukku.lotro.logic.timing.results.RevealCardsFromHandResult;
import java.util.Collection;
public class RevealCardsFromHandEffect extends AbstractEffect {
private PhysicalCard _source;
private String _handPlayerId;
private Collection<PhysicalCard> _cards;
public RevealCardsFromHandEffect(PhysicalCard source, String handPlayerId, Collection<PhysicalCard> cards) {
_source = source;
_handPlayerId = handPlayerId;
_cards = cards;
}
@Override
public String getText(LotroGame game) {
return null;
}
@Override
public EffectResult.Type getType() {
return EffectResult.Type.REVEAL_CARDS_FROM_HAND;
}
@Override
public boolean isPlayableInFull(LotroGame game) {
for (PhysicalCard card : _cards) {
if (card.getZone() != Zone.HAND)
return false;
}
return true;
}
@Override
protected FullEffectResult playEffectReturningResult(LotroGame game) {
game.getGameState().sendMessage(GameUtils.getCardLink(_source) + " revealed " + _handPlayerId + " cards in hand - " + getAppendedNames(_cards));
return new FullEffectResult(new EffectResult[]{new RevealCardsFromHandResult(_source, _handPlayerId, _cards)}, true, true);
}
}

View File

@@ -5,6 +5,7 @@ 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.EffectResult;
import com.gempukku.lotro.logic.timing.results.RevealCardsFromHandResult;
import java.util.List;
@@ -28,7 +29,7 @@ public abstract class RevealRandomCardsFromHandEffect extends AbstractEffect {
@Override
public EffectResult.Type getType() {
return null;
return EffectResult.Type.REVEAL_CARDS_FROM_HAND;
}
@Override
@@ -38,7 +39,7 @@ public abstract class RevealRandomCardsFromHandEffect extends AbstractEffect {
if (randomCards.size() > 0)
game.getGameState().sendMessage(GameUtils.getCardLink(_source) + " revealed cards from " + _playerHand + " hand at random - " + getAppendedNames(randomCards));
cardsRevealed(randomCards);
return new FullEffectResult(null, randomCards.size() == _count, randomCards.size() == _count);
return new FullEffectResult(new EffectResult[]{new RevealCardsFromHandResult(_source, _playerHand, randomCards)}, randomCards.size() == _count, randomCards.size() == _count);
}
return new FullEffectResult(null, false, false);
}

View File

@@ -53,7 +53,7 @@ public class Card1_036 extends AbstractOldEvent {
protected void opponentChosen(String opponentId) {
List<? extends PhysicalCard> hand = game.getGameState().getHand(opponentId);
int orcsCount = Filters.filter(hand, game.getGameState(), game.getModifiersQuerying(), Filters.race(Race.ORC)).size();
action.appendEffect(new RevealAndChooseCardsFromOpponentHandEffect(playerId, opponentId, self, "Opponent's hand", Filters.none, 0, 0) {
action.appendEffect(new RevealAndChooseCardsFromOpponentHandEffect(action, playerId, opponentId, self, "Opponent's hand", Filters.none, 0, 0) {
@Override
protected void cardsSelected(List<PhysicalCard> selectedCards) {
// Do nothing

View File

@@ -50,7 +50,7 @@ public class Card1_044 extends AbstractOldEvent {
@Override
protected void opponentChosen(final String opponentId) {
action.appendEffect(
new RevealAndChooseCardsFromOpponentHandEffect(playerId, opponentId, self, "Choose an ISENGARD minion", Filters.and(Filters.culture(Culture.ISENGARD), Filters.type(CardType.MINION)), 0, 1) {
new RevealAndChooseCardsFromOpponentHandEffect(action, playerId, opponentId, self, "Choose an ISENGARD minion", Filters.and(Filters.culture(Culture.ISENGARD), Filters.type(CardType.MINION)), 0, 1) {
@Override
protected void cardsSelected(List<PhysicalCard> selectedCards) {
if (selectedCards.size() > 0) {

View File

@@ -57,7 +57,7 @@ public class Card1_075 extends AbstractAttachableFPPossession {
@Override
protected void opponentChosen(final String opponentId) {
action.appendEffect(
new RevealAndChooseCardsFromOpponentHandEffect(playerId, opponentId, self, "Opponent's hand", Filters.none, 0, 0) {
new RevealAndChooseCardsFromOpponentHandEffect(action, playerId, opponentId, self, "Opponent's hand", Filters.none, 0, 0) {
@Override
protected void cardsSelected(List<PhysicalCard> selectedCards) {
Collection<PhysicalCard> orcs = Filters.filter(game.getGameState().getHand(opponentId), game.getGameState(), game.getModifiersQuerying(), Filters.race(Race.ORC));

View File

@@ -42,7 +42,7 @@ public class Card1_086 extends AbstractOldEvent {
@Override
protected void opponentChosen(String opponentId) {
action.appendEffect(
new RevealAndChooseCardsFromOpponentHandEffect(playerId, opponentId, self, "Opponent's hand", Filters.none, 0, 0) {
new RevealAndChooseCardsFromOpponentHandEffect(action, playerId, opponentId, self, "Opponent's hand", Filters.none, 0, 0) {
@Override
protected void cardsSelected(List<PhysicalCard> selectedCards) {
// Do nothing, just revealing

View File

@@ -56,7 +56,7 @@ public class Card1_313 extends AbstractAttachableFPPossession {
@Override
protected void opponentChosen(final String opponentId) {
action.appendEffect(
new RevealAndChooseCardsFromOpponentHandEffect(playerId, opponentId, self, "Opponent's hand", Filters.none, 0, 0) {
new RevealAndChooseCardsFromOpponentHandEffect(action, playerId, opponentId, self, "Opponent's hand", Filters.none, 0, 0) {
@Override
protected void cardsSelected(List<PhysicalCard> selectedCards) {
Collection<PhysicalCard> orcs = Filters.filter(game.getGameState().getHand(opponentId), game.getGameState(), game.getModifiersQuerying(), Filters.race(Race.ORC));

View File

@@ -0,0 +1,66 @@
package com.gempukku.lotro.cards.set5.rohan;
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.AddBurdenEffect;
import com.gempukku.lotro.cards.effects.AddUntilEndOfPhaseModifierEffect;
import com.gempukku.lotro.cards.modifiers.StrengthModifier;
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.effects.ChooseActiveCardEffect;
import com.gempukku.lotro.logic.timing.EffectResult;
import com.gempukku.lotro.logic.timing.results.RevealCardsFromHandResult;
import java.util.Collections;
import java.util.List;
/**
* Set: Battle of Helm's Deep
* Side: Shadow
* Culture: Sauron
* Twilight Cost: 0
* Type: Event
* Game Text: Skirmish: Make a companion or ally skirmishing a [SAURON] Orc strength -1 for each ring-bound companion.
* Response: If a free people player reveals this card from your hand, discard this card to add 2 burdens.
*/
public class Card5_096 extends AbstractEvent {
public Card5_096() {
super(Side.SHADOW, 0, Culture.SAURON, "Eye of Barad-Dur", Phase.SKIRMISH);
}
@Override
public PlayEventAction getPlayCardAction(String playerId, LotroGame game, final PhysicalCard self, int twilightModifier) {
final PlayEventAction action = new PlayEventAction(self);
action.appendEffect(
new ChooseActiveCardEffect(self, playerId, "Choose companion or ally",
Filters.or(CardType.COMPANION, CardType.ALLY), Filters.inSkirmishAgainst(Culture.SAURON, Race.ORC)) {
@Override
protected void cardSelected(LotroGame game, PhysicalCard card) {
int ringBoundCompanions = Filters.countActive(game.getGameState(), game.getModifiersQuerying(), CardType.COMPANION, Keyword.RING_BOUND);
action.insertEffect(
new AddUntilEndOfPhaseModifierEffect(
new StrengthModifier(self, Filters.sameCard(card), -ringBoundCompanions), Phase.SKIRMISH));
}
});
return action;
}
@Override
public List<PlayEventAction> getOptionalAfterActions(String playerId, LotroGame game, EffectResult effectResult, PhysicalCard self) {
if (effectResult.getType() == EffectResult.Type.REVEAL_CARDS_FROM_HAND) {
RevealCardsFromHandResult revealResult = (RevealCardsFromHandResult) effectResult;
if (revealResult.getSource().getOwner().equals(game.getGameState().getCurrentPlayerId())
&& revealResult.getRevealedCards().contains(self)
&& PlayConditions.canPayForShadowCard(game, self, 0)) {
PlayEventAction action = new PlayEventAction(self);
action.appendEffect(
new AddBurdenEffect(self, 2));
return Collections.singletonList(action);
}
}
return null;
}
}

View File

@@ -20,7 +20,8 @@ public abstract class EffectResult {
PUT_ON_THE_ONE_RING, REMOVE_BURDEN, ADD_BURDEN,
WHEN_MOVE_FROM, WHEN_FELLOWSHIP_MOVES, WHEN_MOVE_TO
WHEN_MOVE_FROM, WHEN_FELLOWSHIP_MOVES, WHEN_MOVE_TO,
REVEAL_CARDS_FROM_HAND
}
private Type _type;

View File

@@ -0,0 +1,31 @@
package com.gempukku.lotro.logic.timing.results;
import com.gempukku.lotro.game.PhysicalCard;
import com.gempukku.lotro.logic.timing.EffectResult;
import java.util.Collection;
public class RevealCardsFromHandResult extends EffectResult {
private PhysicalCard _source;
private String _playerId;
private Collection<PhysicalCard> _revealedCards;
public RevealCardsFromHandResult(PhysicalCard source, String playerId, Collection<PhysicalCard> revealedCards) {
super(Type.REVEAL_CARDS_FROM_HAND);
_source = source;
_playerId = playerId;
_revealedCards = revealedCards;
}
public PhysicalCard getSource() {
return _source;
}
public String getPlayerId() {
return _playerId;
}
public Collection<PhysicalCard> getRevealedCards() {
return _revealedCards;
}
}