/// <summary> /// Constructs a root game object, along with a complete game tree from /// the specified SGFGameTree object. /// </summary> /// <param name="sgfGameTree">The SGF game tree object.</param> public Game(SGFGameTree sgfGameTree) { //GameInfo = CreateGameInfoFromSGF(sgfGameTree); //InitializeFromGameInfo(); GameInfo = new GameInfo() { FreePlacedHandicap = true }; CreateGameTree(sgfGameTree, this); }
private static void CreateGameTree(SGFGameTree root, Game p) { if (p.GameInfo != null) { foreach (var m in root.Sequence.GetRootProperties()) { if (PropertyHandlers.ContainsKey(m.Name)) { PropertyHandlers[m.Name](p, m); } if (!PropertiesToExclude.Contains(m.Name)) { p.sgfProperties.Add(m); } } p.InitializeFromGameInfo(); } foreach (var m in root.Sequence.GetProperties()) { if (PropertyHandlers.ContainsKey(m.Name)) { p = PropertyHandlers[m.Name](p, m); } if (!PropertiesToExclude.Contains(m.Name)) { p.sgfProperties.Add(m); } } foreach (var r in root.GameTrees) { CreateGameTree(r, p); } }
/// <summary> /// Parse an SGFCollection object from a TextReader. /// </summary> /// <param name="sr">The source TextReader.</param> public void Read(TextReader sr) { sr.EatWS(); while ((char)sr.Peek() == '(') { var gameTree = new SGFGameTree(); gameTree.Read(sr); GameTrees.Add(gameTree); sr.EatWS(); } }
internal void Read(TextReader sr) { char c = (char)sr.Read(); if (c != '(') throw new InvalidDataException("Game-tree doesn't begin with a '('."); Sequence.Read(sr); sr.EatWS(); while ((char)sr.Peek() == '(') { SGFGameTree gameTree = new SGFGameTree(); gameTree.Read(sr); GameTrees.Add(gameTree); sr.EatWS(); } c = (char)sr.Read(); if (c != ')') throw new InvalidDataException("Game-tree doesn't end with a ')'."); }
internal void Read(TextReader sr) { char c = (char)sr.Read(); if (c != '(') { throw new InvalidDataException("Game-tree doesn't begin with a '('."); } Sequence.Read(sr); sr.EatWS(); while ((char)sr.Peek() == '(') { SGFGameTree gameTree = new SGFGameTree(); gameTree.Read(sr); GameTrees.Add(gameTree); sr.EatWS(); } c = (char)sr.Read(); if (c != ')') { throw new InvalidDataException("Game-tree doesn't end with a ')'."); } }
private static void CreateGameTree(SGFGameTree root, Game p) { if (p.GameInfo != null) { foreach (var m in root.Sequence.GetRootProperties()) { if (PropertyHandlers.ContainsKey(m.Name)) PropertyHandlers[m.Name](p, m); if (!PropertiesToExclude.Contains(m.Name)) p.sgfProperties.Add(m); } p.InitializeFromGameInfo(); } foreach (var m in root.Sequence.GetProperties()) { if (PropertyHandlers.ContainsKey(m.Name)) p = PropertyHandlers[m.Name](p, m); if (!PropertiesToExclude.Contains(m.Name)) p.sgfProperties.Add(m); } foreach (var r in root.GameTrees) { CreateGameTree(r, p); } }