GameAction.moveTo(final Zone zoneTo, Card c, Integer position) now demands to be run from non-edt

GuiDisplayUtil - warped tutor functions in game.getAction.invoke() to run in aux game thread.
"Manual Breakpoint" - removed because EDT won't give accurate information on player zones.
This commit is contained in:
Maxmtg
2013-05-31 23:13:38 +00:00
parent f412e5ccf3
commit e612c7f01a
4 changed files with 11 additions and 49 deletions

View File

@@ -361,6 +361,8 @@ public class GameAction {
} }
public final Card moveTo(final Zone zoneTo, Card c, Integer position) { public final Card moveTo(final Zone zoneTo, Card c, Integer position) {
FThreads.assertExecutedByEdt(false);
// Ideally move to should never be called without a prevZone // Ideally move to should never be called without a prevZone
// Remove card from Current Zone, if it has one // Remove card from Current Zone, if it has one
final Zone zoneFrom = game.getZoneOf(c); final Zone zoneFrom = game.getZoneOf(c);

View File

@@ -50,7 +50,6 @@ import forge.game.PlanarDice;
import forge.game.phase.PhaseType; import forge.game.phase.PhaseType;
import forge.game.player.HumanPlay; import forge.game.player.HumanPlay;
import forge.game.player.Player; import forge.game.player.Player;
import forge.game.zone.PlayerZone;
import forge.game.zone.ZoneType; import forge.game.zone.ZoneType;
import forge.gui.input.InputSelectCardsFromList; import forge.gui.input.InputSelectCardsFromList;
import forge.item.CardDb; import forge.item.CardDb;
@@ -245,13 +244,12 @@ public final class GuiDisplayUtil {
*/ */
public static void devModeTutor() { public static void devModeTutor() {
final List<Card> lib = getGame().getPhaseHandler().getPriorityPlayer().getCardsIn(ZoneType.Library); final List<Card> lib = getGame().getPhaseHandler().getPriorityPlayer().getCardsIn(ZoneType.Library);
final Object o = GuiChoose.oneOrNone("Choose a card", lib); final Card c = GuiChoose.oneOrNone("Choose a card", lib);
if (null == o) { if (null == c)
return; return;
} else {
final Card c = (Card) o; getGame().getAction().invoke(new Runnable() { @Override public void run() { getGame().getAction().moveToHand(c); }});
getGame().getAction().moveToHand(c);
}
} }
/** /**
@@ -387,9 +385,10 @@ public final class GuiDisplayUtil {
return; return;
} }
getGame().getAction().invoke(new Runnable() { @Override public void run() {
Card forgeCard = c.toForgeCard(p); Card forgeCard = c.toForgeCard(p);
getGame().getAction().moveToHand(forgeCard); getGame().getAction().moveToHand(forgeCard);
}});
} }
public static void devModeCardToBattlefield() { public static void devModeCardToBattlefield() {
@@ -440,33 +439,6 @@ public final class GuiDisplayUtil {
} }
public static void devModeBreakpoint() {
List<Player> Players = getGame().getPlayers();
/*
Combat CombatHandler = AllZone.getCombat();
TriggerHandler Triggers = AllZone.getTriggerHandler();
InputControl InputHandler = AllZone.getInputControl();
ReplacementHandler Replacements = AllZone.getReplacementHandler();
StaticEffects StaticHandler = AllZone.getStaticEffects();
*/
List<PlayerZone> Zones = new ArrayList<PlayerZone>();
for (Player p : Players) {
Zones.add(p.getZone(ZoneType.Ante));
Zones.add(p.getZone(ZoneType.Battlefield));
Zones.add(p.getZone(ZoneType.Command));
Zones.add(p.getZone(ZoneType.Exile));
Zones.add(p.getZone(ZoneType.Graveyard));
Zones.add(p.getZone(ZoneType.Hand));
Zones.add(p.getZone(ZoneType.Library));
Zones.add(p.getZone(ZoneType.Sideboard));
// player has no stack of his own
}
//Set a breakpoint on the following statement
System.out.println("Manual Breakpoint");
}
public static void devModeRiggedPlanarRoll() public static void devModeRiggedPlanarRoll()
{ {
final List<Player> players = getGame().getPlayers(); final List<Player> players = getGame().getPlayers();

View File

@@ -76,10 +76,6 @@ public enum CDev implements ICDoc {
public void mousePressed(final MouseEvent e) { public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devModeCardToBattlefield(); } }; GuiDisplayUtil.devModeCardToBattlefield(); } };
private final MouseListener madBreakpoint = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devModeBreakpoint(); } };
private final MouseListener madRiggedRoll = new MouseAdapter() { @Override private final MouseListener madRiggedRoll = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) { public void mousePressed(final MouseEvent e) {
GuiDisplayUtil.devModeRiggedPlanarRoll(); } }; GuiDisplayUtil.devModeRiggedPlanarRoll(); } };
@@ -113,7 +109,6 @@ public enum CDev implements ICDoc {
VDev.SINGLETON_INSTANCE.getLblTapPermanent().addMouseListener(madTap); VDev.SINGLETON_INSTANCE.getLblTapPermanent().addMouseListener(madTap);
VDev.SINGLETON_INSTANCE.getLblUntapPermanent().addMouseListener(madUntap); VDev.SINGLETON_INSTANCE.getLblUntapPermanent().addMouseListener(madUntap);
VDev.SINGLETON_INSTANCE.getLblSetLife().addMouseListener(madLife); VDev.SINGLETON_INSTANCE.getLblSetLife().addMouseListener(madLife);
VDev.SINGLETON_INSTANCE.getLblBreakpoint().addMouseListener(madBreakpoint);
VDev.SINGLETON_INSTANCE.getLblCardToBattlefield().addMouseListener(madCardToBattlefield); VDev.SINGLETON_INSTANCE.getLblCardToBattlefield().addMouseListener(madCardToBattlefield);
VDev.SINGLETON_INSTANCE.getLblRiggedRoll().addMouseListener(madRiggedRoll); VDev.SINGLETON_INSTANCE.getLblRiggedRoll().addMouseListener(madRiggedRoll);
VDev.SINGLETON_INSTANCE.getLblWalkTo().addMouseListener(madWalkToPlane); VDev.SINGLETON_INSTANCE.getLblWalkTo().addMouseListener(madWalkToPlane);

View File

@@ -74,7 +74,6 @@ public enum VDev implements IVDoc<CDev> {
private final DevLabel lblSetLife = new DevLabel("Set Player Life"); private final DevLabel lblSetLife = new DevLabel("Set Player Life");
private final DevLabel lblCardToBattlefield = new DevLabel("Add card to play"); private final DevLabel lblCardToBattlefield = new DevLabel("Add card to play");
private final DevLabel lblCardToHand = new DevLabel("Add card to hand"); private final DevLabel lblCardToHand = new DevLabel("Add card to hand");
private final DevLabel lblBreakpoint = new DevLabel("Trigger breakpoint");
private final DevLabel lblRiggedRoll = new DevLabel("Rigged planar roll"); private final DevLabel lblRiggedRoll = new DevLabel("Rigged planar roll");
private final DevLabel lblWalkTo = new DevLabel("Planeswalk to"); private final DevLabel lblWalkTo = new DevLabel("Planeswalk to");
@@ -93,7 +92,6 @@ public enum VDev implements IVDoc<CDev> {
devLBLs.add(lblTapPermanent); devLBLs.add(lblTapPermanent);
devLBLs.add(lblUntapPermanent); devLBLs.add(lblUntapPermanent);
devLBLs.add(lblSetLife); devLBLs.add(lblSetLife);
devLBLs.add(lblBreakpoint);
devLBLs.add(lblWalkTo); devLBLs.add(lblWalkTo);
scroller.setBorder(null); scroller.setBorder(null);
@@ -116,7 +114,6 @@ public enum VDev implements IVDoc<CDev> {
viewport.add(this.lblTapPermanent, halfConstraints + ", split 2"); viewport.add(this.lblTapPermanent, halfConstraints + ", split 2");
viewport.add(this.lblUntapPermanent, halfConstraints); viewport.add(this.lblUntapPermanent, halfConstraints);
viewport.add(this.lblSetLife, constraints); viewport.add(this.lblSetLife, constraints);
viewport.add(this.lblBreakpoint, constraints);
} }
//========= Overridden methods //========= Overridden methods
@@ -227,10 +224,6 @@ public enum VDev implements IVDoc<CDev> {
return this.lblSetLife; return this.lblSetLife;
} }
public DevLabel getLblBreakpoint() {
return this.lblBreakpoint;
}
public DevLabel getLblRiggedRoll() { public DevLabel getLblRiggedRoll() {
return this.lblRiggedRoll; return this.lblRiggedRoll;
} }