|
4 | 4 | using System.Linq; |
5 | 5 | using System.Net; |
6 | 6 | using System.Text; |
| 7 | +using Newtonsoft.Json; |
7 | 8 | using Newtonsoft.Json.Linq; |
8 | 9 |
|
9 | 10 | namespace Nancy.Simple |
@@ -111,18 +112,25 @@ private static bool GetPlay(out int betValue, List<Card> cards, JToken community |
111 | 112 | return true; |
112 | 113 | } |
113 | 114 |
|
| 115 | + var commCount = communityCards.Count(); |
| 116 | + var allCards = new List<Card>(cards); |
| 117 | + foreach (var card in communityCards) |
| 118 | + { |
| 119 | + var rank = card["rank"].Value<string>(); |
| 120 | + var suit = card["suit"].Value<string>(); |
| 121 | + allCards.Add(new Card(rank,suit)); |
| 122 | + } |
114 | 123 |
|
115 | 124 | try |
116 | 125 | { |
117 | | - ContactRainman(); |
| 126 | + ContactRainman(allCards); |
118 | 127 | } |
119 | 128 | catch (Exception ex) |
120 | 129 | { |
121 | 130 |
|
122 | 131 | Console.Error.WriteLine(ex); |
123 | 132 | } |
124 | 133 |
|
125 | | - var commCount = communityCards.Count(); |
126 | 134 | if (commCount == 3) |
127 | 135 | { |
128 | 136 |
|
@@ -214,15 +222,24 @@ public static int SmallRaise(int currentBuyIn, int currentBet, int smallBlind) |
214 | 222 | return currentBuyIn + currentBet + smallBlind*2; |
215 | 223 | } |
216 | 224 |
|
217 | | - public static void ContactRainman() |
| 225 | + public static void ContactRainman(List<Card> allCards) |
218 | 226 | { |
219 | 227 | string address = "http://rainman.leanpoker.org/rank"; |
220 | 228 | var httpWebRequest = (HttpWebRequest)WebRequest.Create(address); |
221 | 229 | httpWebRequest.ContentType = "text/plain"; |
222 | 230 | httpWebRequest.Method = "POST"; |
223 | 231 |
|
224 | | - using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) |
| 232 | + using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream() |
| 233 | + )) |
225 | 234 | { |
| 235 | + var baseStr = "cards="; |
| 236 | + |
| 237 | + var result = JsonConvert.SerializeObject(allCards); |
| 238 | + Console.Error.WriteLine("Json sent: " + result); |
| 239 | + |
| 240 | + |
| 241 | + |
| 242 | + |
226 | 243 | string json = "cards=[{ \"rank\":\"5\",\"suit\":\"diamonds\"}]"; |
227 | 244 |
|
228 | 245 | streamWriter.Write(json); |
|
0 commit comments