mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Prevent passing GameObject instances to gui via SGuiChoose dialog
Fix so scry cards can appear in card picture pane
This commit is contained in:
@@ -18,6 +18,7 @@ import forge.game.card.CardView;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.cost.*;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.SpellAbilityStackInstance;
|
||||
import forge.game.zone.ZoneType;
|
||||
@@ -297,7 +298,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
||||
if (nNeeded == 0) {
|
||||
return PaymentDecision.number(0);
|
||||
}
|
||||
final Player p = SGuiChoose.oneOrNone(String.format("Exile from whose %s?", cost.getFrom()), payableZone);
|
||||
final Player p = Player.get(SGuiChoose.oneOrNone(String.format("Exile from whose %s?", cost.getFrom()), PlayerView.getCollection(payableZone)));
|
||||
if (p == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -308,8 +309,8 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<Card> toExile = SGuiChoose.many("Exile from " + cost.getFrom(), "To be exiled", count - nNeeded, typeList, null);
|
||||
return PaymentDecision.card(new CardCollection(toExile));
|
||||
CardCollection toExile = Card.getList(SGuiChoose.many("Exile from " + cost.getFrom(), "To be exiled", count - nNeeded, CardView.getCollection(typeList), null));
|
||||
return PaymentDecision.card(toExile);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -388,7 +389,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
||||
|
||||
CardCollection exiled = new CardCollection();
|
||||
for (int i = 0; i < nNeeded; i++) {
|
||||
final Card c = SGuiChoose.oneOrNone("Exile from " + cost.getFrom(), typeList);
|
||||
final Card c = Card.get(SGuiChoose.oneOrNone("Exile from " + cost.getFrom(), CardView.getCollection(typeList)));
|
||||
if (c == null) { return null; }
|
||||
|
||||
typeList.remove(c);
|
||||
@@ -417,8 +418,8 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
||||
if (list.size() < c) {
|
||||
return null;
|
||||
}
|
||||
final List<Card> choice = SGuiChoose.many("Choose an exiled card to put into graveyard", "To graveyard", c, list, CardView.get(source));
|
||||
return PaymentDecision.card(new CardCollection(choice));
|
||||
final CardCollection choice = Card.getList(SGuiChoose.many("Choose an exiled card to put into graveyard", "To graveyard", c, CardView.getCollection(list), CardView.get(source)));
|
||||
return PaymentDecision.card(choice);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -489,7 +490,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(source.getName()).append(" - Choose an opponent to gain ").append(c).append(" life:");
|
||||
|
||||
final Player chosenToGain = SGuiChoose.oneOrNone(sb.toString(), oppsThatCanGainLife);
|
||||
final Player chosenToGain = Player.get(SGuiChoose.oneOrNone(sb.toString(), PlayerView.getCollection(oppsThatCanGainLife)));
|
||||
if (chosenToGain == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -599,7 +600,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
||||
|
||||
CardCollection chosen = new CardCollection();
|
||||
for (int i = 0; i < nNeeded; i++) {
|
||||
final Card c = SGuiChoose.oneOrNone("Put from " + fromZone + " to library", typeList);
|
||||
final Card c = Card.get(SGuiChoose.oneOrNone("Put from " + fromZone + " to library", CardView.getCollection(typeList)));
|
||||
if (c == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -614,7 +615,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
||||
return PaymentDecision.number(0);
|
||||
}
|
||||
|
||||
final Player p = SGuiChoose.oneOrNone(String.format("Put cards from whose %s?", fromZone), payableZone);
|
||||
final Player p = Player.get(SGuiChoose.oneOrNone(String.format("Put cards from whose %s?", fromZone), PlayerView.getCollection(payableZone)));
|
||||
if (p == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -626,7 +627,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
||||
|
||||
CardCollection chosen = new CardCollection();
|
||||
for (int i = 0; i < nNeeded; i++) {
|
||||
final Card c = SGuiChoose.oneOrNone("Put cards from " + fromZone + " to Library", typeList);
|
||||
final Card c = Card.get(SGuiChoose.oneOrNone("Put cards from " + fromZone + " to Library", CardView.getCollection(typeList)));
|
||||
if (c == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -946,8 +947,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
|
||||
}
|
||||
}
|
||||
|
||||
final CardView view = SGuiChoose.oneOrNone("Remove counter(s) from a card in " + cost.zone, suspended);
|
||||
final Card card = Card.get(view);
|
||||
final Card card = Card.get(SGuiChoose.oneOrNone("Remove counter(s) from a card in " + cost.zone, suspended));
|
||||
return null == card ? null : PaymentDecision.card(card, c);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import forge.game.cost.*;
|
||||
import forge.game.mana.ManaCostAdjustment;
|
||||
import forge.game.mana.ManaCostBeingPaid;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerView;
|
||||
import forge.game.spellability.Ability;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
@@ -489,7 +490,7 @@ public class HumanPlay {
|
||||
}
|
||||
// replace this with input
|
||||
for (int i = 0; i < nNeeded; i++) {
|
||||
final Card c = SGuiChoose.oneOrNone("Exile from " + from, list);
|
||||
final Card c = Card.get(SGuiChoose.oneOrNone("Exile from " + from, CardView.getCollection(list)));
|
||||
if (c == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -523,7 +524,7 @@ public class HumanPlay {
|
||||
payableZone.add(player);
|
||||
}
|
||||
}
|
||||
Player chosen = SGuiChoose.oneOrNone(String.format("Put cards from whose %s?", from), payableZone);
|
||||
Player chosen = Player.get(SGuiChoose.oneOrNone(String.format("Put cards from whose %s?", from), PlayerView.getCollection(payableZone)));
|
||||
if (chosen == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -535,7 +536,7 @@ public class HumanPlay {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Card c = SGuiChoose.oneOrNone("Put cards to Library", typeList);
|
||||
final Card c = Card.get(SGuiChoose.oneOrNone("Put cards to Library", CardView.getCollection(typeList)));
|
||||
|
||||
if (c != null) {
|
||||
typeList.remove(c);
|
||||
|
||||
@@ -377,10 +377,10 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
}
|
||||
|
||||
tempShowCards(sourceList);
|
||||
final List<CardView> choices = SGuiChoose.many(title, "Chosen Cards", min, max, CardView.getCollection(sourceList), CardView.get(sa.getHostCard()));
|
||||
final CardCollection choices = Card.getList(SGuiChoose.many(title, "Chosen Cards", min, max, CardView.getCollection(sourceList), CardView.get(sa.getHostCard())));
|
||||
endTempShowCards();
|
||||
|
||||
return Card.getList(choices);
|
||||
return choices;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -530,24 +530,21 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
public CardCollection orderBlockers(final Card attacker, final CardCollection blockers) {
|
||||
final CardView vAttacker = CardView.get(attacker);
|
||||
MatchUtil.getController().setPanelSelection(vAttacker);
|
||||
final List<CardView> choices = SGuiChoose.order("Choose Damage Order for " + vAttacker, "Damaged First", CardView.getCollection(blockers), vAttacker);
|
||||
return Card.getList(choices);
|
||||
return Card.getList(SGuiChoose.order("Choose Damage Order for " + vAttacker, "Damaged First", CardView.getCollection(blockers), vAttacker));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardCollection orderBlocker(final Card attacker, final Card blocker, final CardCollection oldBlockers) {
|
||||
final CardView vAttacker = CardView.get(attacker);
|
||||
MatchUtil.getController().setPanelSelection(vAttacker);
|
||||
final List<CardView> choices = SGuiChoose.insertInList("Choose blocker after which to place " + vAttacker + " in damage order; cancel to place it first", CardView.get(blocker), CardView.getCollection(oldBlockers));
|
||||
return Card.getList(choices);
|
||||
return Card.getList(SGuiChoose.insertInList("Choose blocker after which to place " + vAttacker + " in damage order; cancel to place it first", CardView.get(blocker), CardView.getCollection(oldBlockers)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardCollection orderAttackers(final Card blocker, final CardCollection attackers) {
|
||||
final CardView vBlocker = CardView.get(blocker);
|
||||
MatchUtil.getController().setPanelSelection(vBlocker);
|
||||
final List<CardView> choices = SGuiChoose.order("Choose Damage Order for " + vBlocker, "Damaged First", CardView.getCollection(attackers), vBlocker);
|
||||
return Card.getList(choices);
|
||||
return Card.getList(SGuiChoose.order("Choose Damage Order for " + vBlocker, "Damaged First", CardView.getCollection(attackers), vBlocker));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -585,7 +582,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
}
|
||||
}
|
||||
else {
|
||||
toBottom = new CardCollection(SGuiChoose.many("Select cards to be put on the bottom of your library", "Cards to put on the bottom", -1, topN, null));
|
||||
toBottom = Card.getList(SGuiChoose.many("Select cards to be put on the bottom of your library", "Cards to put on the bottom", -1, CardView.getCollection(topN), null));
|
||||
topN.removeAll((Collection<?>)toBottom);
|
||||
if (topN.isEmpty()) {
|
||||
toTop = null;
|
||||
@@ -594,7 +591,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
toTop = topN;
|
||||
}
|
||||
else {
|
||||
toTop = new CardCollection(SGuiChoose.order("Arrange cards to be put on top of your library", "Cards arranged", topN, null));
|
||||
toTop = Card.getList(SGuiChoose.order("Arrange cards to be put on top of your library", "Cards arranged", CardView.getCollection(topN), null));
|
||||
}
|
||||
}
|
||||
endTempShowCards();
|
||||
@@ -645,10 +642,10 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
public CardCollectionView chooseCardsToDiscardFrom(Player p, SpellAbility sa, CardCollection valid, int min, int max) {
|
||||
if (p != player) {
|
||||
tempShowCards(valid);
|
||||
final List<CardView> choices = SGuiChoose.many("Choose " + min + " card" + (min != 1 ? "s" : "") + " to discard",
|
||||
"Discarded", min, min, CardView.getCollection(valid), null);
|
||||
final CardCollection choices = Card.getList(SGuiChoose.many("Choose " + min + " card" + (min != 1 ? "s" : "") + " to discard",
|
||||
"Discarded", min, min, CardView.getCollection(valid), null));
|
||||
endTempShowCards();
|
||||
return Card.getList(choices);
|
||||
return choices;
|
||||
}
|
||||
|
||||
InputSelectCardsFromList inp = new InputSelectCardsFromList(this, min, max, valid);
|
||||
@@ -1648,8 +1645,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
|
||||
public void addCountersToPermanent() {
|
||||
final CardCollectionView cards = game.getCardsIn(ZoneType.Battlefield);
|
||||
final CardView cardView = SGuiChoose.oneOrNone("Add counters to which card?", CardView.getCollection(cards));
|
||||
final Card card = Card.get(cardView);
|
||||
final Card card = Card.get(SGuiChoose.oneOrNone("Add counters to which card?", CardView.getCollection(cards)));
|
||||
if (card == null) { return; }
|
||||
|
||||
final CounterType counter = SGuiChoose.oneOrNone("Which type of counter?", CounterType.values());
|
||||
@@ -1698,7 +1694,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
}
|
||||
|
||||
public void setPlayerLife() {
|
||||
final Player player = SGuiChoose.oneOrNone("Set life for which player?", (FCollection<Player>)game.getPlayers());
|
||||
final Player player = Player.get(SGuiChoose.oneOrNone("Set life for which player?", PlayerView.getCollection(game.getPlayers())));
|
||||
if (player == null) { return; }
|
||||
|
||||
final Integer life = SGuiChoose.getInteger("Set life to what?", 0);
|
||||
@@ -1728,7 +1724,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
}
|
||||
|
||||
public void addCardToHand() {
|
||||
final Player p = SGuiChoose.oneOrNone("Put card in hand for which player?", (FCollection<Player>)game.getPlayers());
|
||||
final Player p = Player.get(SGuiChoose.oneOrNone("Put card in hand for which player?", PlayerView.getCollection(game.getPlayers())));
|
||||
if (p == null) {
|
||||
return;
|
||||
}
|
||||
@@ -1796,7 +1792,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
}
|
||||
|
||||
public void riggedPlanarRoll() {
|
||||
final Player player = SGuiChoose.oneOrNone("Which player should roll?", (FCollection<Player>)game.getPlayers());
|
||||
final Player player = Player.get(SGuiChoose.oneOrNone("Which player should roll?", PlayerView.getCollection(game.getPlayers())));
|
||||
if (player == null) { return; }
|
||||
|
||||
final PlanarDice res = SGuiChoose.oneOrNone("Choose result", PlanarDice.values());
|
||||
|
||||
Reference in New Issue
Block a user