Example #1
0
        public static void Main(string[] args)
        {
            Messages.Messages messages = new Messages.Messages();
            GameLoop.GameLoop Game     = new GameLoop.GameLoop();

            messages.IntroMessage();
            Game.StartGame();
        }
Example #2
0
        public void ReceiveMessage(Messages.Messages message)
        {
            switch (message)
            {
            case Messages.Messages.MainMenuConfirm:
                ChangeState(StatesEnum.Shuffle);
                break;

            default:
                throw new NotImplementedException(message.ToString());
            }
        }
Example #3
0
        public void ReceiveMessage(Messages.Messages message)
        {
            switch (message)
            {
            case Messages.Messages.RestartGame:
                ChangeState(StatesEnum.Shuffle);
                break;

            case Messages.Messages.ReturnToMainMenu:
                ChangeState(StatesEnum.MainMenu);
                break;

            default:
                throw new System.NotImplementedException();
            }
        }
Example #4
0
 private void Alert(string msg, Messages.Messages.enmType type)
 {
     Messages.Messages popup = new Messages.Messages();
     popup.showAlert(msg, type);
 }
Example #5
0
        public void StartGame()
        {
            int  Frame     = 1;
            int  MaxFrames = 10;
            Game game      = new Game();

            Messages.Messages messages = new Messages.Messages();


            while (Frame <= MaxFrames)
            {
                Frame frameDetails = new Frame(Frame);
                messages.FrameMessage(Frame);


                bool inFrame = true;
                while (inFrame)
                {
                    string roll = Console.ReadLine();

                    if (Int32.TryParse(roll, out int value) && ValidateRoll(frameDetails, value))
                    {
                        Roll rollPins = new Roll();
                        rollPins.Pins = value;
                        frameDetails.Rolls.Add(rollPins);

                        if (rollPins.Pins == 10)
                        {
                            messages.StrikeMessage();
                            Frame  += 1;
                            inFrame = false;
                            continue;
                        }

                        if (frameDetails.Rolls.Count == 2)
                        {
                            if (DetermineSpare(frameDetails))
                            {
                                messages.SpareMessage();
                            }

                            if (Frame == 10 && (DetermineSpare(frameDetails) || DetermineStrike(frameDetails)))
                            {
                                continue;
                            }

                            Frame  += 1;
                            inFrame = false;
                        }

                        if (frameDetails.Rolls.Count == 3)
                        {
                            Frame  += 1;
                            inFrame = false;
                        }
                    }
                    else
                    {
                        Console.WriteLine("Please make sure your enter a valid score, try entering again.");
                    }
                }

                game.Frames.Add(frameDetails);
                Console.WriteLine("Game Summary: " + CalculateScore(game));
            }


            Console.WriteLine("Game over, thanks for playing!");
            Console.ReadLine();
        }