Reveal and choose card from opponent's hand.
This commit is contained in:
@@ -0,0 +1,45 @@
|
|||||||
|
package com.gempukku.lotro.cards.effects;
|
||||||
|
|
||||||
|
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.UnrespondableEffect;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public abstract class RevealAndChooseCardsFromOpponentHandEffect extends UnrespondableEffect {
|
||||||
|
private String _playerId;
|
||||||
|
private String _opponentId;
|
||||||
|
private Filter _selectionFilter;
|
||||||
|
private int _minChosen;
|
||||||
|
private int _maxChosen;
|
||||||
|
|
||||||
|
protected RevealAndChooseCardsFromOpponentHandEffect(String playerId, String opponentId, Filter selectionFilter, int minChosen, int maxChosen) {
|
||||||
|
_playerId = playerId;
|
||||||
|
_opponentId = opponentId;
|
||||||
|
_selectionFilter = selectionFilter;
|
||||||
|
_minChosen = minChosen;
|
||||||
|
_maxChosen = maxChosen;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void playEffect(LotroGame game) {
|
||||||
|
List<PhysicalCard> opponentHand = new LinkedList<PhysicalCard>(game.getGameState().getHand(_opponentId));
|
||||||
|
List<PhysicalCard> selectable = Filters.filter(opponentHand, game.getGameState(), game.getModifiersQuerying(), _selectionFilter);
|
||||||
|
|
||||||
|
game.getUserFeedback().sendAwaitingDecision(_playerId,
|
||||||
|
new ArbitraryCardsSelectionDecision(1, "Opponent's hand", opponentHand, 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);
|
||||||
|
}
|
||||||
@@ -3,8 +3,8 @@ package com.gempukku.lotro.cards.set1.elven;
|
|||||||
import com.gempukku.lotro.cards.AbstractEvent;
|
import com.gempukku.lotro.cards.AbstractEvent;
|
||||||
import com.gempukku.lotro.cards.actions.PlayEventAction;
|
import com.gempukku.lotro.cards.actions.PlayEventAction;
|
||||||
import com.gempukku.lotro.cards.effects.ChooseAndExertCharacterEffect;
|
import com.gempukku.lotro.cards.effects.ChooseAndExertCharacterEffect;
|
||||||
import com.gempukku.lotro.cards.effects.ChooseArbitraryCardsEffect;
|
|
||||||
import com.gempukku.lotro.cards.effects.ChooseOpponentEffect;
|
import com.gempukku.lotro.cards.effects.ChooseOpponentEffect;
|
||||||
|
import com.gempukku.lotro.cards.effects.RevealAndChooseCardsFromOpponentHandEffect;
|
||||||
import com.gempukku.lotro.common.*;
|
import com.gempukku.lotro.common.*;
|
||||||
import com.gempukku.lotro.filters.Filters;
|
import com.gempukku.lotro.filters.Filters;
|
||||||
import com.gempukku.lotro.game.PhysicalCard;
|
import com.gempukku.lotro.game.PhysicalCard;
|
||||||
@@ -47,13 +47,11 @@ public class Card1_044 extends AbstractEvent {
|
|||||||
new ChooseOpponentEffect(playerId) {
|
new ChooseOpponentEffect(playerId) {
|
||||||
@Override
|
@Override
|
||||||
protected void opponentChosen(String opponentId) {
|
protected void opponentChosen(String opponentId) {
|
||||||
List<? extends PhysicalCard> hand = game.getGameState().getHand(opponentId);
|
action.addEffect(
|
||||||
List<PhysicalCard> isengardMinions = Filters.filter(hand, game.getGameState(), game.getModifiersQuerying(), Filters.culture(Culture.ISENGARD), Filters.type(CardType.MINION));
|
new RevealAndChooseCardsFromOpponentHandEffect(playerId, opponentId, Filters.and(Filters.culture(Culture.ISENGARD), Filters.type(CardType.MINION)), 1, 1) {
|
||||||
action.addCost(
|
|
||||||
new ChooseArbitraryCardsEffect(playerId, "Choose ISENGARD minion to discard", isengardMinions, 1, 1) {
|
|
||||||
@Override
|
@Override
|
||||||
protected void cardsSelected(List<PhysicalCard> card) {
|
protected void cardsSelected(List<PhysicalCard> selectedCards) {
|
||||||
action.addEffect(new DiscardCardFromHandEffect(card.get(0)));
|
action.addEffect(new DiscardCardFromHandEffect(selectedCards.get(0)));
|
||||||
action.addEffect(new DrawCardEffect(playerId));
|
action.addEffect(new DrawCardEffect(playerId));
|
||||||
action.addEffect(new DrawCardEffect(playerId));
|
action.addEffect(new DrawCardEffect(playerId));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package com.gempukku.lotro.cards.set1.site;
|
|||||||
import com.gempukku.lotro.cards.AbstractSite;
|
import com.gempukku.lotro.cards.AbstractSite;
|
||||||
import com.gempukku.lotro.cards.PlayConditions;
|
import com.gempukku.lotro.cards.PlayConditions;
|
||||||
import com.gempukku.lotro.cards.effects.ChooseAndExertCharacterEffect;
|
import com.gempukku.lotro.cards.effects.ChooseAndExertCharacterEffect;
|
||||||
import com.gempukku.lotro.cards.effects.ChooseArbitraryCardsEffect;
|
|
||||||
import com.gempukku.lotro.cards.effects.ChooseOpponentEffect;
|
import com.gempukku.lotro.cards.effects.ChooseOpponentEffect;
|
||||||
|
import com.gempukku.lotro.cards.effects.RevealAndChooseCardsFromOpponentHandEffect;
|
||||||
import com.gempukku.lotro.common.Keyword;
|
import com.gempukku.lotro.common.Keyword;
|
||||||
import com.gempukku.lotro.common.Phase;
|
import com.gempukku.lotro.common.Phase;
|
||||||
import com.gempukku.lotro.filters.Filters;
|
import com.gempukku.lotro.filters.Filters;
|
||||||
@@ -14,7 +14,6 @@ import com.gempukku.lotro.logic.actions.DefaultCostToEffectAction;
|
|||||||
import com.gempukku.lotro.logic.timing.Action;
|
import com.gempukku.lotro.logic.timing.Action;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,10 +42,10 @@ public class Card1_351 extends AbstractSite {
|
|||||||
@Override
|
@Override
|
||||||
protected void opponentChosen(String opponentId) {
|
protected void opponentChosen(String opponentId) {
|
||||||
action.addEffect(
|
action.addEffect(
|
||||||
new ChooseArbitraryCardsEffect(playerId, "Opponent's hand", new LinkedList<PhysicalCard>(game.getGameState().getHand(opponentId)), 0, 0) {
|
new RevealAndChooseCardsFromOpponentHandEffect(playerId, opponentId, Filters.none(), 0, 0) {
|
||||||
@Override
|
@Override
|
||||||
protected void cardsSelected(List<PhysicalCard> selectedCards) {
|
protected void cardsSelected(List<PhysicalCard> selectedCards) {
|
||||||
// TODO - Reveal hand
|
// Do nothing, it's just to reveal
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,6 +79,15 @@ public class Filters {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Filter none() {
|
||||||
|
return new Filter() {
|
||||||
|
@Override
|
||||||
|
public boolean accepts(GameState gameState, ModifiersQuerying modifiersQuerying, PhysicalCard physicalCard) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public static Filter signet(final Signet signet) {
|
public static Filter signet(final Signet signet) {
|
||||||
return new Filter() {
|
return new Filter() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public abstract class ArbitraryCardsSelectionDecision extends AbstractAwaitingDecision {
|
public abstract class ArbitraryCardsSelectionDecision extends AbstractAwaitingDecision {
|
||||||
private List<PhysicalCard> _physicalCards;
|
private List<PhysicalCard> _physicalCards;
|
||||||
|
private List<PhysicalCard> _selectable;
|
||||||
private int _minimum;
|
private int _minimum;
|
||||||
private int _maximum;
|
private int _maximum;
|
||||||
|
|
||||||
@@ -15,14 +16,27 @@ public abstract class ArbitraryCardsSelectionDecision extends AbstractAwaitingDe
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ArbitraryCardsSelectionDecision(int id, String text, List<PhysicalCard> physicalCards, int minimum, int maximum) {
|
public ArbitraryCardsSelectionDecision(int id, String text, List<PhysicalCard> physicalCards, int minimum, int maximum) {
|
||||||
|
this(id, text, physicalCards, physicalCards, minimum, maximum);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArbitraryCardsSelectionDecision(int id, String text, List<PhysicalCard> physicalCards, List<PhysicalCard> selectable, int minimum, int maximum) {
|
||||||
super(id, text, AwaitingDecisionType.ARBITRARY_CARDS);
|
super(id, text, AwaitingDecisionType.ARBITRARY_CARDS);
|
||||||
_physicalCards = physicalCards;
|
_physicalCards = physicalCards;
|
||||||
|
_selectable = selectable;
|
||||||
_minimum = minimum;
|
_minimum = minimum;
|
||||||
_maximum = maximum;
|
_maximum = maximum;
|
||||||
setParam("min", String.valueOf(minimum));
|
setParam("min", String.valueOf(minimum));
|
||||||
setParam("max", String.valueOf(maximum));
|
setParam("max", String.valueOf(maximum));
|
||||||
setParam("cardId", getCardIds(physicalCards));
|
setParam("cardId", getCardIds(physicalCards));
|
||||||
setParam("blueprintId", getBlueprintIds(physicalCards));
|
setParam("blueprintId", getBlueprintIds(physicalCards));
|
||||||
|
setParam("selectable", getSelectable(physicalCards, selectable));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String[] getSelectable(List<PhysicalCard> physicalCards, List<PhysicalCard> selectable) {
|
||||||
|
String[] result = new String[physicalCards.size()];
|
||||||
|
for (int i = 0; i < physicalCards.size(); i++)
|
||||||
|
result[i] = String.valueOf(selectable.contains(physicalCards.get(i)));
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] getCardIds(List<PhysicalCard> physicalCards) {
|
private String[] getCardIds(List<PhysicalCard> physicalCards) {
|
||||||
@@ -53,7 +67,7 @@ public abstract class ArbitraryCardsSelectionDecision extends AbstractAwaitingDe
|
|||||||
try {
|
try {
|
||||||
for (String cardId : cardIds) {
|
for (String cardId : cardIds) {
|
||||||
PhysicalCard card = _physicalCards.get(Integer.parseInt(cardId.substring(4)));
|
PhysicalCard card = _physicalCards.get(Integer.parseInt(cardId.substring(4)));
|
||||||
if (result.contains(card))
|
if (result.contains(card) || !_selectable.contains(card))
|
||||||
throw new DecisionResultInvalidException();
|
throw new DecisionResultInvalidException();
|
||||||
result.add(card);
|
result.add(card);
|
||||||
}
|
}
|
||||||
@@ -66,3 +80,4 @@ public abstract class ArbitraryCardsSelectionDecision extends AbstractAwaitingDe
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -625,11 +625,14 @@ var GempLotrGameUI = Class.extend({
|
|||||||
var max = this.getDecisionParameter(decision, "max");
|
var max = this.getDecisionParameter(decision, "max");
|
||||||
var cardIds = this.getDecisionParameters(decision, "cardId");
|
var cardIds = this.getDecisionParameters(decision, "cardId");
|
||||||
var blueprintIds = this.getDecisionParameters(decision, "blueprintId");
|
var blueprintIds = this.getDecisionParameters(decision, "blueprintId");
|
||||||
|
var selectable = this.getDecisionParameters(decision, "selectable");
|
||||||
|
|
||||||
var that = this;
|
var that = this;
|
||||||
|
|
||||||
var selectedCardIds = new Array();
|
var selectedCardIds = new Array();
|
||||||
|
|
||||||
|
var selectableCardIds = new Array();
|
||||||
|
|
||||||
this.dialogInstance
|
this.dialogInstance
|
||||||
.html("<div id='arbitraryChoice'></div>")
|
.html("<div id='arbitraryChoice'></div>")
|
||||||
.dialog("option", "title", text)
|
.dialog("option", "title", text)
|
||||||
@@ -652,6 +655,9 @@ var GempLotrGameUI = Class.extend({
|
|||||||
var cardId = cardIds[i];
|
var cardId = cardIds[i];
|
||||||
var blueprintId = blueprintIds[i];
|
var blueprintId = blueprintIds[i];
|
||||||
|
|
||||||
|
if (selectable[i] == "true")
|
||||||
|
selectableCardIds.push(cardId);
|
||||||
|
|
||||||
var card = new Card(blueprintId, "SPECIAL", cardId, this.selfParticipantId);
|
var card = new Card(blueprintId, "SPECIAL", cardId, this.selfParticipantId);
|
||||||
|
|
||||||
var cardDiv = this.createCardDiv(card);
|
var cardDiv = this.createCardDiv(card);
|
||||||
@@ -681,7 +687,7 @@ var GempLotrGameUI = Class.extend({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.attachSelectionFunctions(cardIds);
|
this.attachSelectionFunctions(selectableCardIds);
|
||||||
|
|
||||||
this.specialGroup.setBounds(10, 10, 547, 188);
|
this.specialGroup.setBounds(10, 10, 547, 188);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user