From be59baaa024f8c5f02ec14fe34155e736548046b Mon Sep 17 00:00:00 2001 From: emkael Date: Wed, 9 Nov 2016 13:29:55 +0100 Subject: * BCDD code for parsing PBN files added --- Aktywator/PBN.cs | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) (limited to 'Aktywator/PBN.cs') 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(); - } } } -- cgit v1.2.3