PlayingCards constructor
This commit is contained in:
@@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
public class Deck
|
public class Deck
|
||||||
{
|
{
|
||||||
public static List<Card> Cards = new();
|
public List<Card> Cards = new();
|
||||||
public static void Enumerate()
|
public Deck()
|
||||||
{
|
{
|
||||||
foreach (Suit suit in Enum.GetValues(typeof(Suit)))
|
foreach (Suit suit in Enum.GetValues(typeof(Suit)))
|
||||||
{
|
{
|
||||||
@@ -42,10 +42,11 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Shuffle();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Random rng = new();
|
private static Random rng = new();
|
||||||
public static void Shuffle()
|
public void Shuffle()
|
||||||
{
|
{
|
||||||
Cards = Cards.OrderBy(a => rng.Next()).ToList();
|
Cards = Cards.OrderBy(a => rng.Next()).ToList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ namespace StripJackNaked
|
|||||||
{
|
{
|
||||||
private static void Main()
|
private static void Main()
|
||||||
{
|
{
|
||||||
|
Deck deck = new();
|
||||||
|
|
||||||
// Init players
|
// Init players
|
||||||
List<Player> Players = new();
|
List<Player> Players = new();
|
||||||
for (int i = 0; i < Constants.PlayerCount; i++)
|
for (int i = 0; i < Constants.PlayerCount; i++)
|
||||||
@@ -29,15 +31,15 @@ namespace StripJackNaked
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Init deck
|
// Init deck
|
||||||
Deck.Enumerate();
|
//Deck.Enumerate();
|
||||||
Deck.Shuffle();
|
// Deck.Shuffle();
|
||||||
|
|
||||||
// Deal cards
|
// Deal cards
|
||||||
while (Deck.Cards.Count > 0)
|
while (deck.Cards.Count > 0)
|
||||||
{
|
{
|
||||||
Card card = Deck.Cards.Last();
|
Card card = deck.Cards.Last();
|
||||||
int player = Deck.Cards.Count() % Constants.PlayerCount; // Alternate dealing cards between players 0 and 1
|
int player = deck.Cards.Count() % Constants.PlayerCount; // Alternate dealing cards between players 0 and 1
|
||||||
_ = Actions.MoveCard(Deck.Cards, Players[player].Hand, card);
|
_ = Actions.MoveCard(deck.Cards, Players[player].Hand, card);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init first round
|
// Init first round
|
||||||
|
|||||||
Reference in New Issue
Block a user