diff options
Diffstat (limited to 'Aktywator/PBN.cs')
-rw-r--r-- | Aktywator/PBN.cs | 52 |
1 files changed, 52 insertions, 0 deletions
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(); + } + } + + } +} |