mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
removed references to match controller via singletons where in non-ui classes (UI may safely use singletons.fcontrol)
This commit is contained in:
@@ -49,7 +49,7 @@ public class RestartGameEffect extends SpellAbilityEffect {
|
||||
playerLibraries.put(p, newLibrary);
|
||||
}
|
||||
|
||||
GameNew.restartGame(Singletons.getControl().getMatch(), game, sa.getActivatingPlayer(), playerLibraries);
|
||||
GameNew.restartGame(game.getMatch(), game, sa.getActivatingPlayer(), playerLibraries);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
||||
@@ -24,8 +24,6 @@ import forge.game.player.LobbyPlayer;
|
||||
import forge.game.player.LobbyPlayerHuman;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerStatistics;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.InputProxy;
|
||||
import forge.gui.framework.EDocID;
|
||||
import forge.gui.framework.SDisplayUtil;
|
||||
import forge.gui.match.CMatchUI;
|
||||
@@ -186,23 +184,23 @@ public class MatchController {
|
||||
CStack.SINGLETON_INSTANCE.setModel(currentGame.getStack());
|
||||
CLog.SINGLETON_INSTANCE.setModel(currentGame.getGameLog());
|
||||
CCombat.SINGLETON_INSTANCE.setModel(currentGame);
|
||||
CMessage.SINGLETON_INSTANCE.setModel(match);
|
||||
|
||||
|
||||
Singletons.getModel().getPreferences().actuateMatchPreferences();
|
||||
Singletons.getControl().changeState(FControl.Screens.MATCH_SCREEN);
|
||||
SDisplayUtil.showTab(EDocID.REPORT_LOG.getDoc());
|
||||
|
||||
InputProxy inputProxy = CMessage.SINGLETON_INSTANCE.getInputControl();
|
||||
inputProxy.setMatch(match);
|
||||
CMessage.SINGLETON_INSTANCE.getInputControl().setMatch(match);
|
||||
|
||||
// models shall notify controllers of changes
|
||||
currentGame.getStack().addObserver(inputProxy);
|
||||
|
||||
currentGame.getStack().addObserver(CStack.SINGLETON_INSTANCE);
|
||||
currentGame.getPhaseHandler().addObserver(inputProxy);
|
||||
currentGame.getGameLog().addObserver(CLog.SINGLETON_INSTANCE);
|
||||
// some observers were set in CMatchUI.initMatch
|
||||
|
||||
// black magic still
|
||||
match.getInput().addObserver(inputProxy);
|
||||
|
||||
|
||||
VAntes.SINGLETON_INSTANCE.setModel(currentGame.getRegisteredPlayers());
|
||||
|
||||
@@ -211,7 +209,6 @@ public class MatchController {
|
||||
}
|
||||
|
||||
// per player observers were set in CMatchUI.SINGLETON_INSTANCE.initMatch
|
||||
CMessage.SINGLETON_INSTANCE.updateGameInfo(match);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -246,6 +246,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable {
|
||||
switch(this.getPhase()) {
|
||||
case UNTAP:
|
||||
//SDisplayUtil.showTab(EDocID.REPORT_STACK.getDoc());
|
||||
updateObservers();
|
||||
PhaseUtil.handleUntap(game);
|
||||
break;
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.google.common.base.Predicate;
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardPredicates.Presets;
|
||||
import forge.Singletons;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.card.spellability.Ability;
|
||||
@@ -41,7 +40,6 @@ import forge.game.player.AIPlayer;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.match.CMatchUI;
|
||||
import forge.gui.match.controllers.CMessage;
|
||||
import forge.gui.match.nonsingleton.VField.PhaseLabel;
|
||||
|
||||
/**
|
||||
@@ -86,8 +84,6 @@ public class PhaseUtil {
|
||||
final PhaseHandler ph = game.getPhaseHandler();
|
||||
final Player turn = ph.getPlayerTurn();
|
||||
|
||||
CMessage.SINGLETON_INSTANCE.updateGameInfo(Singletons.getControl().getMatch());
|
||||
|
||||
game.getCombat().reset(turn);
|
||||
|
||||
// Tokens starting game in play should suffer from Sum. Sickness
|
||||
|
||||
@@ -45,8 +45,11 @@ public class InputProxy implements Observer {
|
||||
|
||||
private static final boolean INPUT_DEBUG = false;
|
||||
|
||||
public void setMatch(MatchController matchController) {
|
||||
match = matchController;
|
||||
public void setMatch(MatchController match0) {
|
||||
match = match0;
|
||||
match.getCurrentGame().getStack().addObserver(this);
|
||||
match.getCurrentGame().getPhaseHandler().addObserver(this);
|
||||
match.getInput().addObserver(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,6 +23,8 @@ import java.awt.event.ActionListener;
|
||||
import java.awt.event.FocusAdapter;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
|
||||
import javax.swing.JButton;
|
||||
|
||||
@@ -38,7 +40,7 @@ import forge.gui.match.views.VMessage;
|
||||
*
|
||||
* <br><br><i>(C at beginning of class name denotes a control class.)</i>
|
||||
*/
|
||||
public enum CMessage implements ICDoc {
|
||||
public enum CMessage implements ICDoc, Observer {
|
||||
/** */
|
||||
SINGLETON_INSTANCE;
|
||||
|
||||
@@ -67,6 +69,7 @@ public enum CMessage implements ICDoc {
|
||||
}
|
||||
}
|
||||
};
|
||||
private MatchController match;
|
||||
|
||||
private void _initButton(JButton button, ActionListener onClick) {
|
||||
// remove to ensure listeners don't accumulate over many initializations
|
||||
@@ -96,17 +99,6 @@ public enum CMessage implements ICDoc {
|
||||
VMessage.SINGLETON_INSTANCE.getTarMessage().setText(s0);
|
||||
}
|
||||
|
||||
/** Updates counter label in message area.
|
||||
* @param match
|
||||
* @param gameState */
|
||||
public void updateGameInfo(MatchController match) {
|
||||
VMessage.SINGLETON_INSTANCE.getLblGames().setText(
|
||||
match.getGameType().toString() + ": Game #"
|
||||
+ (match.getPlayedGames().size() + 1)
|
||||
+ " of " + match.getGamesPerMatch()
|
||||
+ ", turn " + match.getCurrentGame().getPhaseHandler().getTurn());
|
||||
}
|
||||
|
||||
/** Flashes animation on input panel if play is currently waiting on input. */
|
||||
public void remind() {
|
||||
SDisplayUtil.remind(VMessage.SINGLETON_INSTANCE);
|
||||
@@ -120,6 +112,18 @@ public enum CMessage implements ICDoc {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.util.Observer#update(java.util.Observable, java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void update(Observable o, Object arg) {
|
||||
VMessage.SINGLETON_INSTANCE.getLblGames().setText(
|
||||
match.getGameType().toString() + ": Game #"
|
||||
+ (match.getPlayedGames().size() + 1)
|
||||
+ " of " + match.getGamesPerMatch()
|
||||
+ ", turn " + match.getCurrentGame().getPhaseHandler().getTurn());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.ICDoc#update()
|
||||
*/
|
||||
@@ -130,4 +134,14 @@ public enum CMessage implements ICDoc {
|
||||
lastFocusedButton.requestFocusInWindow();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this method.
|
||||
* @param match
|
||||
*/
|
||||
public void setModel(MatchController match0) {
|
||||
match = match0;
|
||||
match.getCurrentGame().getPhaseHandler().addObserver(this);
|
||||
update(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
package forge.gui.match.views;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.util.Iterator;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
import java.util.SortedSet;
|
||||
@@ -172,11 +171,6 @@ public enum VAntes implements IVDoc<CAntes>, Observer {
|
||||
picPanel.setCard(c0);
|
||||
}
|
||||
|
||||
/** @return {@link forge.Card} */
|
||||
public Card getCard() {
|
||||
return card;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(AntePanel o) {
|
||||
return o.card.getUniqueNumber() - card.getUniqueNumber();
|
||||
|
||||
Reference in New Issue
Block a user