Difference between revisions of "PlayGame"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(Created page with "<syntaxhighlight lang=csharp> private static void PlayGame(List<string> AllowedWords, Dictionary<char, int> TileDictionary, bool RandomStart, int StartHandSize, int Ma...")
 
(No difference)

Latest revision as of 12:56, 14 November 2017

        private static void PlayGame(List<string> AllowedWords, Dictionary<char, int> TileDictionary, bool RandomStart, int StartHandSize, int MaxHandSize, int MaxTilesPlayed, int NoOfEndOfTurnTiles)
        {
            int PlayerOneScore = 50;
            int PlayerTwoScore = 50;
            int PlayerOneTilesPlayed = 0;
            int PlayerTwoTilesPlayed = 0;
            string PlayerOneTiles = "";
            string PlayerTwoTiles = "";
            QueueOfTiles TileQueue = new QueueOfTiles(20);
            if (RandomStart)
            {
                PlayerOneTiles = GetStartingHand(TileQueue, StartHandSize);
                PlayerTwoTiles = GetStartingHand(TileQueue, StartHandSize);
            }
            else
            {
                PlayerOneTiles = "BTAHANDENONSARJ";
                PlayerTwoTiles = "CELZXIOTNESMUAA";
            }
            while (PlayerOneTilesPlayed <= MaxTilesPlayed && PlayerTwoTilesPlayed <= MaxTilesPlayed && PlayerOneTiles.Length < MaxHandSize && PlayerTwoTiles.Length < MaxHandSize)
            {
                HaveTurn("Player One", ref PlayerOneTiles, ref PlayerOneTilesPlayed, ref PlayerOneScore, TileDictionary, ref TileQueue, AllowedWords, MaxHandSize, NoOfEndOfTurnTiles);
                Console.WriteLine();
                Console.WriteLine("Press Enter to continue");
                Console.ReadLine();
                Console.WriteLine();
                HaveTurn("Player Two", ref PlayerTwoTiles, ref PlayerTwoTilesPlayed, ref PlayerTwoScore, TileDictionary, ref TileQueue, AllowedWords, MaxHandSize, NoOfEndOfTurnTiles);
            }
            UpdateScoreWithPenalty(ref PlayerOneScore, PlayerOneTiles, TileDictionary);
            UpdateScoreWithPenalty(ref PlayerTwoScore, PlayerTwoTiles, TileDictionary);
            DisplayWinner(PlayerOneScore, PlayerTwoScore);
        }