// Human player input public int FindPlay(IGameState <int> iGameState) { SixNimmtGameState gameState = iGameState as SixNimmtGameState; while (true) { Console.WriteLine(gameState.ToString()); List <int> playsList = new List <int>(gameState.GetPlays()); playsList.Sort(); string plays = string.Join(", ", playsList.ToArray()); if (gameState.PlayInputState == SixNimmtInputState.SelectCard) { // string cards = string.Join(", ", gameState.PlayerCards[gameState.CurrentPlayerTurn].ToArray()); Console.WriteLine($"[{playerName}] Enter a play. Cards: {plays}"); } else { // string plays = string.Join(", ", gameState.GetPlays().ToArray()); Console.WriteLine($"[{playerName}] Choose a row to take: {plays}"); } string playInput = Console.ReadLine(); if (string.IsNullOrEmpty(playInput)) { Console.WriteLine($"[{playerName}] Invalid play. Try again."); continue; } if (!int.TryParse(playInput, out int attemptedPlay)) { Console.WriteLine($"[{playerName}] Invalid play. Input must be a number."); continue; } if (!gameState.GetPlays().Contains(attemptedPlay)) { Console.WriteLine($"[{playerName}] Chosen play '{attemptedPlay}' is not valid."); continue; } return(attemptedPlay); } }