MVC organization: Moved instantiation of AI from FView to FModel.

This commit is contained in:
Doublestrike
2012-01-22 07:43:38 +00:00
parent a2dbe6ff4a
commit a149f9b32d
3 changed files with 20 additions and 15 deletions

View File

@@ -78,7 +78,7 @@ public final class AllZone {
private static CardFactoryInterface cardFactory = null;
/** Constant <code>inputControl</code>. */
private static final InputControl INPUT_CONTROL = new InputControl(Singletons.getModel());
private static InputControl inputControl = null;
/** */
private static FMatchState matchState = new FMatchState();
@@ -379,7 +379,12 @@ public final class AllZone {
* @since 1.0.15
*/
public static InputControl getInputControl() {
return AllZone.INPUT_CONTROL;
return AllZone.inputControl;
}
/** @param i0 &emsp; {@link forge.gui.input.InputControl} */
public static void setInputControl(InputControl i0) {
AllZone.inputControl = i0;
}
/**

View File

@@ -26,8 +26,12 @@ import java.io.PrintStream;
import net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor;
import arcane.util.MultiplexOutputStream;
import forge.AllZone;
import forge.ComputerAIGeneral;
import forge.ComputerAIInput;
import forge.Constant;
import forge.HttpUtil;
import forge.gui.input.InputControl;
import forge.properties.ForgePreferences;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
@@ -88,6 +92,10 @@ public class FModel {
throw new RuntimeException(exn);
}
// Instantiate AI
AllZone.setInputControl(new InputControl(FModel.this));
AllZone.getInputControl().setComputer(new ComputerAIInput(new ComputerAIGeneral()));
// TODO these should be set along with others all at the same time, not
// here
Constant.Runtime.MILL[0] = this.preferences.isMillingLossCondition();

View File

@@ -21,8 +21,6 @@ import javax.swing.SwingUtilities;
import net.slightlymagic.braids.util.UtilFunctions;
import forge.AllZone;
import forge.ComputerAIGeneral;
import forge.ComputerAIInput;
import forge.control.FControl;
import forge.view.home.SplashFrame;
import forge.view.toolbox.CardFaceSymbols;
@@ -42,8 +40,7 @@ public class FView {
/**
* The splashFrame field is guaranteed to exist when this constructor exits.
*
* @param skin0
* the skin
* @param skin0 &emsp; {@link forge.view.toolbox.FSkin}
*/
public FView(final FSkin skin0) {
this.skin = skin0;
@@ -72,7 +69,7 @@ public class FView {
/**
* Allows singleton (global) access to a progress bar (which must be set first).
*
* @return a progress monitor having only one phase; may be null
* @return {@link forge.view.toolbox.FProgressBar}
*/
public final FProgressBar getProgressBar() {
return this.barProgress;
@@ -81,18 +78,18 @@ public class FView {
/**
* Sets a progress bar so it can be accessed via singletons.
*
* @param bar0 &emsp; An FProgressBar object
* @param bar0 &emsp; {@link forge.view.toolbox.FProgressBar}
*/
public final void setProgressBar(FProgressBar bar0) {
this.barProgress = bar0;
}
/** @return FSkin */
/** @return {@link forge.view.toolbox.FSkin} */
public FSkin getSkin() {
return this.skin;
}
/** @param skin0 &emsp; FSkin */
/** @param skin0 &emsp; {@link forge.view.toolbox.FSkin} */
public void setSkin(final FSkin skin0) {
this.skin = skin0;
}
@@ -118,11 +115,6 @@ public class FView {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
// TODO there must be a better place for this. ////////////
AllZone.getInputControl().setComputer(new ComputerAIInput(new ComputerAIGeneral()));
/////////////////////////////////////
final GuiTopLevel g = new GuiTopLevel();
AllZone.setDisplay(g);
g.getController().changeState(FControl.HOME_SCREEN);