Ejemplo n.º 1
0
        public static void Computer()
        {
            int Inputscore    = 0;
            int NoOfAKind     = 0;
            int NoOfTwos      = 0;
            int NoofRerolls   = 0;
            int OneTurnPoints = 0;

            Game.Playernum = 2;
            int[] TwoMatches = new int[2];
            Game  Scores     = new Game();

            Console.Clear();
            if (GlobalVar.Score1 < 50 && GlobalVar.Score2 < 50)
            {
                Console.WriteLine("{0}'s turn", Player.Players[2]);
                //Console.WriteLine("Do you want to throw all dice just once for double points? Y/N");
                string DoubPoin   = "";
                string DoubPoints = "";
                Random AIRand     = new Random();
                int    AIChoice   = AIRand.Next(1, 11);
                if (AIChoice > 7)
                {
                    DoubPoin   = " Not";
                    DoubPoints = "No";
                }
                else
                {
                    DoubPoin   = "";
                    DoubPoints = "Yes";
                }
                Console.WriteLine("Computer chooses to{0} Double their score", DoubPoin);

                string AllTurnScores = "";
                for (int i = 0; i < 5; i++)
                {
                    Inputscore = 0;
                    Die.Dice(ref Inputscore);
                    Scores.DiceRoll[i] = Inputscore;
                }
                MatchesNumber(ref Scores.DiceRoll, ref AllTurnScores, ref Scores.TurnInfo, ref NoOfAKind, ref NoOfTwos, ref Game.NoOfTurns, ref TwoMatches);
                GlobalVar.Score2 += Game.Point(ref NoOfAKind, DoubPoints, ref NoofRerolls, ref OneTurnPoints, ref Scores.DiceRoll, ref TwoMatches, ref AllTurnScores, ref Scores.TurnInfo, ref NoOfTwos);
                Scores.TurnInfo  += " Total: " + GlobalVar.Score2;



                DicePoints.Add(Scores.TurnInfo);
                Console.WriteLine("\r");
                foreach (string Turn in DicePoints)
                {
                    Console.WriteLine(Turn);
                }
                //int DiceCount = Game.DicePoints.Count(); // attempt at making sure the code wouldn't fill the screen and over. Count for some reason wouldn't increase
                // int DiCount = DicePoints.Count();
                //if (DicePoints.Count == 15) {
                // DicePoints.Clear();
                //}
                Console.WriteLine("\r");
                //Console.ReadLine();
                Statistics();
                Player1();
            }
            else
            {
                if (GlobalVar.Score1 > GlobalVar.Score2)
                {
                    Console.WriteLine("{0} Wins", Player.Players[1]);
                }
                else if (GlobalVar.Score2 > GlobalVar.Score1)
                {
                    Console.WriteLine("{0} Wins", Player.Players[2]);
                }
                else
                {
                    Console.WriteLine("The Game is a Draw");
                }
                Console.ReadLine();
            }
        }
Ejemplo n.º 2
0
        public static int Point(ref int Score, string DoubPoints, ref int NoOfRerolls, ref int OneTurnPoint, ref int[] DiceRoll, ref int[] Matches, ref string AllTurnScores, ref string TurnInfo, ref int NoOfTwos)
        {
            //Game ScoresSecond = new Game();

            if (DoubPoints == "y" || DoubPoints == "YES" || DoubPoints == "Y" || DoubPoints == "yes" || DoubPoints == "Yes")
            { // If they put double points it will go here first
                switch (Score)
                {
                case 0:
                    OneTurnPoint = 0;
                    Game.NoPointsTurns++;
                    break;

                case 1:
                    OneTurnPoint = 0;
                    Game.NoPointsTurns++;
                    break;

                case 2:
                    OneTurnPoint = 0;
                    Game.NoPointsTurns++;
                    break;

                case 3:
                    OneTurnPoint = 6;
                    break;

                case 4:
                    OneTurnPoint = 12;
                    break;

                case 5:
                    OneTurnPoint = 24;
                    break;
                }
            }
            else if (Score > 2 && (DoubPoints == "n" || DoubPoints == "NO" || DoubPoints == "N" || DoubPoints == "no" || DoubPoints == "No"))
            { //Score more than 2 matches on the diceroll but did not click double points
                switch (Score)
                {
                case 3:
                    OneTurnPoint = 3;
                    break;

                case 4:
                    OneTurnPoint = 6;
                    break;

                case 5:
                    OneTurnPoint = 12;
                    break;
                }
            }
            else if (Score == 2 && NoOfRerolls == 0 && (DoubPoints == "n" || DoubPoints == "NO" || DoubPoints == "N" || DoubPoints == "no" || DoubPoints == "No"))
            //For when two of the rolls match and they chose not to double their scores, will take those two matched values and reroll
            {
                // int secondroll = 0;
                Console.WriteLine("You got two matches and didn't choose double points! REROLL!!!");
                NoOfRerolls++;
                //break;
                //if (NoofRerolls == 1)
                //{
                int secondroll = 0;
                DiceRoll[0] = Matches[0];
                DiceRoll[1] = Matches[0];
                for (int i = 2; i < 5; i++)
                {
                    secondroll = 0;
                    Die.Dice(ref secondroll);
                    DiceRoll[i] = secondroll;
                }
                //Now it goes through the sorting and point allocation again
                MatchesNumber(ref DiceRoll, ref AllTurnScores, ref TurnInfo, ref Score, ref NoOfTwos, ref Game.NoOfTurns, ref Matches);
                OneTurnPoint = Game.Point(ref Score, DoubPoints, ref NoOfRerolls, ref OneTurnPoint, ref DiceRoll, ref Matches, ref AllTurnScores, ref TurnInfo, ref NoOfTwos);
                if (OneTurnPoint == 0)
                {
                    Game.NoPointsTurns++;
                }

                // Point(ref Score, DoubPoints, ref NoOfRerolls);
            }
            else if (Score == 2 && NoOfRerolls == 1)
            {
                OneTurnPoint = 0;
            }                                                              //will have to be 2 as you have the others carried over from the previous roll
            else if (Score < 2)
            {
                OneTurnPoint = 0;
            }                                         //For the case where they have picked to not double points but don't get any matches
            else //Will only occur if they have not entered yes or no correctly
            {
                Console.WriteLine("You did not enter yes or no for your double points, hence you will get 0 points");
                OneTurnPoint = 0;
            }


            return(OneTurnPoint);
        }
Ejemplo n.º 3
0
        public static void Player1()
        {
            int Inputscore    = 0;
            int NoOfAKind     = 0;
            int NoOfTwos      = 0;
            int NoofRerolls   = 0;
            int OneTurnPoints = 0;

            Game.Playernum = 1;
            //bool EndGame = false;
            int[] TwoMatches = new int[2];
            Game  Scores     = new Game();

            //Player Names = new Player();

            Console.Clear();
            if (GlobalVar.Score1 < 50 && GlobalVar.Score2 < 50)
            {
                Console.WriteLine("{0}'s turn", Player.Players[1]);
                Game.NoOfTurns++; // Only use this for Player 1
                Console.WriteLine("Do you want to throw all dice just once for double points? Y/N");
                string DoubPoints    = Console.ReadLine();
                string AllTurnScores = "";
                for (int i = 0; i < 5; i++)
                {
                    Inputscore = 0;
                    Die.Dice(ref Inputscore);
                    // Scores.ThroTot1 += Inputscore;
                    // Scores.DiceRolled1++;
                    //Console.WriteLine(Inputscore);
                    Scores.DiceRoll[i] = Inputscore;
                }
                MatchesNumber(ref Scores.DiceRoll, ref AllTurnScores, ref Scores.TurnInfo, ref NoOfAKind, ref NoOfTwos, ref Game.NoOfTurns, ref TwoMatches);


                //NoOfAKind = Array.IndexOf(Scores.DiceRoll, j);
                //if (NoOfAKind > 1 && NoOfAKind >= 3)
                //{
                //Matches[Z] = j;
                GlobalVar.Score1 += Game.Point(ref NoOfAKind, DoubPoints, ref NoofRerolls, ref OneTurnPoints, ref Scores.DiceRoll, ref TwoMatches, ref AllTurnScores, ref Scores.TurnInfo, ref NoOfTwos);
                //break;
                //}
                //else if (NoOfAKind == 2) //put something in place to fix when two sets of two come up, just choose one of the two sets of two?
                ////Could let player choose which set of 2s to stick with? If there is time to implement it
                //{
                //    //Scores.DiceRoll[0] = j;
                //    //Scores.DiceRoll[1] = j;
                //    GlobalVar.Score1 += Game.Point(ref NoOfAKind, DoubPoints, ref NoofRerolls, ref OneTurnPoints, ref Scores.DiceRoll, ref TwoMatches);
                //    MatchesNumber(ref Scores.DiceRoll, ref AllTurnScores, ref Scores.TurnInfo, ref NoOfAKind, ref NoOfTwos, ref Game.NoOfTurns, ref TwoMatches);
                //    GlobalVar.Score1 += Game.Point(ref NoOfAKind, DoubPoints, ref NoofRerolls, ref OneTurnPoints, ref Scores.DiceRoll, ref TwoMatches);

                //}
                //else
                //{
                //    GlobalVar.Score1 += 0;
                //}
                //*1 Look at bottom for more
                // Console.WriteLine("Your Score for this round is {0}" , GlobalVar.Score1);
                Scores.TurnInfo += " Total: " + GlobalVar.Score1;
                DicePoints.Add(Scores.TurnInfo);
                Console.WriteLine("\r");
                foreach (string Turn in DicePoints)
                {
                    Console.WriteLine(Turn);
                }
                //Console.ReadLine();
                Console.WriteLine("\r");
                Statistics();
                if (Player.Players[2] == "Computer")
                {
                    Computer();
                }
                else
                {
                    Player2();
                }
            }
            else
            {
                if (GlobalVar.Score1 > GlobalVar.Score2)
                {
                    Console.WriteLine("{0} Wins", Player.Players[1]);
                }
                else if (GlobalVar.Score2 > GlobalVar.Score1)
                {
                    Console.WriteLine("{0} Wins", Player.Players[2]);
                }
                else
                {
                    Console.WriteLine("The Game is a Draw");
                }
                Console.ReadLine();
            }
        }