Deal cards from deck to 4 players 1 card at a time

I have one deck that contains all the cards and want each player to draw 1 card at a time until each player has 7 cards in their hand. Similar to the play style of Uno.

Currently I have all the cards in a Deck list and want to loop through each player’s hand (also each a list, p1Hand, p2Hand, p3Hand, p4Hand) and add a card from the deck to each player one at a time.

I have the game looping to draw the 7 cards to one player. But I am trying to expand on that code.

Ps. Still learning coding and unity as a whole.

Current Loop for 7 cards running through a coroutine and places the cards from the Deck list into a Hand list during DrawCard().

private int initialHand = 7;

for (int i = 0; i < initialHand; i++)
            {   
                WaitForSeconds wait = new WaitForSeconds(.5f);
                cardManager.DrawCard();
                yield return wait;
            }

Here is where I am getting stuck. I create the lists for each player hand instead of just one. Then create a list of lists to cycle through each player a deal them one card each until then all have 7.

public List<Card> p1Hand = new List<Card>();
public List<Card> p2Hand = new List<Card>();
public List<Card> p3Hand = new List<Card>();
public List<Card> p4Hand = new List<Card>();
            
public List<List<Card>> players = new List<List<Card>>();

public List<Card> tempPlayerHand = new List<Card>();
    
private int initialHand = 7;
        
for (int i = 0; i < initialHand; i++)
    {
        WaitForSeconds wait = new WaitForSeconds(.5f);
        for (int p = 0; p < playerManager.players.Count; p++)
        {
            if(playerManager.players.Equals(playerManager.p1Hand))
            {
                tempPlayerHand = playerManager.p1Hand;
                cardManager.DrawCard(tempPlayerHand);
            }
            yield return wait;
        }
    }

I create a tempPlayerHand list to try and send the information to the Card Manager script that runs the DrawCard function. I am thinking the if statement is wrong to identify which player hand to send the card to. I will also add an if statement for each player hand if that is the way to work the loop.

You can try changing your script to this

public List<Card> p1Hand = new List<Card>();
public List<Card> p2Hand = new List<Card>();
public List<Card> p3Hand = new List<Card>();
public List<Card> p4Hand = new List<Card>();

public List<Card> players = new List<Card>();

private int initialHand = 7;

void Start()
{
  players.Add(p1Hand );
  players.Add(p2Hand );
  players.Add(p3Hand );
  players.Add(p4Hand );

  for(int i = 0; i < initialHand; i++)
  {
    for(int p = 0; p < players.Count; p++)
    {
      if(players[p] == p1Hand)
        cardManager.DrawCard(p1Hand);
      else if(players[p] == p2Hand)
        cardManager.DrawCard(p2Hand);
      else if(players[p] == p3Hand)
        cardManager.DrawCard(p3Hand);
      else if(players[p] == p4Hand)
        cardManager.DrawCard(p4Hand);
    }
  }
}