summaryrefslogtreecommitdiff
path: root/Aktywator/PBN.cs
diff options
context:
space:
mode:
authorMichał Zimniewicz <michzimny@users.noreply.github.com>2016-11-19 17:53:52 +0100
committerGitHub <noreply@github.com>2016-11-19 17:53:52 +0100
commit001db1e8d9389c092def6037fe4ac098d5e0e535 (patch)
treec5c22053a517f1b9bbb553171e84eb4334f24377 /Aktywator/PBN.cs
parentfc037b277004b98ee740a1fc5191e6571b6cbaf3 (diff)
parent211efd174ac0333cdf9f40695ea5673e5bfb7b95 (diff)
Merge pull request #3 from emkael/hand-evaluation
Dane analizy w widne wczytywane wraz z rozkładami
Diffstat (limited to 'Aktywator/PBN.cs')
-rw-r--r--Aktywator/PBN.cs36
1 files changed, 14 insertions, 22 deletions
diff --git a/Aktywator/PBN.cs b/Aktywator/PBN.cs
index ad7ac99..f6d5393 100644
--- a/Aktywator/PBN.cs
+++ b/Aktywator/PBN.cs
@@ -2,12 +2,14 @@
using System.Collections.Generic;
using System.Text;
using System.IO;
+using System.Windows.Forms;
namespace Aktywator
{
class PBN
{
public HandRecord[] handRecords;
+ public DDTable[] ddTables;
protected int lowBoard;
protected int highBoard;
private int _count;
@@ -19,33 +21,23 @@ namespace Aktywator
public PBN(string filename, int lowBoard, int highBoard)
{
this.handRecords = new HandRecord[highBoard + 1];
+ this.ddTables = new DDTable[highBoard + 1];
- StreamReader f = new StreamReader(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read));
- try
+ this.lowBoard = lowBoard;
+ this.highBoard = highBoard;
+
+ this._count = 0;
+ PBNFile pbn = new PBNFile(filename);
+ foreach (PBNBoard board in pbn.Boards)
{
- int board = lowBoard;
- bool canBeRead = false;
- _count = 0;
- while (!f.EndOfStream && (board <= highBoard))
+ int boardNo = Int32.Parse(board.GetNumber());
+ if (lowBoard <= boardNo && boardNo <= 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++;
- }
+ this.handRecords[boardNo] = new HandRecord(board.GetLayout());
+ this.ddTables[boardNo] = new DDTable(board);
+ this._count++;
}
}
- finally
- {
- f.Close();
- }
}
}