Example #1
0
File: Game.cs Project: serd/GoSharp
        /// <summary>
        /// Adds stones to the board in a rectangular area.
        /// </summary>
        /// <param name="x1">The left coordinate of the rectangle.</param>
        /// <param name="y1">The top coordinate of the rectangle.</param>
        /// <param name="x2">The right coordinate of the rectangle.</param>
        /// <param name="y2">The bottom coordinate of the rectangle.</param>
        /// <param name="c">The color of the stone to add (or empty to clear).</param>
        public void SetupMove(int x1, int y1, int x2, int y2, Content c)
        {
            SGFProperty p = sgfProperties.SingleOrDefault(x => x.Name == ColorToSGFProp[c]);

            if (p == null)
            {
                p = new SGFProperty()
                {
                    Name = ColorToSGFProp[c]
                };
                sgfProperties.Add(p);
            }
            string       composed = Point.ConvertToSGF(x1, y1) + ":" + Point.ConvertToSGF(x2, y2);
            SGFPropValue v        = new SGFPropValue(composed);

            p.Values.Add(v);
            for (int i = x1; i <= x2; i++)
            {
                for (int j = y1; j <= y2; j++)
                {
                    Board[i, j] = c;
                }
            }
            setupMoves = null;
        }
Example #2
0
File: Game.cs Project: serd/GoSharp
        Game HandleBoardSize(SGFProperty p)
        {
            SGFPropValue v = p.Values[0];

            if (v.IsComposed)
            {
                GameInfo.BoardSizeX = v.NumX;
                GameInfo.BoardSizeY = v.NumY;
            }
            else
            {
                GameInfo.BoardSizeX = GameInfo.BoardSizeY = v.Num;
            }
            return(this);
        }
Example #3
0
File: Game.cs Project: serd/GoSharp
        /// <summary>
        /// Adds a stone to the board as a setup move.
        /// </summary>
        /// <param name="x">The X coordinate of the setup move.</param>
        /// <param name="y">The Y coordinate of the setup move.</param>
        /// <param name="c">The color of the stone to add (or empty to clear).</param>
        public void SetupMove(int x, int y, Content c)
        {
            SGFProperty p = sgfProperties.SingleOrDefault(z => z.Name == ColorToSGFProp[c]);

            if (p == null)
            {
                p = new SGFProperty()
                {
                    Name = ColorToSGFProp[c]
                };
                sgfProperties.Add(p);
            }
            SGFPropValue v = new SGFPropValue(Point.ConvertToSGF(x, y));

            p.Values.Add(v);
            Board[x, y] = c;
            setupMoves  = null;
        }
Example #4
0
 /// <summary>
 /// Adds stones to the board in a rectangular area.
 /// </summary>
 /// <param name="x1">The left coordinate of the rectangle.</param>
 /// <param name="y1">The top coordinate of the rectangle.</param>
 /// <param name="x2">The right coordinate of the rectangle.</param>
 /// <param name="y2">The bottom coordinate of the rectangle.</param>
 /// <param name="c">The color of the stone to add (or empty to clear).</param>
 public void SetupMove(int x1, int y1, int x2, int y2, Content c)
 {
     SGFProperty p = sgfProperties.SingleOrDefault(x => x.Name == ColorToSGFProp[c]);
     if (p == null)
     {
         p = new SGFProperty() { Name = ColorToSGFProp[c] };
         sgfProperties.Add(p);
     }
     string composed = Point.ConvertToSGF(x1, y1) + ":" + Point.ConvertToSGF(x2, y2);
     SGFPropValue v = new SGFPropValue(composed);
     p.Values.Add(v);
     for (int i = x1; i <= x2; i++)
     {
         for (int j = y1; j <= y2; j++)
         {
             Board[i, j] = c;
         }
     }
     setupMoves = null;
 }
Example #5
0
 /// <summary>
 /// Adds a stone to the board as a setup move.
 /// </summary>
 /// <param name="x">The X coordinate of the setup move.</param>
 /// <param name="y">The Y coordinate of the setup move.</param>
 /// <param name="c">The color of the stone to add (or empty to clear).</param>
 public void SetupMove(int x, int y, Content c)
 {
     SGFProperty p = sgfProperties.SingleOrDefault(z => z.Name == ColorToSGFProp[c]);
     if (p == null)
     {
         p = new SGFProperty() { Name = ColorToSGFProp[c] };
         sgfProperties.Add(p);
     }
     SGFPropValue v = new SGFPropValue(Point.ConvertToSGF(x, y));
     p.Values.Add(v);
     Board[x, y] = c;
     setupMoves = null;
 }