Hi
I have the following code which obviously has some duplication. I'm sure this could be removed using a delegate or Action but can't quite grasp it.
anyone got any ideas?
public void DealStartingCards()
{
for (int i = 0; i < 3; i++)
{
foreach (var player in Players)
{
if (player.Hand.FaceDownCards.Count < 3)
{
if (Deck.Count > 0)
player.Hand.FaceDownCards.Add(Deck.TakeTopCard());
}
}
}
for (int i = 0; i < 3; i++)
{
foreach (var player in Players)
{
if (player.Hand.FaceUpCards.Count < 3)
{
if (Deck.Count > 0)
player.Hand.FaceUpCards.Add(Deck.TakeTopCard());
}
}
}
for (int i = 0; i < 3; i++)
{
foreach (var player in Players)
{
if (player.Hand.InHandCards.Count < 3)
{
if (Deck.Count > 0)
player.Hand.InHandCards.Add(Deck.TakeTopCard());
}
}
}
}
InHandCards, FaceUpCards and FaceDownCards are all of type List<Card>