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/HandRecord.cs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'Aktywator/HandRecord.cs') 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