Exemplo n.º 1
0
        private void setLabelsOnBoard(GoMove gm)
        {
            short	nLabel = 0;
            Point p;
            if (null != gm.Labels)
            {
                int i = gm.Labels.Count;
                i = gm.Labels.Capacity;

                System.Collections.IEnumerator myEnumerator = gm.Labels.GetEnumerator();
                while (myEnumerator.MoveNext())
                {
                    p = (Point)myEnumerator.Current;
                    Grid[p.X,p.Y].SetLabel(++nLabel);
                }
            }
        }
Exemplo n.º 2
0
 private void setMarksOnBoard(GoMove gm)
 {
     Point p;
     if (null != gm.Labels)
     {
         System.Collections.IEnumerator myEnumerator = gm.Marks.GetEnumerator();
         while ( myEnumerator.MoveNext() )
         {
             p = (Point)myEnumerator.Current;
             Grid[p.X,p.Y].SetMark();
         }
     }
 }
Exemplo n.º 3
0
        /// <ZZZZZZZ>
        /// 
        /// </ZZZZZZZ>
        /// <ZZZZZ ZZZZ="ZZZZZZ"></ZZZZZ>
        /// <ZZZZZ ZZZZ="Z"></ZZZZZ>
        private void MouseUpHandler(Object sender,MouseEventArgs e)
        {
            Point p;
            GoMove	gmThisMove;

            p = PointToGrid(e.X,e.Y);
            if (!onBoard(p.X, p.Y) || !closeEnough(p,e.X, e.Y)|| Grid[p.X,p.Y].HasStone())
                return; //ZZZZZZ ZZZZ Z ZZZZ ZZZZZ.

            //ZZZZZ ZZZZ ZZ Z ZZZZZZ ZZZZ, ZZ ZZZZ ZZ ZZZ ZZZ ZZZZ ZZ ZZZ ZZZZ ZZZZ
            gmThisMove = new GoMove(p.X, p.Y, m_colorToPlay, 0);
            PlayNext(ref gmThisMove);
            gameTree.addMove(gmThisMove);
        }
Exemplo n.º 4
0
 //ZZZZ ZZ ZZZZZZZZ ZZ ZZZZZZZ ZZZ ZZZ ZZZZ ZZZZ ZZZZ.
 void recordMove(Point p, StoneColor colorToPlay)
 {
     Grid[p.X,p.Y].setStone(colorToPlay);
     // ZZZZZZ ZZZZ ZZZZ.
     m_gmLastMove = new GoMove(p.X, p.Y, colorToPlay, nSeq++);
 }
Exemplo n.º 5
0
 public void ResetBoard()
 {
     int i,j;
     for (i=0; i<nSize; i++)
         for (j=0; j<nSize; j++)
             Grid[i,j].removeStone();
     m_gmLastMove = null;
     Invalidate(null);
 }
Exemplo n.º 6
0
 private void appendDeadGroup(ref GoMove gm, StoneColor c)
 {
     ArrayList a = new ArrayList();
     for (int i=0; i<nSize; i++)
         for (int j=0; j<nSize; j++)
             if (Grid[i,j].isKilled())
             {
                 Point pt = new Point(i,j);
                 a.Add(pt);
                 Grid[i,j].setNoKilled();
             }
     gm.DeadGroup = a;
     gm.DeadGroupColor = c;
 }
Exemplo n.º 7
0
        public void PlayNext(ref GoMove gm)
        {
            Point p = gm.Point;
            m_colorToPlay = gm.Color;	//ZZZ ZZZZZ, ZZZZZZZZZ ZZZZ ZZZZZZ ZZZZ ZZZZ ZZZZ.

            //ZZZZZ ZZZ ZZZZZ/ZZZZZZ ZZ ZZZZZZZ ZZZZZZZZZ
            clearLabelsAndMarksOnBoard();

            if (m_gmLastMove != null)
                repaintOneSpotNow(m_gmLastMove.Point);

            bDrawMark = true;
            Grid[p.X,p.Y].setStone(gm.Color);
            m_gmLastMove = new GoMove(p.X, p.Y, gm.Color, nSeq++);
            //ZZZ ZZZZZ/ZZZZ
            setLabelsOnBoard(gm);
            setMarksOnBoard(gm);

            doDeadGroup(nextTurn(m_colorToPlay));
            //ZZ ZZZ ZZZZZ ZZZ ZZZZ, ZZ ZZZZ ZZ ZZZZZZZZ ZZZZ, ZZ ZZZZ ZZ ZZZ ZZZZZZZ ZZZZ ZZ ZZZZZZZZ.
            if (m_fAnyKill)
                appendDeadGroup(ref gm, nextTurn(m_colorToPlay));
            else //ZZZZ ZZ ZZZ ZZ ZZ'Z Z ZZZZZZZ
            {
                doDeadGroup(m_colorToPlay);
                if (m_fAnyKill)
                    appendDeadGroup(ref gm, m_colorToPlay);
            }
            m_fAnyKill = false;

            optRepaint();

            //ZZZZZZ ZZZZZ
            m_colorToPlay = nextTurn(m_colorToPlay);

            //ZZZZ ZZZ ZZZZZZZ, ZZ ZZZ
            textBox1.Clear();
            textBox1.AppendText(gm.Comment);
        }
Exemplo n.º 8
0
        /*
         * ZZZZ ZZZ ZZZZ ZZ ZZZZ ZZZ ZZZZ ZZZZZZZZZ ZZ ZZZZ ZZZZZZ ZZZZ ZZZZ ZZ ZZZZZZ.
         * ZZZZ ZZ ZZ:
         * 	1. ZZZZZZ ZZZ ZZZZZZZ ZZZZ ZZZZ ZZZ ZZZZZ
         *  1.1 ZZZZ ZZZZZZ ZZZ "ZZZZZZZZ" ZZZZZZZZZZ
         *	2. store the stones got killed by current move
         *  3. ZZZZZZZZZZ ZZZ ZZZ "ZZZZZZZZ"
         */
        public void PlayPrev(GoMove gm)
        {
            Point p = gm.Point;
            m_colorToPlay = gm.Color;

            clearLabelsAndMarksOnBoard();
            m_gmLastMove = gameTree.peekPrev();

            bDrawMark = true;
            Grid[p.X, p.Y].die();
            if (gm.DeadGroup != null)
            {
                foreach (Point pt in gm.DeadGroup)
                {
                    Grid[pt.X, pt.Y].setStone(gm.DeadGroupColor);
                }
            }
            optRepaint();

            //show the movement information
            textBox1.Clear();
            textBox1.AppendText(gm.Comment);
            return;
        }
Exemplo n.º 9
0
 public void updateResult(GoMove gm)
 {
 }
Exemplo n.º 10
0
 public void addAMove(GoMove gm)
 {
     gm.Seq = m_total ++;
     m_seq++;
     m_moves.Add(gm);
 }
Exemplo n.º 11
0
        /**
         * ZZZZZZZ Z ZZZ ZZZ ZZZ ZZZZZZZZZZZZZ ZZZZZ
         * ZZ ZZZZZ ZZ Z ZZZZ, ZZ ZZZZZZ ZZZZZZZZZZZ.
         * ZZZZZZZZZZ, ZZZ ZZZZZZZ ZZZ ZZZZ ZZZZ ZZZ ZZZZ ZZ ZZZZ.
         *
         * ZZZZ: ZZ/ZZ ZZZ ZZZZZZZZZ ZZZ ZZZZ ZZZZZZZZ ZZZZZ ZZZZZZ, ZZZ Z ZZZZZ'Z ZZZZ ZZZ ZZZZZZZ ZZZ
         */
        Boolean processASection(ArrayList arrKV)
        {
            Boolean fMultipleMoves = false;   //ZZZZZZZ ZZZZ ZZZZZZZ ZZZ ZZZZZZZZ ZZZZZ.
            GoMove gm = null;

            string key, strValue;

            for (int i = 0;i<arrKV.Count;i++)
            {
                key = ((KeyValuePair)(arrKV[i])).k;
                for (int j=0; j<((KeyValuePair)(arrKV[i])).alV.Count; j++)
                {
                    strValue = (string)(((KeyValuePair)(arrKV[i])).alV[j]);

                    if (key.Equals("B"))   //ZZZZZ ZZZZZ
                    {
                        Debug.Assert(gm == null);
                        gm = new GoMove(strValue, StoneColor.Black);
                    }
                    else if (key.Equals("W"))  //ZZZZZ ZZZZZ
                    {
                        Debug.Assert(gm == null);
                        gm = new GoMove(strValue, StoneColor.White);
                    }
                    else if (key.Equals("C"))  //ZZZZZZZ
                    {
                        //ZZZZZ.ZZZZZZ(Z>0);
                        if (gm != null)
                            gm.Comment = strValue;
                        else	//ZZZ ZZ ZZ ZZZ ZZZZ ZZZZZZZ
                            _gi.comment += strValue;
                    }
                    else if (key.Equals("L"))  //ZZZZZ
                    {
                        if (gm != null)
                            gm.addLabel(strValue);
                        else	//ZZZ ZZ ZZ ZZZ ZZZZ ZZZZZZZ
                            _stGameComment += strValue;
                    }

                    else if (key.Equals("M"))  //ZZZZ
                    {
                        if (gm != null)
                            gm.addMark(strValue);
                        else	//ZZZ ZZ ZZ ZZZ ZZZZ ZZZZZZZ
                            _gi.comment += strValue;
                    }
                    else if (key.Equals("AW"))		//ZZZ ZZZZZ ZZZZZ
                    {
                        fMultipleMoves = true;
                        gm = new GoMove(strValue, StoneColor.White);
                    }
                    else if (key.Equals("AB"))		//ZZZ ZZZZZ ZZZZZ
                    {
                        fMultipleMoves = true;
                        gm = new GoMove(strValue, StoneColor.Black);
                    }
                    else if (key.Equals("HA"))
                        _gi.handicap = (strValue);
                    else if (key.Equals("BR"))
                        _gi.rankBlack = (strValue);
                    else if (key.Equals("PB"))
                        _gi.playerBlack = (strValue);
                    else if (key.Equals("PW"))
                        _gi.playerWhite = (strValue);
                    else if (key.Equals("WR"))
                        _gi.rankWhite = (strValue);
                    else if (key.Equals("DT"))
                        _gi.date = (strValue);
                    else if (key.Equals("KM"))
                        _gi.km = (strValue);
                    else if (key.Equals("RE"))
                        _gi.result = (strValue);
                    else if (key.Equals("SZ"))
                        _gi.size = (strValue);
                    else if (key.Equals("EV"))
                        _gi.gameEvent = (strValue);
                    else if (key.Equals("PC"))
                        _gi.location = (strValue);
                    else if (key.Equals("TM"))
                        _gi.time = (strValue);
                    else if (key.Equals("GN"))
                        _gi.gameName = strValue;

                    else if (key.Equals("FF"))
                        _gi.unknown_ff = (strValue);
                    else if (key.Equals("GM"))
                        _gi.unknown_gm = (strValue);
                    else if (key.Equals("VW"))
                        _gi.unknown_vw = (strValue);
                    else if (key.Equals("US"))
                        _gi.unknown_vw = (strValue);

                    else if (key.Equals("BS"))
                        _gi.unknown_vw = (strValue);
                    else if (key.Equals("WS"))
                        _gi.unknown_vw = (strValue);
                    else if (key.Equals("ID"))
                        _gi.unknown_vw = (strValue);
                    else if (key.Equals("KI"))
                        _gi.unknown_vw = (strValue);
                    else if (key.Equals("SO"))
                        _gi.unknown_vw = (strValue);
                    else if (key.Equals("TR"))
                        _gi.unknown_vw = (strValue);
                    else if (key.Equals("LB"))
                        _gi.unknown_vw = (strValue);
                    else if (key.Equals("RO"))
                        _gi.unknown_vw = (strValue);

                    //ZZZZ ZZZZZ
                    else
                        System.Diagnostics.Debug.Assert(false, "unhandle key: " + key + " "+ strValue);

                    //ZZZZZZZZZ ZZZ ZZZZ ZZZZZZ ZZZ ZZZZ ZZ ZZZZ ZZZZ (ZZ, ZZ) ZZZZ ZZZZZZZZ ZZZZZ.
                    if (fMultipleMoves)
                    {
                        _currVar.addAMove(gm);
                    }
                }
            }

            //ZZZ ZZZ ZZZZ ZZ ZZZZZZZ ZZZZZZZZZ.
            if (!fMultipleMoves && gm != null)
            {
                _currVar.addAMove(gm);
            }
            return true;
        }
Exemplo n.º 12
0
 public void updateResult(GoMove gm)
 {
     _currVar.updateResult(gm);
 }
Exemplo n.º 13
0
 public void addMove(GoMove gm)
 {
     _currVar.addAMove(gm);
 }