Esempio n. 1
0
 //// add_stone adds move to the model, assuming it has valid indexes.
 //// row, col are one-based, as we talk about go boards.
 ////
 public Move AddStone(Move move)
 {
     // This debug.assert could arguably be a throw if we think of this function
     // as platform/library.
     MyDbg.Assert(this.moves[move.Row - 1, move.Column - 1] == null,
                  "Ensure board has no stone at location.");
     this.moves[move.Row - 1, move.Column - 1] = move;
     return(move);
 }
Esempio n. 2
0
        //// ReleaseCurrentMove releases the current move adornment so that it can be
        //// acquired to apply to another move.
        ////
        public static void ReleaseCurrentMove()
        {
            var move = Adornments.CurrentMoveAdornment.Move;

            // This debug.assert could arguably be a throw if we think of this function
            // as platform/library.
            MyDbg.Assert(move != null, "Do not have current move adornment.");
            move.Adornments.Remove(Adornments.CurrentMoveAdornment);
            Adornments.CurrentMoveAdornment.Move   = null;
            Adornments.CurrentMoveAdornment.Cookie = null;
        }
Esempio n. 3
0
 //// GetCurrentMove reserves or locks the current move adornment.
 ////
 public static void GetCurrentMove(Move move, UIElement cookie)
 {
     // This debug.assert could arguably be a throw if we think of this function
     // as platform/library.
     MyDbg.Assert(Adornments.CurrentMoveAdornment.Move == null,
                  "Already have current move adornment at row, col: "); // +
     //Adornments.CurrentMoveAdornment.Move.Row.ToString() + ", " +
     //Adornments.CurrentMoveAdornment.Move.Column.ToString() + ".");
     Adornments.CurrentMoveAdornment.Move   = move;
     Adornments.CurrentMoveAdornment.Cookie = cookie;
     move.AddAdornment(Adornments.CurrentMoveAdornment);
 }
Esempio n. 4
0
        public GameInfo(Game g)
        {
            this.CommentChanged = false;
            this.InitializeComponent();
            // Ensure dialog overlays entire main window so that it cannot handle input.
            var bounds = Window.Current.Bounds;

            this.gameInfoGrid.Width  = bounds.Width;
            this.gameInfoGrid.Height = bounds.Height;
            // Fill in dialog ...
            this.Game = g;
            MyDbg.Assert(g.MiscGameInfo != null);
            var props = g.MiscGameInfo;

            this.gameInfoPB.Text = g.PlayerBlack;
            this.gameInfoPW.Text = g.PlayerWhite;
            this.gameInfoBR.Text = props.ContainsKey("BR") ? props["BR"][0] : "";
            this.gameInfoWR.Text = props.ContainsKey("WR") ? props["WR"][0] : "";
            this.gameInfoBT.Text = props.ContainsKey("BT") ? props["BT"][0] : "";
            this.gameInfoWT.Text = props.ContainsKey("WT") ? props["WT"][0] : "";
            // We don't respond to any handicap changes at this point.  It is too complicated in terms of code
            // changes for little value.  Users can use the New Game command, and if they have already started,
            // then can't change the handicap anyway.
            this.gameInfoHA.Text       = g.Handicap.ToString() + " -- use new game command to set handicap";
            this.gameInfoHA.IsReadOnly = true;
            this.gameInfoKM.Text       = g.Komi;
            this.gameInfoRU.Text       = props.ContainsKey("RU") ? props["RU"][0] : "";
            this.gameInfoSZ.Text       = g.Board.Size.ToString();
            // We don't respond to any handicap changes at this point.
            this.gameInfoSZ.IsReadOnly = true;
            this.gameInfoDT.Text       = props.ContainsKey("DT") ? props["DT"][0] : "";
            this.gameInfoTM.Text       = props.ContainsKey("TM") ? props["TM"][0] : "";
            this.gameInfoEV.Text       = props.ContainsKey("EV") ? props["EV"][0] : "";
            this.gameInfoPC.Text       = props.ContainsKey("PC") ? props["PC"][0] : "";
            this.gameInfoGN.Text       = props.ContainsKey("GN") ? props["GN"][0] : "";
            this.gameInfoON.Text       = props.ContainsKey("ON") ? props["ON"][0] : "";
            this.gameInfoRE.Text       = props.ContainsKey("RE") ? props["RE"][0] : "";
            this.gameInfoAN.Text       = props.ContainsKey("AN") ? props["AN"][0] : "";
            this.gameInfoGC.Text       = g.Comments;
        }