Bonus points at end of game for longest and highest scored words

From TRCCompSci - AQA Computer Science
Revision as of 09:52, 24 May 2018 by M0hk4l3 (talk | contribs) (Created page with "Create four local variables in the main game class. <syntaxhighlight lang="C#"> private static int highestScoredWord = 0; private static string highestScoredWordByPlayer = St...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Create four local variables in the main game class.

private static int highestScoredWord = 0;
private static string highestScoredWordByPlayer = String.Empty;

private static int longestScoredWord = 0;
private static string longestScoredWordByPlayer = String.Empty;

Then in the Have Turn method, after the player has entered a valid choice

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) {
    // Some Stuff Was Here

    if (ValidWord) {
        if (Choice.Length > longestScoredWord) {
            longestScoredWord = Choice.Length;
            longestScoredWordByPlayer = PlayerName;
        }

        if (GetScoreForWord(Choice, TileDictionary) > highestScoredWord) {
            highestScoredWord = GetScoreForWord(Choice, TileDictionary);
            highestScoredWordByPlayer = PlayerName;
        }

        // Some stuff is here
    }
}