"Erland"
Look or reveal cards from hand prevention introduced.
This commit is contained in:
@@ -31,17 +31,19 @@ public abstract class RevealAndChooseCardsFromOpponentHandEffect extends Unrespo
|
||||
|
||||
@Override
|
||||
public void doPlayEffect(LotroGame game) {
|
||||
List<PhysicalCard> opponentHand = new LinkedList<PhysicalCard>(game.getGameState().getHand(_opponentId));
|
||||
Collection<PhysicalCard> selectable = Filters.filter(opponentHand, game.getGameState(), game.getModifiersQuerying(), _selectionFilter);
|
||||
if (game.getModifiersQuerying().canLookOrRevealCardsInHand(game.getGameState(), _opponentId)) {
|
||||
List<PhysicalCard> opponentHand = new LinkedList<PhysicalCard>(game.getGameState().getHand(_opponentId));
|
||||
Collection<PhysicalCard> selectable = Filters.filter(opponentHand, game.getGameState(), game.getModifiersQuerying(), _selectionFilter);
|
||||
|
||||
game.getUserFeedback().sendAwaitingDecision(_playerId,
|
||||
new ArbitraryCardsSelectionDecision(1, _text, opponentHand, new LinkedList<PhysicalCard>(selectable), Math.min(_minChosen, selectable.size()), Math.min(_maxChosen, selectable.size())) {
|
||||
@Override
|
||||
public void decisionMade(String result) throws DecisionResultInvalidException {
|
||||
List<PhysicalCard> selectedCards = getSelectedCardsByResponse(result);
|
||||
cardsSelected(selectedCards);
|
||||
}
|
||||
});
|
||||
game.getUserFeedback().sendAwaitingDecision(_playerId,
|
||||
new ArbitraryCardsSelectionDecision(1, _text, opponentHand, new LinkedList<PhysicalCard>(selectable), Math.min(_minChosen, selectable.size()), Math.min(_maxChosen, selectable.size())) {
|
||||
@Override
|
||||
public void decisionMade(String result) throws DecisionResultInvalidException {
|
||||
List<PhysicalCard> selectedCards = getSelectedCardsByResponse(result);
|
||||
cardsSelected(selectedCards);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void cardsSelected(List<PhysicalCard> selectedCards);
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.gempukku.lotro.cards.modifiers;
|
||||
|
||||
import com.gempukku.lotro.game.PhysicalCard;
|
||||
import com.gempukku.lotro.game.state.GameState;
|
||||
import com.gempukku.lotro.logic.modifiers.AbstractModifier;
|
||||
import com.gempukku.lotro.logic.modifiers.ModifierEffect;
|
||||
import com.gempukku.lotro.logic.modifiers.ModifiersQuerying;
|
||||
|
||||
public class OpponentsCantLookOrRevealCardsFromHand extends AbstractModifier {
|
||||
private String _playerId;
|
||||
|
||||
public OpponentsCantLookOrRevealCardsFromHand(PhysicalCard source, String playerId) {
|
||||
super(source, "Opponents can't look or reveal cards from hand", null, new ModifierEffect[]{ModifierEffect.LOOK_OR_REVEAL_MODIFIER});
|
||||
_playerId = playerId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canLookOrRevealCardsInHand(GameState gameState, ModifiersQuerying modifiersQuerying, String playerId) {
|
||||
if (_playerId.equals(playerId))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -49,16 +49,18 @@ public class Card1_055 extends AbstractPermanent {
|
||||
new MultipleChoiceAwaitingDecision(1, "Choose opponent with at least 7 cards in hand", opponentsHavingAtLeast7Cards(game, playerId)) {
|
||||
@Override
|
||||
protected void validDecisionMade(int index, final String chosenOpponent) {
|
||||
List<? extends PhysicalCard> hand = game.getGameState().getHand(chosenOpponent);
|
||||
List<PhysicalCard> randomCardsFromHand = GameUtils.getRandomCards(hand, 2);
|
||||
action.appendEffect(
|
||||
new ChooseArbitraryCardsEffect(playerId, "Choose card to discard", randomCardsFromHand, 1, 1) {
|
||||
@Override
|
||||
protected void cardsSelected(List<PhysicalCard> selectedCards) {
|
||||
action.appendEffect(
|
||||
new DiscardCardFromDeckEffect(chosenOpponent, selectedCards.get(0)));
|
||||
}
|
||||
});
|
||||
if (game.getModifiersQuerying().canLookOrRevealCardsInHand(game.getGameState(), chosenOpponent)) {
|
||||
List<? extends PhysicalCard> hand = game.getGameState().getHand(chosenOpponent);
|
||||
List<PhysicalCard> randomCardsFromHand = GameUtils.getRandomCards(hand, 2);
|
||||
action.appendEffect(
|
||||
new ChooseArbitraryCardsEffect(playerId, "Choose card to discard", randomCardsFromHand, 1, 1) {
|
||||
@Override
|
||||
protected void cardsSelected(List<PhysicalCard> selectedCards) {
|
||||
action.appendEffect(
|
||||
new DiscardCardFromDeckEffect(chosenOpponent, selectedCards.get(0)));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
@@ -71,16 +71,15 @@ public class Card1_075 extends AbstractAttachableFPPossession {
|
||||
action.appendEffect(
|
||||
new ChooseOpponentEffect(playerId) {
|
||||
@Override
|
||||
protected void opponentChosen(String opponentId) {
|
||||
protected void opponentChosen(final String opponentId) {
|
||||
action.appendEffect(
|
||||
new RevealAndChooseCardsFromOpponentHandEffect(playerId, opponentId, "Opponent's hand", Filters.none(), 0, 0) {
|
||||
@Override
|
||||
protected void cardsSelected(List<PhysicalCard> selectedCards) {
|
||||
// This is just to reveal the hand
|
||||
Collection<PhysicalCard> orcs = Filters.filter(game.getGameState().getHand(opponentId), game.getGameState(), game.getModifiersQuerying(), Filters.race(Race.ORC));
|
||||
action.appendEffect(new RemoveTwilightEffect(orcs.size()));
|
||||
}
|
||||
});
|
||||
Collection<PhysicalCard> orcs = Filters.filter(game.getGameState().getHand(opponentId), game.getGameState(), game.getModifiersQuerying(), Filters.race(Race.ORC));
|
||||
action.appendEffect(new RemoveTwilightEffect(orcs.size()));
|
||||
}
|
||||
});
|
||||
return Collections.singletonList(action);
|
||||
|
||||
@@ -56,17 +56,18 @@ public class Card1_120 extends AbstractPermanent {
|
||||
final ActivateCardAction action = new ActivateCardAction(self, Keyword.SHADOW, "Remove (3) and spot X burdens to make the Free Peoples player reveal X cards at random from hand. You may discard 1 revealed card.");
|
||||
action.appendCost(new RemoveTwilightEffect(3));
|
||||
final String fpPlayer = gameState.getCurrentPlayerId();
|
||||
action.appendEffect(
|
||||
new PlayoutDecisionEffect(game.getUserFeedback(), playerId,
|
||||
new ArbitraryCardsSelectionDecision(1, "Choose card to discard", GameUtils.getRandomCards(gameState.getHand(fpPlayer), gameState.getBurdens()), 0, 1) {
|
||||
@Override
|
||||
public void decisionMade(String result) throws DecisionResultInvalidException {
|
||||
List<PhysicalCard> cards = getSelectedCardsByResponse(result);
|
||||
if (cards.size() > 0)
|
||||
action.appendEffect(new DiscardCardFromHandEffect(cards.get(0)));
|
||||
}
|
||||
})
|
||||
);
|
||||
if (game.getModifiersQuerying().canLookOrRevealCardsInHand(game.getGameState(), fpPlayer)) {
|
||||
action.appendEffect(
|
||||
new PlayoutDecisionEffect(game.getUserFeedback(), playerId,
|
||||
new ArbitraryCardsSelectionDecision(1, "Choose card to discard", GameUtils.getRandomCards(gameState.getHand(fpPlayer), gameState.getBurdens()), 0, 1) {
|
||||
@Override
|
||||
public void decisionMade(String result) throws DecisionResultInvalidException {
|
||||
List<PhysicalCard> cards = getSelectedCardsByResponse(result);
|
||||
if (cards.size() > 0)
|
||||
action.appendEffect(new DiscardCardFromHandEffect(cards.get(0)));
|
||||
}
|
||||
}));
|
||||
}
|
||||
return Collections.singletonList(action);
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -68,24 +68,23 @@ public class Card1_313 extends AbstractAttachableFPPossession {
|
||||
action.appendEffect(
|
||||
new ChooseOpponentEffect(playerId) {
|
||||
@Override
|
||||
protected void opponentChosen(String opponentId) {
|
||||
protected void opponentChosen(final String opponentId) {
|
||||
action.appendEffect(
|
||||
new RevealAndChooseCardsFromOpponentHandEffect(playerId, opponentId, "Opponent's hand", Filters.none(), 0, 0) {
|
||||
@Override
|
||||
protected void cardsSelected(List<PhysicalCard> selectedCards) {
|
||||
// This is just to reveal the hand
|
||||
Collection<PhysicalCard> orcs = Filters.filter(game.getGameState().getHand(opponentId), game.getGameState(), game.getModifiersQuerying(), Filters.race(Race.ORC));
|
||||
Integer limit = (Integer) self.getData();
|
||||
int usedUp = 0;
|
||||
if (limit != null)
|
||||
usedUp = limit;
|
||||
int toRemove = Math.min(4 - usedUp, orcs.size());
|
||||
if (toRemove > 0) {
|
||||
self.storeData(usedUp + toRemove);
|
||||
action.appendEffect(new RemoveTwilightEffect(toRemove));
|
||||
}
|
||||
}
|
||||
});
|
||||
Collection<PhysicalCard> orcs = Filters.filter(game.getGameState().getHand(opponentId), game.getGameState(), game.getModifiersQuerying(), Filters.race(Race.ORC));
|
||||
Integer limit = (Integer) self.getData();
|
||||
int usedUp = 0;
|
||||
if (limit != null)
|
||||
usedUp = limit;
|
||||
int toRemove = Math.min(4 - usedUp, orcs.size());
|
||||
if (toRemove > 0) {
|
||||
self.storeData(usedUp + toRemove);
|
||||
action.appendEffect(new RemoveTwilightEffect(toRemove));
|
||||
}
|
||||
}
|
||||
});
|
||||
return Collections.singletonList(action);
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.gempukku.lotro.cards.set2.gandalf;
|
||||
|
||||
import com.gempukku.lotro.cards.AbstractAlly;
|
||||
import com.gempukku.lotro.cards.modifiers.OpponentsCantLookOrRevealCardsFromHand;
|
||||
import com.gempukku.lotro.common.Culture;
|
||||
import com.gempukku.lotro.common.Race;
|
||||
import com.gempukku.lotro.filters.Filters;
|
||||
import com.gempukku.lotro.game.PhysicalCard;
|
||||
import com.gempukku.lotro.game.state.LotroGame;
|
||||
import com.gempukku.lotro.logic.modifiers.Modifier;
|
||||
|
||||
/**
|
||||
* Set: Mines of Moria
|
||||
* Side: Free
|
||||
* Culture: Gandalf
|
||||
* Twilight Cost: 2
|
||||
* Type: Ally • Home 3 • Man
|
||||
* Strength: 5
|
||||
* Vitality: 2
|
||||
* Site: 3
|
||||
* Game Text: To play, spot Gandalf. Shadow players may not look at or reveal cards in your hand.
|
||||
*/
|
||||
public class Card2_021 extends AbstractAlly {
|
||||
public Card2_021() {
|
||||
super(2, 3, 5, 2, Race.MAN, Culture.GANDALF, "Erland", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkPlayRequirements(String playerId, LotroGame game, PhysicalCard self, int twilightModifier) {
|
||||
return super.checkPlayRequirements(playerId, game, self, twilightModifier)
|
||||
&& Filters.canSpot(game.getGameState(), game.getModifiersQuerying(), Filters.name("Gandalf"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Modifier getAlwaysOnEffect(PhysicalCard self) {
|
||||
return new OpponentsCantLookOrRevealCardsFromHand(self, self.getOwner());
|
||||
}
|
||||
}
|
||||
@@ -148,4 +148,9 @@ public abstract class AbstractModifier implements Modifier {
|
||||
public int getRoamingPenalty(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard, int result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canLookOrRevealCardsInHand(GameState gameState, ModifiersQuerying modifiersQuerying, String playerId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,4 +60,6 @@ public interface Modifier {
|
||||
public boolean canBeDiscardedFromPlay(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard card, PhysicalCard source, boolean result);
|
||||
|
||||
public boolean canBeHealed(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard card, boolean result);
|
||||
|
||||
public boolean canLookOrRevealCardsInHand(GameState gameState, ModifiersQuerying modifiersQuerying, String playerId);
|
||||
}
|
||||
|
||||
@@ -2,5 +2,6 @@ package com.gempukku.lotro.logic.modifiers;
|
||||
|
||||
public enum ModifierEffect {
|
||||
KEYWORD_MODIFIER, STRENGTH_MODIFIER, VITALITY_MODIFIER, TWILIGHT_COST_MODIFIER, OVERWHELM_MODIFIER, WOUND_MODIFIER,
|
||||
PRESENCE_MODIFIER, ARCHERY_MODIFIER, MOVE_LIMIT_MODIFIER, ACTION_MODIFIER, ASSIGNMENT_MODIFIER, DISCARD_FROM_PLAY_MODIFIER, ALL_MODIFIER
|
||||
PRESENCE_MODIFIER, ARCHERY_MODIFIER, MOVE_LIMIT_MODIFIER, ACTION_MODIFIER, ASSIGNMENT_MODIFIER, DISCARD_FROM_PLAY_MODIFIER,
|
||||
LOOK_OR_REVEAL_MODIFIER, ALL_MODIFIER
|
||||
}
|
||||
|
||||
@@ -455,6 +455,17 @@ public class ModifiersLogic implements ModifiersEnvironment, ModifiersQuerying {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canLookOrRevealCardsInHand(GameState gameState, String playerId) {
|
||||
for (Modifier modifier : getModifiers(ModifierEffect.DISCARD_FROM_PLAY_MODIFIER))
|
||||
if (!modifier.canLookOrRevealCardsInHand(gameState, this, playerId))
|
||||
return false;
|
||||
for (Modifier modifier : getModifiers(ModifierEffect.ALL_MODIFIER))
|
||||
if (!modifier.canLookOrRevealCardsInHand(gameState, this, playerId))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private class ModifierHookImpl implements ModifierHook {
|
||||
private Modifier _modifier;
|
||||
|
||||
|
||||
@@ -51,4 +51,6 @@ public interface ModifiersQuerying {
|
||||
public boolean canBeHealed(GameState gameState, PhysicalCard card);
|
||||
|
||||
public boolean canDrawCardAndIncrement(GameState gameState, String playerId);
|
||||
|
||||
public boolean canLookOrRevealCardsInHand(GameState gameState, String playerId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user