Display list of words (valid and invalid) used by each player at the end of the game
PlayGame
In PlayGame, declare PlayerOneWords and PlayerTwoWords as lists.
Pass each of these with reference into HaveTurn; pass both of these into DisplayWinner.
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);
}
HaveTurn
Add "ref List<string> PlayerWords" as a parameter for HaveTurn.
When the player enters a word and not a number or menu option, write "PlayerWords.Add(Choice);" to add the word to the current player's list of words played.
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);
//...
}
}
DisplayWinner
Add PlayerOneWords and PlayerTwoWords as parameters for DisplayWinner. Then write out each item in PlayerOneWords and PlayerTwoWords.
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));
//...
}