From 3fd493b395d27749749587518d76a4e5d648920c Mon Sep 17 00:00:00 2001 From: emkael Date: Wed, 9 Nov 2016 14:20:32 +0100 Subject: * PBN double-dummy data support for HandEvaluation table --- Aktywator/Bws.cs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'Aktywator/Bws.cs') diff --git a/Aktywator/Bws.cs b/Aktywator/Bws.cs index 0be06df..eda99a1 100644 --- a/Aktywator/Bws.cs +++ b/Aktywator/Bws.cs @@ -104,6 +104,8 @@ namespace Aktywator return false; if (!sql.checkTableExists("HandRecord")) return false; + if (!sql.checkTableExists("HandEvaluation")) + return false; return true; } @@ -167,6 +169,19 @@ namespace Aktywator catch (OleDbException) { } + try + { + sql.query("CREATE TABLE HandEvaluation (`Section` integer, `Board` integer, " + + "NorthSpades integer,NorthHearts integer,NorthDiamonds integer,NorthClubs integer,NorthNotrump integer," + + "EastSpades integer,EastHearts integer,EastDiamonds integer,EastClubs integer,EastNotrump integer," + + "SouthSpades integer,SouthHearts integer,SouthDiamonds integer,SouthClubs integer,SouthNotrump integer," + + "WestSpades integer,WestHearts integer,WestDiamonds integer,WestClubs integer,WestNotrump integer," + + "NorthHcp integer,EastHcp integer,SouthHcp integer,WestHcp integer" + + ");"); + } + catch (OleDbException) + { + } } public void updateSettings() @@ -377,6 +392,7 @@ namespace Aktywator public void loadHandRecords(PBN pbn) { sql.query("DELETE FROM HandRecord"); + sql.query("DELETE FROM HandEvaluation"); for (int i = 0; i < pbn.handRecords.Length; i++) if (pbn.handRecords[i] != null) for (int section = 1; section <= highSection(); section++) @@ -403,6 +419,24 @@ namespace Aktywator str.Append(b.west[2]); str.Append("','"); str.Append(b.west[3]); str.Append("')"); sql.query(str.ToString()); + int[,] ddTable = pbn.ddTables[i].GetDDTable(); + if (ddTable != null) + { + StringBuilder ddStr = new StringBuilder(); + ddStr.Append("INSERT INTO HandEvaluation VALUES("); + ddStr.Append(section); ddStr.Append(","); + ddStr.Append(i); ddStr.Append(","); + for (int player = 0; player < 4; player++) + { + for (int denom = 0; denom < 5; denom++) + { + ddStr.Append(ddTable[player, denom]); + ddStr.Append(","); + } + } + ddStr.Append("0,0,0,0)"); // HCP not supported yet + sql.query(ddStr.ToString()); + } } } } -- cgit v1.2.3 From 0cfcb31daea464584315263225381ba53c24a9eb Mon Sep 17 00:00:00 2001 From: emkael Date: Wed, 9 Nov 2016 14:25:56 +0100 Subject: * HCP support for HandEvaluation table --- Aktywator/Bws.cs | 10 +++++++++- Aktywator/HandRecord.cs | 31 +++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) (limited to 'Aktywator/Bws.cs') diff --git a/Aktywator/Bws.cs b/Aktywator/Bws.cs index eda99a1..87c9081 100644 --- a/Aktywator/Bws.cs +++ b/Aktywator/Bws.cs @@ -434,7 +434,15 @@ namespace Aktywator ddStr.Append(","); } } - ddStr.Append("0,0,0,0)"); // HCP not supported yet + for (int j = 0; j < 4; j++) + { + ddStr.Append(b.hpcs[j]); + if (j < 3) + { + ddStr.Append(","); + } + } + ddStr.Append(")"); sql.query(ddStr.ToString()); } } diff --git a/Aktywator/HandRecord.cs b/Aktywator/HandRecord.cs index bd0e9f9..199e94f 100644 --- a/Aktywator/HandRecord.cs +++ b/Aktywator/HandRecord.cs @@ -10,6 +10,7 @@ namespace Aktywator public string[] east; public string[] south; public string[] west; + public int[] hpcs; public HandRecord() { @@ -19,6 +20,31 @@ namespace Aktywator west = new string[4]; } + private int _hpcFromHand(string hand) + { + int hpc = 0; + foreach (char c in hand) + { + if (c == 'a' || c == 'A') + { + hpc += 4; + } + if (c == 'k' || c == 'K') + { + hpc += 3; + } + if (c == 'q' || c == 'Q') + { + hpc += 2; + } + if (c == 'j' || c == 'J') + { + hpc += 1; + } + } + return hpc; + } + public HandRecord(string pbnString) { string[] hand = pbnString.Split(' '); @@ -26,6 +52,11 @@ namespace Aktywator east = hand[1].Split('.'); south = hand[2].Split('.'); west = hand[3].Split('.'); + hpcs = new int[4]; + for (int i = 0; i < 4; i++) + { + hpcs[i] = this._hpcFromHand(hand[i]); + } } } } -- cgit v1.2.3