public void PlayRecursiveRound() { var deckStatus = string.Join(",", PlayerOneDeck) + "|" + string.Join(",", PlayerTwoDeck); _HadCardsPreviouslyPlayed = _DeckArrangements.Contains(deckStatus); _DeckArrangements.Add(deckStatus); if (_HadCardsPreviouslyPlayed) { return; } var card1 = PlayerOneDeck.Dequeue(); var card2 = PlayerTwoDeck.Dequeue(); int winner; if (card1 <= PlayerOneDeck.Count && card2 <= PlayerTwoDeck.Count) { winner = GetWinnerOfSubGame(card1, card2); } else if (card1 > card2) { winner = PlayerOne; } else if (card1 < card2) { winner = PlayerTwo; } else { throw new NotSupportedException($"Game does not support ties: {card1}"); } if (winner == PlayerOne) { PlayerOneDeck.Enqueue(card1); PlayerOneDeck.Enqueue(card2); } else if (winner == PlayerTwo) { PlayerTwoDeck.Enqueue(card2); PlayerTwoDeck.Enqueue(card1); } }
public void PlayRound() { var card1 = PlayerOneDeck.Dequeue(); var card2 = PlayerTwoDeck.Dequeue(); if (card1 > card2) { PlayerOneDeck.Enqueue(card1); PlayerOneDeck.Enqueue(card2); } else if (card1 < card2) { PlayerTwoDeck.Enqueue(card2); PlayerTwoDeck.Enqueue(card1); } else { throw new NotSupportedException($"Game does not support ties: {card1}"); } }