From 29d9771333f9f996208b0e3dbce95dd80cddf8e9 Mon Sep 17 00:00:00 2001 From: Michal Zimniewicz Date: Wed, 28 Jan 2015 10:49:16 +0100 Subject: initial commit with unreleased version 1.0.4 --- Aktywator/PBN.cs | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Aktywator/PBN.cs (limited to 'Aktywator/PBN.cs') diff --git a/Aktywator/PBN.cs b/Aktywator/PBN.cs new file mode 100644 index 0000000..ad7ac99 --- /dev/null +++ b/Aktywator/PBN.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; + +namespace Aktywator +{ + class PBN + { + public HandRecord[] handRecords; + protected int lowBoard; + protected int highBoard; + private int _count; + public int count + { + get { return _count; } + } + + public PBN(string filename, int lowBoard, int highBoard) + { + this.handRecords = new HandRecord[highBoard + 1]; + + StreamReader f = new StreamReader(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read)); + try + { + int board = lowBoard; + bool canBeRead = false; + _count = 0; + while (!f.EndOfStream && (board <= highBoard)) + { + string line = f.ReadLine(); + if (line.Trim() == "[Board \"" + board + "\"]") + canBeRead = true; + else if (canBeRead && (line.Substring(0, 6) == "[Deal ")) + { + line = line.Substring(line.IndexOf(':') + 1); + line = line.Substring(0, line.IndexOf('"')); + handRecords[board] = new HandRecord(line); + canBeRead = false; + _count++; + board++; + } + } + } + finally + { + f.Close(); + } + } + + } +} -- cgit v1.2.3