public void NextCard() { PlayingCard player1Card = Player1.GetNextCard(); PlayingCard player2Card = Player2.GetNextCard(); if (player1Card.Rank > player2Card.Rank) { Player1Wins(); } else if (player1Card.Rank < player2Card.Rank) { Player2Wins(); } else { Draw(); } void Player1Wins() { ShowCards(); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("{0} got the cards", Player1.Name); Player1.AddCard(player1Card); Player1.AddCard(player2Card); } void Player2Wins() { ShowCards(); Console.ForegroundColor = ConsoleColor.DarkYellow; Console.WriteLine("{0} got the cards", Player2.Name); Player2.AddCard(player2Card); Player2.AddCard(player1Card); } void Draw() { ShowCards(); Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("2 cards lost..."); Console.WriteLine("cards left: [{0}] {1}x, [{2}] {3}x", Player1.Name, Player1.PlayerCards.Count, Player2.Name, Player2.PlayerCards.Count); } void ShowCards() { Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("[{0}] {1} - [{2}] {3}", Player1.Name, player1Card.ToString(), Player2.Name, player2Card.ToString()); } }
public void AddCard(PlayingCard card) { PlayerCards.Add(card); }