-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBoard.cs
72 lines (63 loc) · 2.25 KB
/
Board.cs
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
using ConsoleTables;
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace PokerConsoleApp
{
public class Board
{
public List<Card> Cards { get; private set; }
public List<Player> Players { get; private set; }
public List<Card> Deck { get; }
public Board(int playerCount)
{
Cards = new List<Card>(5);
Players = new List<Player>(playerCount);
Deck = new List<Card>(52);
for (int i = 0; i < playerCount; i++)
{
Players.Add(new Player());
}
this.Deck = GetFreshDeck();
Debug.Assert(this.Deck.Count == 52);
this.Deck = UtilityMethods.ShuffleList(this.Deck);
}
public static List<Card> GetFreshDeck()
{
List<Card> deck = new List<Card>(52);
foreach (var cr in Enum.GetValues(typeof(RankType)))
{
foreach (var cs in Enum.GetValues(typeof(SuitType)))
{
deck.Add(new Card((RankType)cr, (SuitType)cs));
}
}
return deck;
}
public void DealGame()
{
// deal hole cards
for (int player_index = 0; player_index < Players.Count; player_index++)
{
for (int hole_card_index = 0; hole_card_index < 2; hole_card_index++)
{
this.Players[player_index].Hole.Add(Card.DealCard(Deck));
}
Debug.Assert(this.Players[player_index].Hole.Count == 2);
}
// deal board cards (flop1 flop2 flop3 turn river)
for (int _boardCardIndex = 0; _boardCardIndex < 5; _boardCardIndex++)
{
this.Cards.Add(Card.DealCard(Deck));
}
}
public override string ToString()
{
string ret_string;
var table = new ConsoleTable("flop", "turn", "river");
table.AddRow($"{Cards[0].ToString()} {Cards[1].ToString()} {Cards[2].ToString()}", Cards[3].ToString(), Cards[4].ToString());
ret_string = UtilityMethods.Trim_To_End(table.ToString(), "Count:");
return ret_string;
}
}
}