Example #1
0
        internal void PrintScoreboard(Yatzy spil)
        {
            PossibleOutcomes.Clear();
            Dictionary <string, int> tempdict = Scores;
            int upperScore  = 0;
            int upperBonus  = 0;
            int totalScore  = 0;
            int loopCounter = 0;

            foreach (KeyValuePair <string, int> kvp in tempdict)
            {
                WriteToScoreboard(kvp.Key, spil, true); //tanker possibleOutcomes op.
                if (loopCounter < 6)
                {
                    upperScore += kvp.Value;
                }
                else if (loopCounter == 6)
                {
                    Console.WriteLine($"\tSum: {upperScore}");
                    if (upperScore > 62)
                    {
                        upperBonus  = 50;
                        totalScore += upperBonus;
                    }
                    Console.WriteLine($"\tBonus: {upperBonus}");
                }


                totalScore += kvp.Value;
                string scoreboardText;

                if (RemovedOutcomes.Contains(kvp.Key))
                {
                    scoreboardText = $"\t{kvp.Key}: X";
                }
                else
                {
                    scoreboardText = $"\t{kvp.Key}: {kvp.Value}";
                }


                if ((PossibleOutcomes.Contains(kvp.Key)) && (kvp.Value == 0) && (!(RemovedOutcomes.Contains(kvp.Key))))
                {
                    scoreboardText += " <--";
                }

                Console.WriteLine(scoreboardText);
                loopCounter++;
            }
            Console.WriteLine($"\tSum: {totalScore}");
            Console.WriteLine("-------------------------------------\n");
        }
Example #2
0
 private void AddToScoreboardOrPossibleOutcomes(string userInput, int score, bool AddToPossibleOutcomesInstead)
 {
     if (AddToPossibleOutcomesInstead) //altså hvis de blot skal tilføjes til listen over mulige udfald, så skal selve scoren jo ikke ændres.
     {
         if (score > 0)
         {
             PossibleOutcomes.Add(userInput);
         }
     }
     else
     {
         Scores[userInput] = score;  //selve scoren på scoreboardet.
     }
 }