PlayingCards constructor #3

Merged
ashstrahle merged 1 commits from Ash into main 2022-08-14 12:50:54 +10:00
2 changed files with 12 additions and 9 deletions
Showing only changes of commit b46f12d4ae - Show all commits

View File

@@ -17,8 +17,8 @@
public class Deck
{
public static List<Card> Cards = new();
public static void Enumerate()
public List<Card> Cards = new();
public Deck()
{
foreach (Suit suit in Enum.GetValues(typeof(Suit)))
{
@@ -42,10 +42,11 @@
});
}
}
Shuffle();
}
private static Random rng = new();
public static void Shuffle()
public void Shuffle()
{
Cards = Cards.OrderBy(a => rng.Next()).ToList();
}

View File

@@ -21,6 +21,8 @@ namespace StripJackNaked
{
private static void Main()
{
Deck deck = new();
// Init players
List<Player> Players = new();
for (int i = 0; i < Constants.PlayerCount; i++)
@@ -29,15 +31,15 @@ namespace StripJackNaked
}
// Init deck
Deck.Enumerate();
Deck.Shuffle();
//Deck.Enumerate();
// Deck.Shuffle();
// Deal cards
while (Deck.Cards.Count > 0)
while (deck.Cards.Count > 0)
{
Card card = Deck.Cards.Last();
int player = Deck.Cards.Count() % Constants.PlayerCount; // Alternate dealing cards between players 0 and 1
_ = Actions.MoveCard(Deck.Cards, Players[player].Hand, card);
Card card = deck.Cards.Last();
int player = deck.Cards.Count() % Constants.PlayerCount; // Alternate dealing cards between players 0 and 1
_ = Actions.MoveCard(deck.Cards, Players[player].Hand, card);
}
// Init first round