Display list of words (valid and invalid) used by each player at the end of the game
In PlayGame, declare PlayerOneWords and PlayerTwoWords as lists. Pass these into HaveTurn with reference.
private static void PlayGame(List<string> AllowedWords, Dictionary<char, int> TileDictionary, bool RandomStart, int StartHandSize, int MaxHandSize, int MaxTilesPlayed, int NoOfEndOfTurnTiles)
{
//...
//Declare PlayerOneWords and PlayerTwoWords
List<string> PlayerOneWords = new List<string>();
List<string> PlayerTwoWords = new List<string>();
//...
while (PlayerOneTilesPlayed <= MaxTilesPlayed && PlayerTwoTilesPlayed <= MaxTilesPlayed && PlayerOneTiles.Length < MaxHandSize && PlayerTwoTiles.Length < MaxHandSize)
{
//Pass PlayerOneWords with reference
HaveTurn("Player One", ref PlayerOneTiles, ref PlayerOneTilesPlayed, ref PlayerOneScore, TileDictionary, ref TileQueue, AllowedWords, MaxHandSize, NoOfEndOfTurnTiles, ref PlayerOneWords);
//...
//Pass PlayerTwoWords with reference
HaveTurn("Player Two", ref PlayerTwoTiles, ref PlayerTwoTilesPlayed, ref PlayerTwoScore, TileDictionary, ref TileQueue, AllowedWords, MaxHandSize, NoOfEndOfTurnTiles, ref PlayerTwoWords);
}
//...
DisplayWinner(PlayerOneScore, PlayerTwoScore, PlayerOneWords, PlayerTwoWords);
}
private static void HaveTurn(string PlayerName, ref string PlayerTiles, ref int PlayerTilesPlayed, ref int PlayerScore, Dictionary<char, int> TileDictionary, ref QueueOfTiles TileQueue, List<string> AllowedWords, int MaxHandSize, int NoOfEndOfTurnTiles, ref List<string> PlayerWords)
{
//...
while (!ValidChoice)
{
Choice = GetChoice();
if (Choice == "1")
{
DisplayTileValues(TileDictionary, AllowedWords);
}
else if (Choice == "4")
{
TileQueue.Show();
}
else if (Choice == "7")
{
DisplayTilesInHand(PlayerTiles);
}
else if (Choice == "0")
{
ValidChoice = true;
FillHandWithTiles(ref TileQueue, ref PlayerTiles, MaxHandSize);
}
else
{
ValidChoice = true;
//Add this to add the word to the list of words used by that player
PlayerWords.Add(Choice);
//...
}
}
private static void DisplayWinner(int PlayerOneScore, int PlayerTwoScore, List<string> PlayerOneWords, List<string> PlayerTwoWords)
{
//...
//Add this to write out each list
Console.WriteLine("These were the words played by Player One:");
PlayerOneWords.ForEach(i => Console.WriteLine("{0}\t", i));
Console.WriteLine();
Console.WriteLine("These were the words played by Player Two:");
PlayerTwoWords.ForEach(i => Console.WriteLine("{0}\t", i));
//...
}