Difference between revisions of "HaveTurn"
(Created page with "<syntaxhighlight lang=csharp> private static void HaveTurn(string PlayerName, ref string PlayerTiles, ref int PlayerTilesPlayed, ref int PlayerScore, Dictionary<char,...") |
(No difference)
|
Latest revision as of 12:55, 14 November 2017
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)
{
Console.WriteLine();
Console.WriteLine(PlayerName + " it is your turn.");
DisplayTilesInHand(PlayerTiles);
string NewTileChoice = "2";
bool ValidChoice = false;
bool ValidWord = false;
string Choice = "";
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;
if (Choice.Length == 0)
{
ValidWord = false;
}
else
{
ValidWord = CheckWordIsInTiles(Choice, PlayerTiles);
}
if (ValidWord)
{
ValidWord = CheckWordIsValid(Choice, AllowedWords);
if (ValidWord)
{
Console.WriteLine();
Console.WriteLine("Valid word");
Console.WriteLine();
UpdateAfterAllowedWord(Choice, ref PlayerTiles, ref PlayerScore, ref PlayerTilesPlayed, TileDictionary, AllowedWords);
NewTileChoice = GetNewTileChoice();
}
}
if (!ValidWord)
{
Console.WriteLine();
Console.WriteLine("Not a valid attempt, you lose your turn.");
Console.WriteLine();
}
if (NewTileChoice != "4")
{
AddEndOfTurnTiles(ref TileQueue, ref PlayerTiles, NewTileChoice, Choice);
}
Console.WriteLine();
Console.WriteLine("Your word was:" + Choice);
Console.WriteLine("Your new score is:" + PlayerScore);
Console.WriteLine("You have played " + PlayerTilesPlayed + " tiles so far in this game.");
}
}
}