summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-11-09 14:20:32 +0100
committeremkael <emkael@tlen.pl>2016-11-14 14:47:04 +0100
commit3fd493b395d27749749587518d76a4e5d648920c (patch)
tree325daa433c497945657a53e266b4fc5d102bf332
parentbe59baaa024f8c5f02ec14fe34155e736548046b (diff)
* PBN double-dummy data support for HandEvaluation table
-rw-r--r--Aktywator/Bws.cs34
-rw-r--r--Aktywator/DDTable.cs9
-rw-r--r--Aktywator/PBNBoard.cs3
3 files changed, 42 insertions, 4 deletions
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());
+ }
}
}
}
diff --git a/Aktywator/DDTable.cs b/Aktywator/DDTable.cs
index 38e0fbd..5de9c3b 100644
--- a/Aktywator/DDTable.cs
+++ b/Aktywator/DDTable.cs
@@ -14,7 +14,8 @@ namespace Aktywator
class DDTable
{
- public static char[] DENOMINATIONS = { 'C', 'D', 'H', 'S', 'N' };
+ public static char[] DENOMINATIONS = { 'S', 'H', 'D', 'C', 'N' };
+ private static char[] JFR_DENOMS = {'N', 'S', 'H', 'D', 'C'};
public static char[] PLAYERS = { 'N', 'E', 'S', 'W' };
private PBNBoard board;
@@ -58,11 +59,13 @@ namespace Aktywator
{
char player = playerAbility.Groups[1].Value[0];
int playerID = Array.IndexOf(PLAYERS, player);
- int denomID = 4;
+ int denomID;
+ int denom = 0;
foreach (char tricks in playerAbility.Groups[2].Value.ToCharArray())
{
+ denomID = Array.IndexOf(DENOMINATIONS, JFR_DENOMS[denom]);
result[playerID, denomID] = (tricks > '9') ? (tricks - 'A' + 10) : (tricks - '0');
- denomID--;
+ denom++;
}
}
return this.validateTable(result);
diff --git a/Aktywator/PBNBoard.cs b/Aktywator/PBNBoard.cs
index 605630c..fadfd22 100644
--- a/Aktywator/PBNBoard.cs
+++ b/Aktywator/PBNBoard.cs
@@ -87,7 +87,8 @@ namespace Aktywator
public String GetLayout()
{
- return this.GetField("Deal");
+ string[] dealParts = this.GetField("Deal").Split(':');
+ return dealParts[dealParts.Length - 1];
}
public String GetNumber()