/// <summary> /// Creates a tsumego problem from the contents of an SGF file downloaded from online-go.com using /// the Ruby downloader. /// </summary> /// <param name="data">The contents of an SGF file.</param> /// <returns></returns> public static TsumegoProblem CreateFromSgfText(string data) { SgfParser parser = new SgfParser(); var collection = parser.Parse(data); SgfGameTree sgfTree = collection.GameTrees.First(); string problemName = ""; StoneColor playerToPlay = StoneColor.None; foreach (var node in sgfTree.Sequence) { if (node["GN"] != null) { problemName = node["GN"].Value <string>(); } if (node["PL"] != null) { SgfColor sgfColor = node["PL"].Value <SgfColor>(); switch (sgfColor) { case SgfColor.Black: playerToPlay = StoneColor.Black; break; case SgfColor.White: playerToPlay = StoneColor.White; break; } } } return(new TsumegoProblem(problemName, sgfTree, playerToPlay)); }
public SgfPlayerToPlayProperty(SgfColor color) : base("PL", new SgfColorValue(color) ) { }