summaryrefslogtreecommitdiff
path: root/Aktywator/PBN.cs
diff options
context:
space:
mode:
authorMichal Zimniewicz <mzimniew@man.poznan.pl>2015-01-28 10:49:16 +0100
committerMichal Zimniewicz <mzimniew@man.poznan.pl>2015-01-28 10:58:38 +0100
commit29d9771333f9f996208b0e3dbce95dd80cddf8e9 (patch)
tree7160accad1184eabc2dbfadf4175aeeb6abf82dc /Aktywator/PBN.cs
parenta331533373a95820a89aa93fead351ceb9a30046 (diff)
initial commit with unreleased version 1.0.4
Diffstat (limited to 'Aktywator/PBN.cs')
-rw-r--r--Aktywator/PBN.cs52
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();
+ }
+ }
+
+ }
+}