public static void ThrowDiceText(int diceThrow, YatzyPlayer player) { Console.WriteLine($"\t{player.Name}, din tur. SLAG NUMMER {diceThrow}."); Console.WriteLine("\tTryck ENTER för att slå tärningarna."); }
public static void PlayYatzy() { Random dice = new Random(); Intro(); Console.WriteLine(); Console.WriteLine(); int howManyPlayers = YatzyPlayer.HowManyPlayers(); List <YatzyPlayer> players = YatzyPlayer.CreateListOfPLayers(howManyPlayers); Console.WriteLine(); List <Yatzyboard> yatzyboard = Yatzyboard.CreateEmptyYatzyboard(players); Console.Clear(); Console.WriteLine(); Console.WriteLine(); for (int turn = 0; turn < 15; turn++) { foreach (YatzyPlayer player in players) { int count = 1; Console.Clear(); Console.WriteLine(); Console.WriteLine(); Yatzyboard.PrintOutYatzyboard(yatzyboard, players); Console.WriteLine(); ThrowDiceText(count, player); Console.ReadLine(); int[] dices = ThrowDices(); Console.WriteLine(); PrintOutDices(dices); while (count < 3) { count++; Console.WriteLine(); TextWhichToKeep(); dices = UpdateThrewedDices(dices); Console.Clear(); Console.WriteLine(); Console.WriteLine(); Yatzyboard.PrintOutYatzyboard(yatzyboard, players); Console.WriteLine(); ThrowDiceText(count, player); Console.WriteLine(); PrintOutDices(dices); Console.ReadLine(); Console.Clear(); Console.WriteLine(); Console.WriteLine(); Yatzyboard.PrintOutYatzyboard(yatzyboard, players); dices = FillArrayFullWithNewDices(dices); Console.WriteLine(); PrintOutDices(dices); } TextWherePutSum(); bool isFree; int where = 0; int points = 0; do { where = ReturnNumber(1, 15); isFree = CheckIfFree(where, player.Sums); if (isFree == false) { Console.WriteLine("\tDu har redan satt poäng där, vänligen försök igen."); } points = YatzySum.GetPoint(where, dices); if (points == 0) { isFree = KeepThePlace(where); } } while (!isFree); YatzySum.SetPoint(where, points, player.Sums); } } YatzySum.CountSumUp(players); Console.Clear(); Console.WriteLine(); Console.WriteLine(); Yatzyboard.PrintOutYatzyboard(yatzyboard, players); Console.WriteLine("\t\t\t\t\tTryck för att se Highscore."); Console.ReadKey(true); Console.Clear(); HighScoreEachGame.OpenHighscores("yatzyhighscorelist.txt", HighScoreEachGame.ListYatzy); HighScoreEachGame.PrintOutHighscores("----------------------YATZY--------------------", HighScoreEachGame.ListYatzy); Console.WriteLine(); foreach (var player in players) { Console.WriteLine($"\t\t\t\t\t{player.Name} fick {player.YatzyRecord} poäng.\n"); } foreach (var player in players) { int maybeHighscore = HighScoreEachGame.SeeIfHighscore(HighScoreEachGame.ListSnake, Yatzy.SumPlayer1); if (maybeHighscore < 11) { Console.WriteLine("\t\t\t\t\tGrattis! Du kom in på Highscore-listan!"); HighScoreEachGame.PutHighScoreInList(maybeHighscore, player.YatzyRecord, HighScoreEachGame.ListYatzy); HighScoreEachGame.PutHighScoreInFile("yatzyhighscore.txt", HighScoreEachGame.ListYatzy); Console.Clear(); HighScoreEachGame.OpenHighscores("yatzyhighscore.txt", HighScoreEachGame.ListYatzy); HighScoreEachGame.PrintOutHighscores("----------------------YATZY--------------------", HighScoreEachGame.ListYatzy); Console.WriteLine(); } else { Console.WriteLine("\t\t\t\t\tBättre lycka nästa gång!\n\n"); } } Console.ReadLine(); }