So I have a dice rolling game where you roll dice to score points. Currently once 25 points is reached a message appears saying this player is the winner but is stuck in a loop that goes up to 50 Once a score limit is reached I want to end the game but im not really sure how to. I think I need a Do while loop but not sure how to add in because the total points limit is in another class?
Thanks
class Game
{
private static void Main(string[] args) ----- Main method:
{
if (gamemode == 1)
{
quickgame();
}
}
private static void quickgame() ---- Game carried out
{
Console.WriteLine("\nInstructions: Players take turns rolling all five dice and scoring for three-of-a-kind or better. \n\t If a player only has two-of-a-kind, they may re-throw the remaining dice in an \n\t attempt to improve the matching dice values. If no matching numbers are\n\t rolled, a player scores 0. The first player to reach 25 points wins. ");
Console.WriteLine("\nScoring: 3-Of-A-Kind = 3 Points \n 4-Of-A-Kind = 6 Points \n 5-Of-A-Kind = 12 Points\n");
Random RandomNum = new Random();
Player[] player1 = new Player[5];
Die[] myDie = new Die[5];
for (int i = 0; i < 5; i++)
{
myDie[i] = new Dice_v4.Die(RandomNum);
player1[i] = new Dice_v4.Player();
}
for (int i = 0; i < 2; i++) // Number of players
{
Console.Write("Enter Name for Player {0}:", i + 1);
string NewName = Console.ReadLine();
player1[i].SetName(NewName);
}
Console.WriteLine("\nPress enter in turns to roll the five dice");
Console.ReadLine();
Console.WriteLine();
for (int j = 1; j < 50; j++)
{
for (int i = 0; i < 2; i++)
{
myDie[i].roll();
Console.WriteLine("{0} Rolled:{1} on the first dice", player1[i].GetName(), myDie[i].GetTopNumber());
Console.WriteLine("{0} Rolled:{1} on the second dice", player1[i].GetName(), myDie[i].GetTopNumber1());
Console.WriteLine("{0} Rolled:{1} on the third dice", player1[i].GetName(), myDie[i].GetTopNumber2());
Console.WriteLine("{0} Rolled:{1} on the fourth dice", player1[i].GetName(), myDie[i].GetTopNumber3());
Console.WriteLine("{0} Rolled:{1} on the fifth dice", player1[i].GetName(), myDie[i].GetTopNumber4());
myDie[i].points();
Console.WriteLine("\t\t\t\t\tTotal Throws:{0}\n ------------------------------------------------------", j);
myDie[i].Totally();
Console.ReadLine();
}
}
}
}
Points :
class Die
{
public string points()
{
TotalPoints = threepoints + sixpoints + twelvepoints;
Console.WriteLine("\n\t\t\t\t\tTotal Score: {0}", TotalPoints);
return pointss;
}
public string Totally()
{
if (TotalPoints >= 25)
{
Console.WriteLine("This Player Won the game");
}
return tots;
}
}
Aucun commentaire:
Enregistrer un commentaire