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.actions.PlayEventAction;
|
||||
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.RevealAndChooseCardsFromOpponentHandEffect;
|
||||
import com.gempukku.lotro.common.*;
|
||||
import com.gempukku.lotro.filters.Filters;
|
||||
import com.gempukku.lotro.game.PhysicalCard;
|
||||
@@ -47,13 +47,11 @@ public class Card1_044 extends AbstractEvent {
|
||||
new ChooseOpponentEffect(playerId) {
|
||||
@Override
|
||||
protected void opponentChosen(String opponentId) {
|
||||
List<? extends PhysicalCard> hand = game.getGameState().getHand(opponentId);
|
||||
List<PhysicalCard> isengardMinions = Filters.filter(hand, game.getGameState(), game.getModifiersQuerying(), Filters.culture(Culture.ISENGARD), Filters.type(CardType.MINION));
|
||||
action.addCost(
|
||||
new ChooseArbitraryCardsEffect(playerId, "Choose ISENGARD minion to discard", isengardMinions, 1, 1) {
|
||||
action.addEffect(
|
||||
new RevealAndChooseCardsFromOpponentHandEffect(playerId, opponentId, Filters.and(Filters.culture(Culture.ISENGARD), Filters.type(CardType.MINION)), 1, 1) {
|
||||
@Override
|
||||
protected void cardsSelected(List<PhysicalCard> card) {
|
||||
action.addEffect(new DiscardCardFromHandEffect(card.get(0)));
|
||||
protected void cardsSelected(List<PhysicalCard> selectedCards) {
|
||||
action.addEffect(new DiscardCardFromHandEffect(selectedCards.get(0)));
|
||||
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.PlayConditions;
|
||||
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.RevealAndChooseCardsFromOpponentHandEffect;
|
||||
import com.gempukku.lotro.common.Keyword;
|
||||
import com.gempukku.lotro.common.Phase;
|
||||
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 java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -43,10 +42,10 @@ public class Card1_351 extends AbstractSite {
|
||||
@Override
|
||||
protected void opponentChosen(String opponentId) {
|
||||
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
|
||||
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) {
|
||||
return new Filter() {
|
||||
@Override
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.List;
|
||||
|
||||
public abstract class ArbitraryCardsSelectionDecision extends AbstractAwaitingDecision {
|
||||
private List<PhysicalCard> _physicalCards;
|
||||
private List<PhysicalCard> _selectable;
|
||||
private int _minimum;
|
||||
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) {
|
||||
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);
|
||||
_physicalCards = physicalCards;
|
||||
_selectable = selectable;
|
||||
_minimum = minimum;
|
||||
_maximum = maximum;
|
||||
setParam("min", String.valueOf(minimum));
|
||||
setParam("max", String.valueOf(maximum));
|
||||
setParam("cardId", getCardIds(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) {
|
||||
@@ -53,7 +67,7 @@ public abstract class ArbitraryCardsSelectionDecision extends AbstractAwaitingDe
|
||||
try {
|
||||
for (String cardId : cardIds) {
|
||||
PhysicalCard card = _physicalCards.get(Integer.parseInt(cardId.substring(4)));
|
||||
if (result.contains(card))
|
||||
if (result.contains(card) || !_selectable.contains(card))
|
||||
throw new DecisionResultInvalidException();
|
||||
result.add(card);
|
||||
}
|
||||
@@ -66,3 +80,4 @@ public abstract class ArbitraryCardsSelectionDecision extends AbstractAwaitingDe
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ var GempLotrGameUI = Class.extend({
|
||||
if (event.which == 1) {
|
||||
if (event.shiftKey) {
|
||||
that.displayCardInfo(selectedCardElem.data("card"));
|
||||
} else if (selectedCardElem.hasClass("selectableCard"))
|
||||
} else if (selectedCardElem.hasClass("selectableCard"))
|
||||
that.selectionFunction(selectedCardElem.data("card").cardId);
|
||||
}
|
||||
}
|
||||
@@ -153,52 +153,52 @@ var GempLotrGameUI = Class.extend({
|
||||
initializeDialogs: function() {
|
||||
this.dialogInstance = $("<div></div>")
|
||||
.dialog({
|
||||
autoOpen: false,
|
||||
closeOnEscape: false,
|
||||
resizable: false,
|
||||
minHeight: 80
|
||||
});
|
||||
autoOpen: false,
|
||||
closeOnEscape: false,
|
||||
resizable: false,
|
||||
minHeight: 80
|
||||
});
|
||||
|
||||
this.assignmentDialog = $("<div></div>")
|
||||
.dialog({
|
||||
autoOpen: false,
|
||||
closeOnEscape: false,
|
||||
title: "Assignments",
|
||||
resizable: true,
|
||||
minHeight: 240,
|
||||
minWidth: 400,
|
||||
width: 500,
|
||||
height: 200,
|
||||
position: ["right", "bottom"]
|
||||
});
|
||||
autoOpen: false,
|
||||
closeOnEscape: false,
|
||||
title: "Assignments",
|
||||
resizable: true,
|
||||
minHeight: 240,
|
||||
minWidth: 400,
|
||||
width: 500,
|
||||
height: 200,
|
||||
position: ["right", "bottom"]
|
||||
});
|
||||
|
||||
this.skirmishDialog = $("<div></div>")
|
||||
.dialog({
|
||||
autoOpen: false,
|
||||
closeOnEscape: false,
|
||||
title: "Skirmish",
|
||||
resizable: true,
|
||||
minHeight: 240,
|
||||
minWidth: 400,
|
||||
width: 500,
|
||||
height: 200,
|
||||
position: ["right", "top"]
|
||||
});
|
||||
autoOpen: false,
|
||||
closeOnEscape: false,
|
||||
title: "Skirmish",
|
||||
resizable: true,
|
||||
minHeight: 240,
|
||||
minWidth: 400,
|
||||
width: 500,
|
||||
height: 200,
|
||||
position: ["right", "top"]
|
||||
});
|
||||
|
||||
$(".ui-dialog-titlebar-close").hide();
|
||||
|
||||
this.infoDialog = $("<div></div>")
|
||||
.dialog({
|
||||
autoOpen: false,
|
||||
closeOnEscape: true,
|
||||
resizable: false,
|
||||
title: "Card information",
|
||||
minHeight: 80,
|
||||
minWidth: 200,
|
||||
width: 600,
|
||||
height: 300,
|
||||
maxHeight: 300
|
||||
});
|
||||
autoOpen: false,
|
||||
closeOnEscape: true,
|
||||
resizable: false,
|
||||
title: "Card information",
|
||||
minHeight: 80,
|
||||
minWidth: 200,
|
||||
width: 600,
|
||||
height: 300,
|
||||
maxHeight: 300
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
@@ -538,13 +538,13 @@ var GempLotrGameUI = Class.extend({
|
||||
this.dialogInstance
|
||||
.html(text + "<br /><input id='integerDecision' type='text' value='0'>")
|
||||
.dialog("option", "buttons",
|
||||
{
|
||||
"OK": function() {
|
||||
$(this).dialog("close");
|
||||
that.decisionFunction(id, $("#integerDecision").val());
|
||||
}
|
||||
}
|
||||
)
|
||||
{
|
||||
"OK": function() {
|
||||
$(this).dialog("close");
|
||||
that.decisionFunction(id, $("#integerDecision").val());
|
||||
}
|
||||
}
|
||||
)
|
||||
.dialog("option", "width", "400")
|
||||
.dialog("option", "height", "auto");
|
||||
;
|
||||
@@ -578,13 +578,13 @@ var GempLotrGameUI = Class.extend({
|
||||
this.dialogInstance
|
||||
.html(html)
|
||||
.dialog("option", "buttons",
|
||||
{
|
||||
"OK": function() {
|
||||
$(this).dialog("close");
|
||||
that.decisionFunction(id, $("#multipleChoiceDecision").val());
|
||||
}
|
||||
}
|
||||
)
|
||||
{
|
||||
"OK": function() {
|
||||
$(this).dialog("close");
|
||||
that.decisionFunction(id, $("#multipleChoiceDecision").val());
|
||||
}
|
||||
}
|
||||
)
|
||||
.dialog("option", "width", "400")
|
||||
.dialog("option", "height", "auto");
|
||||
|
||||
@@ -625,11 +625,14 @@ var GempLotrGameUI = Class.extend({
|
||||
var max = this.getDecisionParameter(decision, "max");
|
||||
var cardIds = this.getDecisionParameters(decision, "cardId");
|
||||
var blueprintIds = this.getDecisionParameters(decision, "blueprintId");
|
||||
var selectable = this.getDecisionParameters(decision, "selectable");
|
||||
|
||||
var that = this;
|
||||
|
||||
var selectedCardIds = new Array();
|
||||
|
||||
var selectableCardIds = new Array();
|
||||
|
||||
this.dialogInstance
|
||||
.html("<div id='arbitraryChoice'></div>")
|
||||
.dialog("option", "title", text)
|
||||
@@ -652,6 +655,9 @@ var GempLotrGameUI = Class.extend({
|
||||
var cardId = cardIds[i];
|
||||
var blueprintId = blueprintIds[i];
|
||||
|
||||
if (selectable[i] == "true")
|
||||
selectableCardIds.push(cardId);
|
||||
|
||||
var card = new Card(blueprintId, "SPECIAL", cardId, this.selfParticipantId);
|
||||
|
||||
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);
|
||||
|
||||
@@ -911,13 +917,13 @@ var GempLotrGameUI = Class.extend({
|
||||
|
||||
if (this.shadowAssignGroups[characterId] == null) {
|
||||
this.shadowAssignGroups[characterId] = new NormalCardGroup(null, this.assignmentDialog, function (card) {
|
||||
return (card.zone == "SHADOW_CHARACTERS" && card.assign == characterId);
|
||||
}
|
||||
);
|
||||
return (card.zone == "SHADOW_CHARACTERS" && card.assign == characterId);
|
||||
}
|
||||
);
|
||||
this.freePeopleAssignGroups[characterId] = new NormalCardGroup(null, this.assignmentDialog, function (card) {
|
||||
return (card.cardId == characterId);
|
||||
}
|
||||
);
|
||||
return (card.cardId == characterId);
|
||||
}
|
||||
);
|
||||
|
||||
this.moveCardToElement(characterId, this.assignmentDialog);
|
||||
this.assignDialogResized();
|
||||
|
||||
Reference in New Issue
Block a user