mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
updates to VStack are never empty
This commit is contained in:
@@ -23,7 +23,6 @@ import forge.game.player.LobbyPlayer;
|
||||
import forge.game.player.LobbyPlayerHuman;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerStatistics;
|
||||
import forge.game.player.PlayerType;
|
||||
import forge.gui.InputProxy;
|
||||
import forge.gui.framework.EDocID;
|
||||
import forge.gui.framework.SDisplayUtil;
|
||||
@@ -38,7 +37,6 @@ import forge.gui.match.controllers.CStack;
|
||||
import forge.gui.match.nonsingleton.VField;
|
||||
import forge.gui.match.views.VAntes;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.util.Aggregates;
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
@@ -163,31 +161,44 @@ public class MatchController {
|
||||
}
|
||||
|
||||
try {
|
||||
HumanPlayer localHuman = (HumanPlayer) Aggregates.firstFieldEquals(currentGame.getPlayers(), Player.Accessors.FN_GET_TYPE, PlayerType.HUMAN);
|
||||
|
||||
HumanPlayer localHuman = null;
|
||||
for(Player p : currentGame.getPlayers()) {
|
||||
if ( p.getLobbyPlayer() != FControl.SINGLETON_INSTANCE.getLobby().getGuiPlayer())
|
||||
continue;
|
||||
localHuman = (HumanPlayer) p;
|
||||
break;
|
||||
}
|
||||
if (null == localHuman)
|
||||
throw new IllegalStateException("Cannot start a game without a human yet!");
|
||||
|
||||
FControl.SINGLETON_INSTANCE.setPlayer(localHuman);
|
||||
|
||||
// The UI controls should use these game data as models
|
||||
CMatchUI.SINGLETON_INSTANCE.initMatch(currentGame.getRegisteredPlayers(), localHuman);
|
||||
CDock.SINGLETON_INSTANCE.onGameStarts(currentGame, localHuman);
|
||||
|
||||
CLog.SINGLETON_INSTANCE.init(currentGame.getGameLog());
|
||||
currentGame.getGameLog().addObserver(CLog.SINGLETON_INSTANCE);
|
||||
|
||||
CStack.SINGLETON_INSTANCE.setModel(currentGame.getStack());
|
||||
CLog.SINGLETON_INSTANCE.setModel(currentGame.getGameLog());
|
||||
CCombat.SINGLETON_INSTANCE.setModel(currentGame);
|
||||
|
||||
Singletons.getModel().getPreferences().actuateMatchPreferences();
|
||||
Singletons.getControl().changeState(FControl.Screens.MATCH_SCREEN);
|
||||
SDisplayUtil.showTab(EDocID.REPORT_LOG.getDoc());
|
||||
|
||||
InputProxy inputControl = CMessage.SINGLETON_INSTANCE.getInputControl();
|
||||
inputControl.setMatch(this);
|
||||
input.addObserver(inputControl);
|
||||
currentGame.getStack().addObserver(inputControl);
|
||||
// black magic still
|
||||
InputProxy inputProxy = CMessage.SINGLETON_INSTANCE.getInputControl();
|
||||
inputProxy.setMatch(this);
|
||||
input.addObserver(inputProxy);
|
||||
|
||||
// models shall notify controllers of changes
|
||||
currentGame.getStack().addObserver(inputProxy);
|
||||
currentGame.getStack().addObserver(CStack.SINGLETON_INSTANCE);
|
||||
currentGame.getPhaseHandler().addObserver(inputControl);
|
||||
|
||||
|
||||
|
||||
currentGame.getPhaseHandler().addObserver(inputProxy);
|
||||
currentGame.getGameLog().addObserver(CLog.SINGLETON_INSTANCE);
|
||||
// some observers are set in CMatchUI.initMatch
|
||||
|
||||
|
||||
|
||||
final boolean canRandomFoil = Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_RANDOM_FOIL) && gameType == GameType.Constructed;
|
||||
GameNew.newGame(this, startConditions, currentGame, canRandomFoil);
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public enum CLog implements ICDoc, Observer {
|
||||
* TODO: Write javadoc for this method.
|
||||
* @param gameLog
|
||||
*/
|
||||
public void init(GameLog gameLog) {
|
||||
public void setModel(GameLog gameLog) {
|
||||
model = gameLog;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@ public enum CStack implements ICDoc, Observer {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
private MagicStack model;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.ICDoc#getCommandOnSelect()
|
||||
*/
|
||||
@@ -36,25 +38,17 @@ public enum CStack implements ICDoc, Observer {
|
||||
public void initialize() {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.ICDoc#update()
|
||||
*/
|
||||
public void update(MagicStack model) {
|
||||
private final Runnable upd = new Runnable() { @Override public void run() {
|
||||
SDisplayUtil.showTab(EDocID.REPORT_STACK.getDoc());
|
||||
VStack.SINGLETON_INSTANCE.updateStack(model);
|
||||
}
|
||||
} };
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.util.Observer#update(java.util.Observable, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void update(final Observable arg0, Object arg1) {
|
||||
if ( arg0 instanceof MagicStack )
|
||||
{
|
||||
FThreads.invokeInEdtNowOrLater(new Runnable() { @Override public void run() {
|
||||
SDisplayUtil.showTab(EDocID.REPORT_STACK.getDoc());
|
||||
update((MagicStack)arg0);
|
||||
} });
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -62,7 +56,9 @@ public enum CStack implements ICDoc, Observer {
|
||||
*/
|
||||
@Override
|
||||
public void update() {
|
||||
// won't update without a model!
|
||||
FThreads.invokeInEdtNowOrLater(upd);
|
||||
}
|
||||
|
||||
public void setModel(MagicStack model) { this.model = model; }
|
||||
|
||||
}
|
||||
|
||||
@@ -86,13 +86,7 @@ public class CField implements ICDoc {
|
||||
public void mousePressed(final MouseEvent e) { cardclickAction(e); } };
|
||||
|
||||
|
||||
// Hand, Graveyard, Library, Flashback, Exile zones, attached to hand.
|
||||
private final Observer observerZones = new Observer() {
|
||||
@Override
|
||||
public void update(final Observable a, final Object b) {
|
||||
FThreads.invokeInEdtNowOrLater(updateZonesRunnable);
|
||||
}
|
||||
};
|
||||
|
||||
private final Runnable updateZonesRunnable = new Runnable() { @Override public void run() { CField.this.view.updateZones(CField.this.player); } };
|
||||
private final Runnable updateDetailsRunnable = new Runnable() { @Override public void run() { CField.this.view.updateDetails(CField.this.player); } };
|
||||
|
||||
@@ -103,6 +97,13 @@ public class CField implements ICDoc {
|
||||
FThreads.invokeInEdtNowOrLater(updateDetailsRunnable);
|
||||
}
|
||||
};
|
||||
// Hand, Graveyard, Library, Flashback, Exile zones, attached to hand.
|
||||
private final Observer observerZones = new Observer() {
|
||||
@Override
|
||||
public void update(final Observable a, final Object b) {
|
||||
FThreads.invokeInEdtNowOrLater(updateZonesRunnable);
|
||||
}
|
||||
};
|
||||
|
||||
// Card play area, attached to battlefield zone.
|
||||
private final Observer observerPlay = new Observer() {
|
||||
|
||||
Reference in New Issue
Block a user