-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActionsToSort.cs
More file actions
98 lines (94 loc) · 3.75 KB
/
Copy pathActionsToSort.cs
File metadata and controls
98 lines (94 loc) · 3.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using System;
using System.Collections.Generic;
using System.Linq;
using Task1.Combinations;
namespace Task
{
class ActionsToSort
{
public static void SortCards(string checkedString)
{
var tokens = checkedString.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
switch (tokens[0])
{
case "texas-holdem":
List<Card> board = Card.ParseCards(tokens[1]);
var hands = new List<List<Card>>();
for (int i = 2; i < tokens.Length; i++)
{
List<Card> newCards = Card.ParseCards(tokens[i]);
hands.Add(newCards);
}
var pairTxsHands = new List<Hand>();
foreach (var hand in hands)
{
var combination = CombinationClass.FindTexasHandValue(hand, board);
var handObj = new Hand
{
Cards = hand,
Combination = combination
};
pairTxsHands.Add(handObj);
}
PrintSortedHands(pairTxsHands);
break;
case "omaha-holdem":
List<Card> omhBoard = Card.ParseCards(tokens[1]);
var omhHands = new List<List<Card>>();
for (int i = 2; i < tokens.Length; i++)
{
List<Card> newCards = Card.ParseCards(tokens[i]);
omhHands.Add(newCards);
}
var pairOmahaHands = new List<Hand>();
foreach (var hand in omhHands)
{
var combination = CombinationClass.FindOmahaHandValue(hand, omhBoard);
var handObj = new Hand
{
Cards = hand,
Combination = combination
};
pairOmahaHands.Add(handObj);
}
PrintSortedHands(pairOmahaHands);
break;
case "five-card-draw":
var fiveCardsList = new List<List<Card>>();
for (int i = 1; i < tokens.Length; i++)
{
List<Card> newCards = Card.ParseCards(tokens[i]);
fiveCardsList.Add(newCards);
}
var pairFcdHands = new List<Hand>();
foreach (var hand in fiveCardsList)
{
var combination = CombinationClass.FindFiveCardsHandValue(hand);
var handObj = new Hand
{
Cards = hand,
Combination = combination
};
pairFcdHands.Add(handObj);
}
PrintSortedHands(pairFcdHands);
break;
default:
break;
}
}
private static void PrintSortedHands(List<Hand> hand)
{
var query = hand.GroupBy(combination => combination.Combination).OrderBy(z => z.Key).ToList();
string strHand = string.Empty;
foreach (var handDict in query)
{
List<string> handsList = handDict.ToList().Select(x => x.ToString()).ToList();
handsList.Sort();
Console.Write(String.Join("=", handsList));
Console.Write(" ");
}
Console.WriteLine();
}
}
}