summaryrefslogtreecommitdiff
path: root/Aktywator/HandRecord.cs
diff options
context:
space:
mode:
authorMichal Zimniewicz <mzimniew@man.poznan.pl>2016-11-19 17:59:10 +0100
committerMichal Zimniewicz <mzimniew@man.poznan.pl>2016-11-19 17:59:10 +0100
commitcd8f6bf8c23f9a63669d7489dd9d49525c9df6e4 (patch)
treef274fec74eaa624cc86f1b50514d6bddcefd7b20 /Aktywator/HandRecord.cs
parent531b20117552e9a7a78bce3a70ad71acff2de340 (diff)
parent211efd174ac0333cdf9f40695ea5673e5bfb7b95 (diff)
Merge branch 'hand-evaluation' into validate-lead-card
Diffstat (limited to 'Aktywator/HandRecord.cs')
-rw-r--r--Aktywator/HandRecord.cs31
1 files changed, 31 insertions, 0 deletions
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]);
+ }
}
}
}