Beispiel #1
0
        public override string ToString()
        {
            SGFCollection lSGFCollection = new SGFCollection();
            SGFSequence   lSGFSequence   = new SGFSequence();
            SGFNode       lSGFNode       = new SGFNode();

            CoordinateSystem lCoord = CoordinateSystem.GetCoordinateSystem(BoardSize);

            lSGFNode.AddProperty(new SGFProperty("GM", "1"));
            lSGFNode.AddProperty(new SGFProperty("FF", "4"));
            lSGFNode.AddProperty(new SGFProperty("CA", "UTF-8"));
            lSGFNode.AddProperty(new SGFProperty("SZ", BoardSize));
            lSGFNode.AddProperty(new SGFProperty("KM", Convert.ToString(Komi)));

            lSGFNode.AddPropertyIfNotEmpty(new SGFProperty("GN", GameName));
            lSGFNode.AddPropertyIfNotEmpty(new SGFProperty("ID", Identification));
            lSGFNode.AddPropertyIfNotEmpty(new SGFProperty("DT", Date));
            lSGFNode.AddPropertyIfNotEmpty(new SGFProperty("PB", BlackPlayerName));
            lSGFNode.AddPropertyIfNotEmpty(new SGFProperty("PW", WhitePlayerName));
            //			lSGFNode.AddPropertyIfNotEmpty(new SGFProperty("RS", Result));
            lSGFNode.AddPropertyIfNotEmpty(new SGFProperty("C", Comment));
            lSGFNode.AddPropertyIfNotEmpty(new SGFProperty("RU", Rules));
            lSGFNode.AddPropertyIfNotEmpty(new SGFProperty("PC", Place));
            lSGFNode.AddPropertyIfNotEmpty(new SGFProperty("WR", WhiteRank));
            lSGFNode.AddPropertyIfNotEmpty(new SGFProperty("BR", BlackRank));
            lSGFNode.AddPropertyIfNotEmpty(new SGFProperty("RE", Result));

            if (TimeLimit != 0)
            {
                lSGFNode.AddPropertyIfNotEmpty(new SGFProperty("TM", TimeLimit));
            }

            if (HandicapStones > 0)
            {
                lSGFNode.AddPropertyIfNotEmpty(new SGFProperty("HE", HandicapStones));
            }

            lSGFSequence.AddNode(lSGFNode);

            foreach (GameMove lGameMove in Moves)
            {
                lSGFNode = new SGFNode();

                lSGFNode.AddProperty(new SGFProperty(
                                         (lGameMove.SetupMove ? "A" : "") + (lGameMove.Player.IsBlack ? "B" : "W")
                                         , lCoord.ToSGFString(lGameMove.Move)));

                lSGFSequence.AddNode(lSGFNode);
            }

            if ((Territory[0].Count != 0) || (Territory[1].Count != 0))
            {
                lSGFNode = new SGFNode();

                for (int lTerritoryIndex = 0; lTerritoryIndex < 2; lTerritoryIndex++)
                {
                    if (Territory[lTerritoryIndex].Count != 0)
                    {
                        foreach (int lIndex in Territory[lTerritoryIndex])
                        {
                            lSGFNode.AddProperty(new SGFProperty(
                                                     "T" + (lTerritoryIndex == 0 ? "B" : "W"), lCoord.ToSGFString(lIndex)));
                        }
                    }
                }
                lSGFSequence.AddNode(lSGFNode);
            }

            lSGFCollection.AddSequence(lSGFSequence);

            return(lSGFCollection.ToString());
        }