mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
Flesh out Dev pane
This commit is contained in:
@@ -1,11 +1,18 @@
|
||||
package forge.screens.match;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
@@ -14,6 +21,7 @@ import com.google.common.eventbus.Subscribe;
|
||||
|
||||
import forge.FThreads;
|
||||
import forge.Forge;
|
||||
import forge.card.CardCharacteristicName;
|
||||
import forge.game.Game;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.GameRules;
|
||||
@@ -21,6 +29,7 @@ import forge.game.GameType;
|
||||
import forge.game.Match;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.card.CardPredicates.Presets;
|
||||
import forge.game.combat.Combat;
|
||||
import forge.game.combat.CombatUtil;
|
||||
@@ -29,6 +38,7 @@ import forge.game.phase.PhaseType;
|
||||
import forge.game.player.LobbyPlayer;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.RegisteredPlayer;
|
||||
import forge.game.trigger.TriggerType;
|
||||
import forge.game.zone.Zone;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.model.FModel;
|
||||
@@ -501,4 +511,178 @@ public class FControl {
|
||||
evt.visit(this);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setupGameState(String filename) {
|
||||
int humanLife = -1;
|
||||
int aiLife = -1;
|
||||
|
||||
final Map<ZoneType, String> humanCardTexts = new EnumMap<ZoneType, String>(ZoneType.class);
|
||||
final Map<ZoneType, String> aiCardTexts = new EnumMap<ZoneType, String>(ZoneType.class);
|
||||
|
||||
String tChangePlayer = "NONE";
|
||||
String tChangePhase = "NONE";
|
||||
|
||||
try {
|
||||
final FileInputStream fstream = new FileInputStream(filename);
|
||||
final DataInputStream in = new DataInputStream(fstream);
|
||||
final BufferedReader br = new BufferedReader(new InputStreamReader(in));
|
||||
|
||||
String temp = "";
|
||||
|
||||
while ((temp = br.readLine()) != null) {
|
||||
final String[] tempData = temp.split("=");
|
||||
if (tempData.length < 2 || temp.charAt(0) == '#') {
|
||||
continue;
|
||||
}
|
||||
|
||||
final String categoryName = tempData[0].toLowerCase();
|
||||
final String categoryValue = tempData[1];
|
||||
|
||||
switch (categoryName) {
|
||||
case "humanlife":
|
||||
humanLife = Integer.parseInt(categoryValue);
|
||||
break;
|
||||
case "ailife":
|
||||
aiLife = Integer.parseInt(categoryValue);
|
||||
break;
|
||||
case "activeplayer":
|
||||
tChangePlayer = categoryValue.trim().toLowerCase();
|
||||
break;
|
||||
case "activephase":
|
||||
tChangePhase = categoryValue;
|
||||
break;
|
||||
case "humancardsinplay":
|
||||
humanCardTexts.put(ZoneType.Battlefield, categoryValue);
|
||||
break;
|
||||
case "aicardsinplay":
|
||||
aiCardTexts.put(ZoneType.Battlefield, categoryValue);
|
||||
break;
|
||||
case "humancardsinhand":
|
||||
humanCardTexts.put(ZoneType.Hand, categoryValue);
|
||||
break;
|
||||
case "aicardsinhand":
|
||||
aiCardTexts.put(ZoneType.Hand, categoryValue);
|
||||
break;
|
||||
case "humancardsingraveyard":
|
||||
humanCardTexts.put(ZoneType.Graveyard, categoryValue);
|
||||
break;
|
||||
case "aicardsingraveyard":
|
||||
aiCardTexts.put(ZoneType.Graveyard, categoryValue);
|
||||
break;
|
||||
case "humancardsinlibrary":
|
||||
humanCardTexts.put(ZoneType.Library, categoryValue);
|
||||
break;
|
||||
case "aicardsinlibrary":
|
||||
aiCardTexts.put(ZoneType.Library, categoryValue);
|
||||
break;
|
||||
case "humancardsinexile":
|
||||
humanCardTexts.put(ZoneType.Exile, categoryValue);
|
||||
break;
|
||||
case "aicardsinexile":
|
||||
aiCardTexts.put(ZoneType.Exile, categoryValue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
in.close();
|
||||
}
|
||||
catch (final FileNotFoundException fnfe) {
|
||||
FOptionPane.showErrorDialog("File not found: " + filename);
|
||||
}
|
||||
catch (final Exception e) {
|
||||
FOptionPane.showErrorDialog("Error loading battle setup file!");
|
||||
return;
|
||||
}
|
||||
|
||||
setupGameState(humanLife, aiLife, humanCardTexts, aiCardTexts, tChangePlayer, tChangePhase);
|
||||
}
|
||||
|
||||
public static void setupGameState(final int humanLife, final int aiLife, final Map<ZoneType, String> humanCardTexts,
|
||||
final Map<ZoneType, String> aiCardTexts, final String tChangePlayer, final String tChangePhase) {
|
||||
|
||||
game.getAction().invoke(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final Player human = game.getPlayers().get(0);
|
||||
final Player ai = game.getPlayers().get(1);
|
||||
|
||||
Player newPlayerTurn = tChangePlayer.equals("human") ? newPlayerTurn = human : tChangePlayer.equals("ai") ? newPlayerTurn = ai : null;
|
||||
PhaseType newPhase = tChangePhase.trim().equalsIgnoreCase("none") ? null : PhaseType.smartValueOf(tChangePhase);
|
||||
|
||||
game.getPhaseHandler().devModeSet(newPhase, newPlayerTurn);
|
||||
|
||||
game.getTriggerHandler().suppressMode(TriggerType.ChangesZone);
|
||||
|
||||
setupPlayerState(humanLife, humanCardTexts, human);
|
||||
setupPlayerState(aiLife, aiCardTexts, ai);
|
||||
|
||||
game.getTriggerHandler().clearSuppression(TriggerType.ChangesZone);
|
||||
|
||||
game.getAction().checkStaticAbilities();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void setupPlayerState(int life, Map<ZoneType, String> cardTexts, final Player p) {
|
||||
Map<ZoneType, List<Card>> humanCards = new EnumMap<ZoneType, List<Card>>(ZoneType.class);
|
||||
for (Entry<ZoneType, String> kv : cardTexts.entrySet()) {
|
||||
humanCards.put(kv.getKey(), processCardsForZone(kv.getValue().split(";"), p));
|
||||
}
|
||||
|
||||
if (life > 0) {
|
||||
p.setLife(life, null);
|
||||
}
|
||||
|
||||
for (Entry<ZoneType, List<Card>> kv : humanCards.entrySet()) {
|
||||
if (kv.getKey() == ZoneType.Battlefield) {
|
||||
for (final Card c : kv.getValue()) {
|
||||
p.getZone(ZoneType.Hand).add(c);
|
||||
p.getGame().getAction().moveToPlay(c);
|
||||
c.setSickness(false);
|
||||
}
|
||||
}
|
||||
else {
|
||||
p.getZone(kv.getKey()).setCards(kv.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<Card> processCardsForZone(final String[] data, final Player player) {
|
||||
final List<Card> cl = new ArrayList<Card>();
|
||||
for (final String element : data) {
|
||||
final String[] cardinfo = element.trim().split("\\|");
|
||||
|
||||
final Card c = Card.fromPaperCard(FModel.getMagicDb().getCommonCards().getCard(cardinfo[0]), player);
|
||||
|
||||
boolean hasSetCurSet = false;
|
||||
for (final String info : cardinfo) {
|
||||
if (info.startsWith("Set:")) {
|
||||
c.setCurSetCode(info.substring(info.indexOf(':') + 1));
|
||||
hasSetCurSet = true;
|
||||
}
|
||||
else if (info.equalsIgnoreCase("Tapped:True")) {
|
||||
c.tap();
|
||||
}
|
||||
else if (info.startsWith("Counters:")) {
|
||||
final String[] counterStrings = info.substring(info.indexOf(':') + 1).split(",");
|
||||
for (final String counter : counterStrings) {
|
||||
c.addCounter(CounterType.valueOf(counter), 1, true);
|
||||
}
|
||||
}
|
||||
else if (info.equalsIgnoreCase("SummonSick:True")) {
|
||||
c.setSickness(true);
|
||||
}
|
||||
else if (info.equalsIgnoreCase("FaceDown:True")) {
|
||||
c.setState(CardCharacteristicName.FaceDown);
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasSetCurSet) {
|
||||
c.setCurSetCode(c.getMostRecentSet());
|
||||
}
|
||||
|
||||
cl.add(c);
|
||||
}
|
||||
return cl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,102 +1,151 @@
|
||||
package forge.screens.match.views;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.game.Game;
|
||||
import forge.game.GameType;
|
||||
import forge.game.PlanarDice;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CardPredicates;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.AbilityManaPart;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.item.PaperCard;
|
||||
import forge.model.FModel;
|
||||
import forge.net.FServer;
|
||||
import forge.player.HumanPlay;
|
||||
import forge.screens.match.FControl;
|
||||
import forge.screens.match.input.InputSelectCardsFromList;
|
||||
import forge.screens.match.views.VHeader.HeaderDropDown;
|
||||
import forge.toolbox.FFileChooser;
|
||||
import forge.toolbox.FLabel;
|
||||
import forge.toolbox.GuiChoose;
|
||||
import forge.toolbox.GuiDialog;
|
||||
import forge.utils.ForgePreferences;
|
||||
import forge.utils.ForgePreferences.FPref;
|
||||
|
||||
public class VDev extends HeaderDropDown {
|
||||
private static final float INSETS_FACTOR = 0.025f;
|
||||
private static final float GAP_FACTOR = 0.01f;
|
||||
|
||||
private List<DevLabel> devLabels = new ArrayList<DevLabel>();
|
||||
|
||||
public VDev() {
|
||||
final ForgePreferences prefs = FModel.getPreferences();
|
||||
boolean unlimitedLands = prefs.getPrefBoolean(FPref.DEV_UNLIMITED_LAND);
|
||||
|
||||
addDevLabel("Play Unlimited Lands: " + (unlimitedLands ? "Enabled" : "Disabled"), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
}, true, unlimitedLands);
|
||||
addDevLabel("Generate Mana", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
});
|
||||
addDevLabel("Setup Game State", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
generateMana();
|
||||
}
|
||||
});
|
||||
addDevLabel("Tutor for Card", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
});
|
||||
addDevLabel("Add Counter to Permanent", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
});
|
||||
addDevLabel("Tap Permanent", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
});
|
||||
addDevLabel("Untap Permanent", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
}
|
||||
});
|
||||
addDevLabel("Set Player Life", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
tutorForCard();
|
||||
}
|
||||
});
|
||||
addDevLabel("Add card to play", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
addCardToBattlefield();
|
||||
}
|
||||
});
|
||||
addDevLabel("Add card to hand", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
addCardToHand();
|
||||
}
|
||||
});
|
||||
addDevLabel("Set Player Life", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setPlayerLife();
|
||||
}
|
||||
});
|
||||
addDevLabel("Setup Game State", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final FFileChooser fc = new FFileChooser();
|
||||
if (!fc.show("Select Game State File")) {
|
||||
return;
|
||||
}
|
||||
|
||||
FControl.setupGameState(fc.getSelectedFile().getAbsolutePath());
|
||||
}
|
||||
});
|
||||
|
||||
final ForgePreferences prefs = FModel.getPreferences();
|
||||
boolean unlimitedLands = prefs.getPrefBoolean(FPref.DEV_UNLIMITED_LAND);
|
||||
final DevLabel lblUnlimitedLands = addDevLabel("Play Unlimited Lands: " +
|
||||
(unlimitedLands ? "On" : "Off"), null, true, unlimitedLands);
|
||||
lblUnlimitedLands.setCommand(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
boolean unlimitedLands = lblUnlimitedLands.isSelected();
|
||||
lblUnlimitedLands.setText("Play Unlimited Lands: " +
|
||||
(unlimitedLands ? "On" : "Off"));
|
||||
|
||||
for (Player p : FControl.getGame().getPlayers()) {
|
||||
if (p.getLobbyPlayer() == FServer.getLobby().getGuiPlayer() ) {
|
||||
p.canCheatPlayUnlimitedLands = unlimitedLands;
|
||||
}
|
||||
}
|
||||
// probably will need to call a synchronized method to have the game thread see changed value of the variable
|
||||
|
||||
prefs.setPref(FPref.DEV_UNLIMITED_LAND, String.valueOf(unlimitedLands));
|
||||
prefs.save();
|
||||
}
|
||||
});
|
||||
|
||||
addDevLabel("Add Counter to Permanent", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
addCounterToPermanent();
|
||||
}
|
||||
});
|
||||
addDevLabel("Tap Permanent", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
tapPermanent();
|
||||
}
|
||||
});
|
||||
addDevLabel("Untap Permanent", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
untapPermanent();
|
||||
}
|
||||
});
|
||||
addDevLabel("Rigged planar roll", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
riggedPlanarRoll();
|
||||
}
|
||||
});
|
||||
addDevLabel("Planeswalk to", new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
planeswalkTo();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addDevLabel(final String text0, final Runnable command0) {
|
||||
addDevLabel(text0, command0, false, false);
|
||||
private DevLabel addDevLabel(final String text0, final Runnable command0) {
|
||||
return addDevLabel(text0, command0, false, false);
|
||||
}
|
||||
private void addDevLabel(final String text0, final Runnable command0, boolean selectable0, boolean selected0) {
|
||||
devLabels.add(add(new DevLabel(text0, command0, selectable0, selected0)));
|
||||
private DevLabel addDevLabel(final String text0, final Runnable command0, boolean selectable0, boolean selected0) {
|
||||
DevLabel devLabel = add(new DevLabel(text0, command0, selectable0, selected0));
|
||||
devLabels.add(devLabel);
|
||||
return devLabel;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,22 +155,249 @@ public class VDev extends HeaderDropDown {
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ScrollBounds layoutAndGetScrollBounds(float visibleWidth, float visibleHeight) {
|
||||
float x = visibleWidth * INSETS_FACTOR;
|
||||
float y = x;
|
||||
float dy = visibleHeight * GAP_FACTOR;
|
||||
|
||||
int rowCount = (int)(devLabels.size() / 2);
|
||||
float labelWidth = (visibleWidth - 2 * x - dy) / 2;
|
||||
float labelHeight = (visibleHeight - y - x) / rowCount - dy;
|
||||
|
||||
float startX = x;
|
||||
float dx = labelWidth + dy;
|
||||
dy += labelHeight;
|
||||
|
||||
for (int i = 0; i < devLabels.size(); i++) {
|
||||
devLabels.get(i).setBounds(x, y, labelWidth, labelHeight);
|
||||
if (i % 2 == 0) {
|
||||
x += dx;
|
||||
}
|
||||
else {
|
||||
x = startX;
|
||||
y += dy;
|
||||
}
|
||||
}
|
||||
return new ScrollBounds(visibleWidth, visibleHeight);
|
||||
}
|
||||
|
||||
private class DevLabel extends FLabel {
|
||||
private static final float PADDING = 6f;
|
||||
|
||||
public DevLabel(final String text0, final Runnable command0, boolean selectable0, boolean selected0) {
|
||||
super(new ButtonBuilder().text(text0).command(command0)
|
||||
.insets(new Vector2(PADDING, PADDING))
|
||||
super(new ButtonBuilder().text(text0).command(command0).fontSize(12)
|
||||
.selectable(selectable0).selected(selected0));
|
||||
}
|
||||
}
|
||||
|
||||
private static void generateMana() {
|
||||
final Card dummy = new Card(-777777);
|
||||
dummy.setOwner(FControl.getGame().getPhaseHandler().getPriorityPlayer());
|
||||
Map<String, String> produced = new HashMap<String, String>();
|
||||
produced.put("Produced", "W W W W W W W U U U U U U U B B B B B B B G G G G G G G R R R R R R R 7");
|
||||
final AbilityManaPart abMana = new AbilityManaPart(dummy, produced);
|
||||
FControl.getGame().getAction().invoke(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
abMana.produceMana(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void tutorForCard() {
|
||||
Player pPriority = FControl.getGame().getPhaseHandler().getPriorityPlayer();
|
||||
if (pPriority == null) {
|
||||
GuiDialog.message("No player has priority now, can't tutor from their deck at the moment");
|
||||
return;
|
||||
}
|
||||
final List<Card> lib = pPriority.getCardsIn(ZoneType.Library);
|
||||
final Card card = GuiChoose.oneOrNone("Choose a card", lib);
|
||||
if (card == null) { return; }
|
||||
|
||||
FControl.getGame().getAction().invoke(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
FControl.getGame().getAction().moveToHand(card);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void addCounterToPermanent() {
|
||||
final Card card = GuiChoose.oneOrNone("Add counters to which card?", FControl.getGame().getCardsIn(ZoneType.Battlefield));
|
||||
if (card == null) { return; }
|
||||
|
||||
final CounterType counter = GuiChoose.oneOrNone("Which type of counter?", CounterType.values());
|
||||
if (counter == null) { return; }
|
||||
|
||||
final Integer count = GuiChoose.getInteger("How many counters?", 1, Integer.MAX_VALUE, 10);
|
||||
if (count == null) { return; }
|
||||
|
||||
card.addCounter(counter, count, false);
|
||||
}
|
||||
|
||||
private static void tapPermanent() {
|
||||
final Game game = FControl.getGame();
|
||||
game.getAction().invoke(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final List<Card> untapped = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), Predicates.not(CardPredicates.Presets.TAPPED));
|
||||
InputSelectCardsFromList inp = new InputSelectCardsFromList(0, Integer.MAX_VALUE, untapped);
|
||||
inp.setCancelAllowed(true);
|
||||
inp.setMessage("Choose permanents to tap");
|
||||
inp.showAndWait();
|
||||
if (!inp.hasCancelled()) {
|
||||
for (Card c : inp.getSelected()) {
|
||||
c.tap();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void untapPermanent() {
|
||||
final Game game = FControl.getGame();
|
||||
|
||||
game.getAction().invoke(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final List<Card> tapped = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.TAPPED);
|
||||
InputSelectCardsFromList inp = new InputSelectCardsFromList(0, Integer.MAX_VALUE, tapped);
|
||||
inp.setCancelAllowed(true);
|
||||
inp.setMessage("Choose permanents to untap");
|
||||
inp.showAndWait();
|
||||
if (!inp.hasCancelled()) {
|
||||
for(Card c : inp.getSelected()) {
|
||||
c.untap();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void setPlayerLife() {
|
||||
final List<Player> players = FControl.getGame().getPlayers();
|
||||
final Player player = GuiChoose.oneOrNone("Set life for which player?", players);
|
||||
if (player == null) { return; }
|
||||
|
||||
final Integer life = GuiChoose.getInteger("Set life to what?", 0);
|
||||
if (life == null) { return; }
|
||||
|
||||
player.setLife(life, null);
|
||||
}
|
||||
|
||||
private static void addCardToHand() {
|
||||
final List<Player> players = FControl.getGame().getPlayers();
|
||||
final Player p = GuiChoose.oneOrNone("Put card in hand for which player?", players);
|
||||
if (null == p) {
|
||||
return;
|
||||
}
|
||||
|
||||
final List<PaperCard> cards = Lists.newArrayList(FModel.getMagicDb().getCommonCards().getUniqueCards());
|
||||
Collections.sort(cards);
|
||||
|
||||
// use standard forge's list selection dialog
|
||||
final IPaperCard c = GuiChoose.oneOrNone("Name the card", cards);
|
||||
if (c == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
FControl.getGame().getAction().invoke(new Runnable() { @Override public void run() {
|
||||
FControl.getGame().getAction().moveToHand(Card.fromPaperCard(c, p));
|
||||
}});
|
||||
}
|
||||
|
||||
private static void addCardToBattlefield() {
|
||||
final List<Player> players = FControl.getGame().getPlayers();
|
||||
final Player p = GuiChoose.oneOrNone("Put card in play for which player?", players);
|
||||
if (null == p) {
|
||||
return;
|
||||
}
|
||||
|
||||
final List<PaperCard> cards = Lists.newArrayList(FModel.getMagicDb().getCommonCards().getUniqueCards());
|
||||
Collections.sort(cards);
|
||||
|
||||
// use standard forge's list selection dialog
|
||||
final IPaperCard c = GuiChoose.oneOrNone("Name the card", cards);
|
||||
if (c == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Game game = FControl.getGame();
|
||||
game.getAction().invoke(new Runnable() {
|
||||
@Override public void run() {
|
||||
final Card forgeCard = Card.fromPaperCard(c, p);
|
||||
|
||||
if (c.getRules().getType().isLand()) {
|
||||
game.getAction().moveToPlay(forgeCard);
|
||||
} else {
|
||||
final List<SpellAbility> choices = forgeCard.getBasicSpells();
|
||||
if (choices.isEmpty()) {
|
||||
return; // when would it happen?
|
||||
}
|
||||
|
||||
final SpellAbility sa = choices.size() == 1 ? choices.get(0) : GuiChoose.oneOrNone("Choose", choices);
|
||||
if (sa == null) {
|
||||
return; // happens if cancelled
|
||||
}
|
||||
|
||||
game.getAction().moveToHand(forgeCard); // this is really needed (for rollbacks at least)
|
||||
// Human player is choosing targets for an ability controlled by chosen player.
|
||||
sa.setActivatingPlayer(p);
|
||||
HumanPlay.playSaWithoutPayingManaCost(game, sa, true);
|
||||
}
|
||||
game.getStack().addAllTirggeredAbilitiesToStack(); // playSa could fire some triggers
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void riggedPlanarRoll() {
|
||||
final List<Player> players = FControl.getGame().getPlayers();
|
||||
final Player player = GuiChoose.oneOrNone("Which player should roll?", players);
|
||||
if (player == null) { return; }
|
||||
|
||||
final PlanarDice res = GuiChoose.oneOrNone("Choose result", PlanarDice.values());
|
||||
if (res == null) { return; }
|
||||
|
||||
System.out.println("Rigging planar dice roll: " + res.toString());
|
||||
|
||||
//DBG
|
||||
//System.out.println("ActivePlanes: " + FControl.getGame().getActivePlanes());
|
||||
//System.out.println("CommandPlanes: " + FControl.getGame().getCardsIn(ZoneType.Command));
|
||||
|
||||
FControl.getGame().getAction().invoke(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlanarDice.roll(player, res);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void planeswalkTo() {
|
||||
final Game game = FControl.getGame();
|
||||
if (!game.getRules().hasAppliedVariant(GameType.Planechase)) { return; }
|
||||
final Player p = game.getPhaseHandler().getPlayerTurn();
|
||||
|
||||
final List<PaperCard> allPlanars = new ArrayList<PaperCard>();
|
||||
for (PaperCard c : FModel.getMagicDb().getVariantCards().getAllCards()) {
|
||||
if (c.getRules().getType().isPlane() || c.getRules().getType().isPhenomenon()) {
|
||||
allPlanars.add(c);
|
||||
}
|
||||
}
|
||||
Collections.sort(allPlanars);
|
||||
|
||||
// use standard forge's list selection dialog
|
||||
final IPaperCard c = GuiChoose.oneOrNone("Name the card", allPlanars);
|
||||
if (c == null) { return; }
|
||||
final Card forgeCard = Card.fromPaperCard(c, p);
|
||||
|
||||
forgeCard.setOwner(p);
|
||||
game.getAction().invoke(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
game.getAction().changeZone(null, p.getZone(ZoneType.PlanarDeck), forgeCard, 0);
|
||||
PlanarDice.roll(p, PlanarDice.Planeswalk);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ public class FLabel extends FDisplayObject {
|
||||
private float bldIconScaleFactor = 0.8f;
|
||||
private int bldFontSize = 14;
|
||||
private HAlignment bldAlignment = HAlignment.LEFT;
|
||||
private Vector2 bldInsets = new Vector2(0, 0);
|
||||
private Vector2 bldInsets = new Vector2(3, 3);
|
||||
|
||||
private boolean bldSelectable = false;
|
||||
private boolean bldSelected = false;
|
||||
@@ -133,6 +133,10 @@ public class FLabel extends FDisplayObject {
|
||||
icon = icon0;
|
||||
}
|
||||
|
||||
public void setCommand(final Runnable command0) {
|
||||
command = command0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean press(float x, float y) {
|
||||
if (opaque || selectable || pressedColor != null) {
|
||||
|
||||
@@ -1,23 +1,6 @@
|
||||
package forge.utils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import forge.card.CardCharacteristicName;
|
||||
import forge.card.CardDb;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.generation.DeckGenerator2Color;
|
||||
@@ -25,29 +8,7 @@ import forge.deck.generation.DeckGenerator3Color;
|
||||
import forge.deck.generation.DeckGenerator5Color;
|
||||
import forge.deck.generation.DeckGeneratorBase;
|
||||
import forge.deck.generation.DeckGeneratorMonoColor;
|
||||
import forge.game.Game;
|
||||
import forge.game.GameType;
|
||||
import forge.game.PlanarDice;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardLists;
|
||||
import forge.game.card.CardPredicates;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.AbilityManaPart;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.trigger.TriggerType;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.item.PaperCard;
|
||||
import forge.model.FModel;
|
||||
import forge.player.HumanPlay;
|
||||
import forge.screens.match.FControl;
|
||||
import forge.screens.match.input.InputSelectCardsFromList;
|
||||
import forge.toolbox.FFileChooser;
|
||||
import forge.toolbox.FOptionPane;
|
||||
import forge.toolbox.GuiChoose;
|
||||
import forge.toolbox.GuiDialog;
|
||||
import forge.utils.ForgePreferences.FPref;
|
||||
|
||||
public class Utils {
|
||||
@@ -83,418 +44,6 @@ public class Utils {
|
||||
return deck;
|
||||
}
|
||||
return null;
|
||||
}public static void devModeGenerateMana() {
|
||||
final Card dummy = new Card(-777777);
|
||||
dummy.setOwner(getGame().getPhaseHandler().getPriorityPlayer());
|
||||
Map<String, String> produced = new HashMap<String, String>();
|
||||
produced.put("Produced", "W W W W W W W U U U U U U U B B B B B B B G G G G G G G R R R R R R R 7");
|
||||
final AbilityManaPart abMana = new AbilityManaPart(dummy, produced);
|
||||
getGame().getAction().invoke(new Runnable() {
|
||||
@Override public void run() { abMana.produceMana(null); }
|
||||
});
|
||||
}
|
||||
|
||||
public static void devSetupGameState() {
|
||||
int humanLife = -1;
|
||||
int computerLife = -1;
|
||||
|
||||
final Map<ZoneType, String> humanCardTexts = new EnumMap<ZoneType, String>(ZoneType.class);
|
||||
final Map<ZoneType, String> aiCardTexts = new EnumMap<ZoneType, String>(ZoneType.class);
|
||||
|
||||
String tChangePlayer = "NONE";
|
||||
String tChangePhase = "NONE";
|
||||
|
||||
final FFileChooser fc = new FFileChooser();
|
||||
if (!fc.show("Select Game State File")) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
final FileInputStream fstream = new FileInputStream(fc.getSelectedFile().getAbsolutePath());
|
||||
final DataInputStream in = new DataInputStream(fstream);
|
||||
final BufferedReader br = new BufferedReader(new InputStreamReader(in));
|
||||
|
||||
String temp = "";
|
||||
|
||||
while ((temp = br.readLine()) != null) {
|
||||
|
||||
final String[] tempData = temp.split("=");
|
||||
if (tempData.length < 2 || temp.charAt(0) == '#') {
|
||||
continue;
|
||||
}
|
||||
|
||||
final String categoryName = tempData[0].toLowerCase();
|
||||
final String categoryValue = tempData[1];
|
||||
|
||||
if (categoryName.equals("humanlife")) humanLife = Integer.parseInt(categoryValue);
|
||||
else if (categoryName.equals("ailife")) computerLife = Integer.parseInt(categoryValue);
|
||||
|
||||
else if (categoryName.equals("activeplayer")) tChangePlayer = categoryValue.trim().toLowerCase();
|
||||
else if (categoryName.equals("activephase")) tChangePhase = categoryValue;
|
||||
|
||||
else if (categoryName.equals("humancardsinplay")) humanCardTexts.put(ZoneType.Battlefield, categoryValue);
|
||||
else if (categoryName.equals("aicardsinplay")) aiCardTexts.put(ZoneType.Battlefield, categoryValue);
|
||||
else if (categoryName.equals("humancardsinhand")) humanCardTexts.put(ZoneType.Hand, categoryValue);
|
||||
else if (categoryName.equals("aicardsinhand")) aiCardTexts.put(ZoneType.Hand, categoryValue);
|
||||
else if (categoryName.equals("humancardsingraveyard")) humanCardTexts.put(ZoneType.Graveyard, categoryValue);
|
||||
else if (categoryName.equals("aicardsingraveyard")) aiCardTexts.put(ZoneType.Graveyard, categoryValue);
|
||||
else if (categoryName.equals("humancardsinlibrary")) humanCardTexts.put(ZoneType.Library, categoryValue);
|
||||
else if (categoryName.equals("aicardsinlibrary")) aiCardTexts.put(ZoneType.Library, categoryValue);
|
||||
else if (categoryName.equals("humancardsinexile")) humanCardTexts.put(ZoneType.Exile, categoryValue);
|
||||
else if (categoryName.equals("aicardsinexile")) aiCardTexts.put(ZoneType.Exile, categoryValue);
|
||||
|
||||
}
|
||||
|
||||
in.close();
|
||||
}
|
||||
catch (final FileNotFoundException fnfe) {
|
||||
FOptionPane.showErrorDialog("File not found: " + fc.getSelectedFile().getAbsolutePath());
|
||||
}
|
||||
catch (final Exception e) {
|
||||
FOptionPane.showErrorDialog("Error loading battle setup file!");
|
||||
return;
|
||||
}
|
||||
|
||||
setupGameState(humanLife, computerLife, humanCardTexts, aiCardTexts, tChangePlayer, tChangePhase);
|
||||
}
|
||||
|
||||
private static void setupGameState(final int humanLife, final int computerLife, final Map<ZoneType, String> humanCardTexts,
|
||||
final Map<ZoneType, String> aiCardTexts, final String tChangePlayer, final String tChangePhase) {
|
||||
|
||||
final Game game = getGame();
|
||||
game.getAction().invoke(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final Player human = game.getPlayers().get(0);
|
||||
final Player ai = game.getPlayers().get(1);
|
||||
|
||||
Player newPlayerTurn = tChangePlayer.equals("human") ? newPlayerTurn = human : tChangePlayer.equals("ai") ? newPlayerTurn = ai : null;
|
||||
PhaseType newPhase = tChangePhase.trim().equalsIgnoreCase("none") ? null : PhaseType.smartValueOf(tChangePhase);
|
||||
|
||||
game.getPhaseHandler().devModeSet(newPhase, newPlayerTurn);
|
||||
|
||||
|
||||
game.getTriggerHandler().suppressMode(TriggerType.ChangesZone);
|
||||
|
||||
devSetupPlayerState(humanLife, humanCardTexts, human);
|
||||
devSetupPlayerState(computerLife, aiCardTexts, ai);
|
||||
|
||||
game.getTriggerHandler().clearSuppression(TriggerType.ChangesZone);
|
||||
|
||||
game.getAction().checkStaticAbilities();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void devSetupPlayerState(int life, Map<ZoneType, String> cardTexts, final Player p) {
|
||||
Map<ZoneType, List<Card>> humanCards = new EnumMap<ZoneType, List<Card>>(ZoneType.class);
|
||||
for(Entry<ZoneType, String> kv : cardTexts.entrySet()) {
|
||||
humanCards.put(kv.getKey(), devProcessCardsForZone(kv.getValue().split(";"), p));
|
||||
}
|
||||
|
||||
if (life > 0) p.setLife(life, null);
|
||||
for (Entry<ZoneType, List<Card>> kv : humanCards.entrySet()) {
|
||||
if (kv.getKey() == ZoneType.Battlefield) {
|
||||
for (final Card c : kv.getValue()) {
|
||||
p.getZone(ZoneType.Hand).add(c);
|
||||
p.getGame().getAction().moveToPlay(c);
|
||||
c.setSickness(false);
|
||||
}
|
||||
} else {
|
||||
p.getZone(kv.getKey()).setCards(kv.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* devProcessCardsForZone.
|
||||
* </p>
|
||||
*
|
||||
* @param data
|
||||
* an array of {@link java.lang.String} objects.
|
||||
* @param player
|
||||
* a {@link forge.game.player.Player} object.
|
||||
* @return a {@link forge.CardList} object.
|
||||
*/
|
||||
private static List<Card> devProcessCardsForZone(final String[] data, final Player player) {
|
||||
final List<Card> cl = new ArrayList<Card>();
|
||||
for (final String element : data) {
|
||||
final String[] cardinfo = element.trim().split("\\|");
|
||||
|
||||
final Card c = Card.fromPaperCard(FModel.getMagicDb().getCommonCards().getCard(cardinfo[0]), player);
|
||||
|
||||
boolean hasSetCurSet = false;
|
||||
for (final String info : cardinfo) {
|
||||
if (info.startsWith("Set:")) {
|
||||
c.setCurSetCode(info.substring(info.indexOf(':') + 1));
|
||||
hasSetCurSet = true;
|
||||
} else if (info.equalsIgnoreCase("Tapped:True")) {
|
||||
c.tap();
|
||||
} else if (info.startsWith("Counters:")) {
|
||||
final String[] counterStrings = info.substring(info.indexOf(':') + 1).split(",");
|
||||
for (final String counter : counterStrings) {
|
||||
c.addCounter(CounterType.valueOf(counter), 1, true);
|
||||
}
|
||||
} else if (info.equalsIgnoreCase("SummonSick:True")) {
|
||||
c.setSickness(true);
|
||||
} else if (info.equalsIgnoreCase("FaceDown:True")) {
|
||||
c.setState(CardCharacteristicName.FaceDown);
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasSetCurSet) {
|
||||
c.setCurSetCode(c.getMostRecentSet());
|
||||
}
|
||||
|
||||
cl.add(c);
|
||||
}
|
||||
return cl;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* devModeTutor.
|
||||
* </p>
|
||||
*
|
||||
* @since 1.0.15
|
||||
*/
|
||||
public static void devModeTutor() {
|
||||
Player pPriority = getGame().getPhaseHandler().getPriorityPlayer();
|
||||
if (pPriority == null) {
|
||||
GuiDialog.message("No player has priority now, can't tutor from their deck at the moment");
|
||||
return;
|
||||
}
|
||||
final List<Card> lib = pPriority.getCardsIn(ZoneType.Library);
|
||||
final Card card = GuiChoose.oneOrNone("Choose a card", lib);
|
||||
if (card == null) { return; }
|
||||
|
||||
getGame().getAction().invoke(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
getGame().getAction().moveToHand(card);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* devModeAddCounter.
|
||||
* </p>
|
||||
*
|
||||
* @since 1.0.15
|
||||
*/
|
||||
public static void devModeAddCounter() {
|
||||
final Card card = GuiChoose.oneOrNone("Add counters to which card?", getGame().getCardsIn(ZoneType.Battlefield));
|
||||
if (card == null) { return; }
|
||||
|
||||
final CounterType counter = GuiChoose.oneOrNone("Which type of counter?", CounterType.values());
|
||||
if (counter == null) { return; }
|
||||
|
||||
final Integer count = GuiChoose.getInteger("How many counters?", 1, Integer.MAX_VALUE, 10);
|
||||
if (count == null) { return; }
|
||||
|
||||
card.addCounter(counter, count, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* devModeTapPerm.
|
||||
* </p>
|
||||
*
|
||||
* @since 1.0.15
|
||||
*/
|
||||
public static void devModeTapPerm() {
|
||||
final Game game = getGame();
|
||||
game.getAction().invoke(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final List<Card> untapped = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), Predicates.not(CardPredicates.Presets.TAPPED));
|
||||
InputSelectCardsFromList inp = new InputSelectCardsFromList(0, Integer.MAX_VALUE, untapped);
|
||||
inp.setCancelAllowed(true);
|
||||
inp.setMessage("Choose permanents to tap");
|
||||
inp.showAndWait();
|
||||
if (!inp.hasCancelled()) {
|
||||
for (Card c : inp.getSelected()) {
|
||||
c.tap();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* devModeUntapPerm.
|
||||
* </p>
|
||||
*
|
||||
* @since 1.0.15
|
||||
*/
|
||||
public static void devModeUntapPerm() {
|
||||
final Game game = getGame();
|
||||
|
||||
|
||||
|
||||
game.getAction().invoke(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final List<Card> tapped = CardLists.filter(game.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.TAPPED);
|
||||
InputSelectCardsFromList inp = new InputSelectCardsFromList(0, Integer.MAX_VALUE, tapped);
|
||||
inp.setCancelAllowed(true);
|
||||
inp.setMessage("Choose permanents to untap");
|
||||
inp.showAndWait();
|
||||
if( !inp.hasCancelled() )
|
||||
for(Card c : inp.getSelected())
|
||||
c.untap();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* devModeSetLife.
|
||||
* </p>
|
||||
*
|
||||
* @since 1.1.3
|
||||
*/
|
||||
public static void devModeSetLife() {
|
||||
final List<Player> players = getGame().getPlayers();
|
||||
final Player player = GuiChoose.oneOrNone("Set life for which player?", players);
|
||||
if (player == null) { return; }
|
||||
|
||||
final Integer life = GuiChoose.getInteger("Set life to what?", 0);
|
||||
if (life == null) { return; }
|
||||
|
||||
player.setLife(life, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* devModeTutorAnyCard.
|
||||
* </p>
|
||||
*
|
||||
* @since 1.2.7
|
||||
*/
|
||||
public static void devModeCardToHand() {
|
||||
final List<Player> players = getGame().getPlayers();
|
||||
final Player p = GuiChoose.oneOrNone("Put card in hand for which player?", players);
|
||||
if (null == p) {
|
||||
return;
|
||||
}
|
||||
|
||||
final List<PaperCard> cards = Lists.newArrayList(FModel.getMagicDb().getCommonCards().getUniqueCards());
|
||||
Collections.sort(cards);
|
||||
|
||||
// use standard forge's list selection dialog
|
||||
final IPaperCard c = GuiChoose.oneOrNone("Name the card", cards);
|
||||
if (c == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
getGame().getAction().invoke(new Runnable() { @Override public void run() {
|
||||
getGame().getAction().moveToHand(Card.fromPaperCard(c, p));
|
||||
}});
|
||||
}
|
||||
|
||||
public static void devModeCardToBattlefield() {
|
||||
final List<Player> players = getGame().getPlayers();
|
||||
final Player p = GuiChoose.oneOrNone("Put card in play for which player?", players);
|
||||
if (null == p) {
|
||||
return;
|
||||
}
|
||||
|
||||
final List<PaperCard> cards = Lists.newArrayList(FModel.getMagicDb().getCommonCards().getUniqueCards());
|
||||
Collections.sort(cards);
|
||||
|
||||
// use standard forge's list selection dialog
|
||||
final IPaperCard c = GuiChoose.oneOrNone("Name the card", cards);
|
||||
if (c == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Game game = getGame();
|
||||
game.getAction().invoke(new Runnable() {
|
||||
@Override public void run() {
|
||||
final Card forgeCard = Card.fromPaperCard(c, p);
|
||||
|
||||
if (c.getRules().getType().isLand()) {
|
||||
game.getAction().moveToPlay(forgeCard);
|
||||
} else {
|
||||
final List<SpellAbility> choices = forgeCard.getBasicSpells();
|
||||
if (choices.isEmpty()) {
|
||||
return; // when would it happen?
|
||||
}
|
||||
|
||||
final SpellAbility sa = choices.size() == 1 ? choices.get(0) : GuiChoose.oneOrNone("Choose", choices);
|
||||
if (sa == null) {
|
||||
return; // happens if cancelled
|
||||
}
|
||||
|
||||
game.getAction().moveToHand(forgeCard); // this is really needed (for rollbacks at least)
|
||||
// Human player is choosing targets for an ability controlled by chosen player.
|
||||
sa.setActivatingPlayer(p);
|
||||
HumanPlay.playSaWithoutPayingManaCost(game, sa, true);
|
||||
}
|
||||
game.getStack().addAllTirggeredAbilitiesToStack(); // playSa could fire some triggers
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void devModeRiggedPlanarRoll() {
|
||||
final List<Player> players = getGame().getPlayers();
|
||||
final Player player = GuiChoose.oneOrNone("Which player should roll?", players);
|
||||
if (player == null) { return; }
|
||||
|
||||
final PlanarDice res = GuiChoose.oneOrNone("Choose result", PlanarDice.values());
|
||||
if (res == null) { return; }
|
||||
|
||||
System.out.println("Rigging planar dice roll: " + res.toString());
|
||||
|
||||
//DBG
|
||||
//System.out.println("ActivePlanes: " + getGame().getActivePlanes());
|
||||
//System.out.println("CommandPlanes: " + getGame().getCardsIn(ZoneType.Command));
|
||||
|
||||
|
||||
|
||||
getGame().getAction().invoke(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlanarDice.roll(player, res);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void devModePlaneswalkTo() {
|
||||
final Game game = getGame();
|
||||
if (!game.getRules().hasAppliedVariant(GameType.Planechase)) { return; }
|
||||
final Player p = game.getPhaseHandler().getPlayerTurn();
|
||||
|
||||
final List<PaperCard> allPlanars = new ArrayList<PaperCard>();
|
||||
for (PaperCard c : FModel.getMagicDb().getVariantCards().getAllCards()) {
|
||||
if (c.getRules().getType().isPlane() || c.getRules().getType().isPhenomenon()) {
|
||||
allPlanars.add(c);
|
||||
}
|
||||
}
|
||||
Collections.sort(allPlanars);
|
||||
|
||||
// use standard forge's list selection dialog
|
||||
final IPaperCard c = GuiChoose.oneOrNone("Name the card", allPlanars);
|
||||
if (c == null) { return; }
|
||||
final Card forgeCard = Card.fromPaperCard(c, p);
|
||||
|
||||
forgeCard.setOwner(p);
|
||||
getGame().getAction().invoke(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
getGame().getAction().changeZone(null, p.getZone(ZoneType.PlanarDeck), forgeCard, 0);
|
||||
PlanarDice.roll(p, PlanarDice.Planeswalk);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static Game getGame() {
|
||||
return FControl.getGame();
|
||||
}
|
||||
|
||||
public static String getPlayerName() {
|
||||
|
||||
Reference in New Issue
Block a user