コード例 #1
0
        public void runClassicYahtzee()
        {
            m_yahtzeeView.showClassicYahtzeeMenu();
            var input = Console.ReadKey();
            switch (input.Key)
            {
                //Play Classic Yahtzee
                case ConsoleKey.D1:
                case ConsoleKey.NumPad1:
                    // 1 = Classic Yahtzee
                    setVersionOfGame(1);
                    playGame();
                    break;

                //Show Compact list
                case ConsoleKey.D2:
                case ConsoleKey.NumPad2:
                    DBYahtzee db = new DBYahtzee();
                    List<Player> pl = db.getEndGameScore();
                    ScoreListView scoreList = new ScoreListView();
                    scoreList.showCompactList(pl);
                    runClassicYahtzee();
                    break;

                // Show Detailed list
                case ConsoleKey.D3:
                case ConsoleKey.NumPad3:
                    DBYahtzee db2 = new DBYahtzee();
                    List<Player> pl2 = db2.getEndGameScore();
                    ScoreListView scoreList2 = new ScoreListView();
                    scoreList2.showDetailedList(pl2);
                    runClassicYahtzee();
                    break;

                case ConsoleKey.D4:
                case ConsoleKey.NumPad4:
                    if (checkIfAnySavedGame() == null)
                    {
                        runClassicYahtzee();
                    }
                    setLoadedGameTrue();
                    setVersionOfGame(1);
                    playGame();
                    break;
                case ConsoleKey.D5:
                case ConsoleKey.NumPad5:
                    MasterController mc = new MasterController();
                    mc.run();
                    break;
                case ConsoleKey.Escape:
                    Environment.Exit(0);
                    break;
                default:
                    runClassicYahtzee();
                    break;
            }
        }
コード例 #2
0
        public void runStrictYahtzee()
        {
            m_yahtzeeView.showStrictYahtzeeMenu();
            var input = Console.ReadKey();

            switch (input.Key)
            {
            //Play Strict Yahtzee
            case ConsoleKey.D1:
            case ConsoleKey.NumPad1:
                // 2 = Strict Yahtzee
                setVersionOfGame(2);
                playGame();
                break;

            //Show Compact list
            case ConsoleKey.D2:
            case ConsoleKey.NumPad2:
                DBYahtzee     db        = new DBYahtzee();
                List <Player> pl        = db.getEndGameScore();
                ScoreListView scoreList = new ScoreListView();
                scoreList.showCompactList(pl);
                runStrictYahtzee();
                break;

            // Show Detailed list
            case ConsoleKey.D3:
            case ConsoleKey.NumPad3:
                DBYahtzee     db2        = new DBYahtzee();
                List <Player> pl2        = db2.getEndGameScore();
                ScoreListView scoreList2 = new ScoreListView();
                scoreList2.showDetailedList(pl2);
                runStrictYahtzee();
                break;

            case ConsoleKey.D4:
            case ConsoleKey.NumPad4:
                MasterController mc = new MasterController();
                mc.run();
                break;

            case ConsoleKey.Escape:
                Environment.Exit(0);
                break;

            default:
                runStrictYahtzee();
                break;
            }
        }
コード例 #3
0
        public void runStrictYahtzee()
        {
            m_yahtzeeView.showStrictYahtzeeMenu();
            var input = Console.ReadKey();
            switch (input.Key)
            {
                //Play Strict Yahtzee
                case ConsoleKey.D1:
                case ConsoleKey.NumPad1:
                    // 2 = Strict Yahtzee
                    setVersionOfGame(2);
                    playGame();
                    break;

                //Show Compact list
                case ConsoleKey.D2:
                case ConsoleKey.NumPad2:
                    DBYahtzee db = new DBYahtzee();
                    List<Player> pl = db.getEndGameScore();
                    ScoreListView scoreList = new ScoreListView();
                    scoreList.showCompactList(pl);
                    runStrictYahtzee();
                    break;

                // Show Detailed list
                case ConsoleKey.D3:
                case ConsoleKey.NumPad3:
                    DBYahtzee db2 = new DBYahtzee();
                    List<Player> pl2 = db2.getEndGameScore();
                    ScoreListView scoreList2 = new ScoreListView();
                    scoreList2.showDetailedList(pl2);
                    runStrictYahtzee();
                    break;

                case ConsoleKey.D4:
                case ConsoleKey.NumPad4:
                    MasterController mc = new MasterController();
                    mc.run();
                    break;
                case ConsoleKey.Escape:
                    Environment.Exit(0);
                    break;
                default:
                    runStrictYahtzee();
                    break;
            }
        }
コード例 #4
0
        protected void playGame()
        {
            bool playGame = true;
            if (loadedGame == false)
            {
                m_mainMenuView.showYahtzeeHeader();
                m_mainMenuView.showYahtzeMenu();
                m_yahtzeeGame.chooseNumberOfPlayers();
            }

            playerList = m_yahtzeeGame.getPlayers();
            do
            {

                m_mainMenuView.showYahtzeeHeader();
                m_yahtzeeView.showBoard(playerList);

                for (int i = 0; i < playerList.Count; i++)
                {
                    m_yahtzeeView.showPlayersTurn(playerList[i]);
                    m_yahtzeeView.rollTheDiceMessage();

                    while (true)
                    {
                        try
                        {
                            m_yahtzeeView.showSaveMessage();

                            //check if player list holds a computer player
                            //then skip read key and switch statement and do the
                            //call the computer roll sequence
                            //read more in the ComputerPlayer class

                            var input = Console.ReadKey();
                            switch (input.Key)
                            {
                                case ConsoleKey.R:
                                    int[] dices = sequenceRollOfDices(playerList[i]);
                                    m_yahtzeeView.showWereToPlaceScore();
                                    switch (versionOfGame)
                                    {
                                        case 1:
                                            playerList[i].placePlayerScore(dices);
                                            break;
                                        case 2:
                                            //Adds 1 to numbers of turns the player as done, 13 is max
                                            playerList[i].addOneToNumbersOfTurn();
                                            playerList[i].placePlayerScoreInOrder(dices, playerList[i].getNumbersOfTurn());
                                            break;
                                    }

                                    playerList[i].updateUpperScore();
                                    playerList[i].updateTotalScore();

                                    m_mainMenuView.showYahtzeeHeader();
                                    m_yahtzeeView.showBoard(playerList);
                                    if (playerList[i].checkIfEndOfGame())
                                    {
                                        playGame = false;
                                    }

                                    break;
                                case ConsoleKey.S:
                                    m_yahtzeeGame.saveOnGoingGame();
                                    m_mainMenuView.showPressAnyKeyToQuit();
                                    Console.ReadLine();
                                    Environment.Exit(0);
                                    break;

                                case ConsoleKey.Escape:
                                    Environment.Exit(0);
                                    break;
                            }
                            break;
                        }
                        catch (Exception)
                        {
                            m_mainMenuView.showYahtzeeHeader();
                            m_yahtzeeView.showBoard(playerList);
                            m_yahtzeeView.showPlayersTurn(playerList[i]);
                            m_yahtzeeView.rollTheDiceMessage();
                        }
                    }
                    playerList[i].setDate();

                }

            } while (playGame);

            m_mainMenuView.showPressAnyKeyToGoBackToMainMenu();
            m_yahtzeeGame.saveEndGameScore();
            Console.ReadLine();
            MasterController mc = new MasterController();
            mc.run();
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: la222tc/YahtzeeGame
        static void Main(string[] args)
        {
            MasterController mc = new MasterController();

            mc.run();
        }
コード例 #6
0
        protected void playGame()
        {
            bool playGame = true;

            if (loadedGame == false)
            {
                m_mainMenuView.showYahtzeeHeader();
                m_mainMenuView.showYahtzeMenu();
                m_yahtzeeGame.chooseNumberOfPlayers();
            }

            playerList = m_yahtzeeGame.getPlayers();
            do
            {
                m_mainMenuView.showYahtzeeHeader();
                m_yahtzeeView.showBoard(playerList);

                for (int i = 0; i < playerList.Count; i++)
                {
                    m_yahtzeeView.showPlayersTurn(playerList[i]);
                    m_yahtzeeView.rollTheDiceMessage();

                    while (true)
                    {
                        try
                        {
                            m_yahtzeeView.showSaveMessage();

                            //check if player list holds a computer player
                            //then skip read key and switch statement and do the
                            //call the computer roll sequence
                            //read more in the ComputerPlayer class

                            var input = Console.ReadKey();
                            switch (input.Key)
                            {
                            case ConsoleKey.R:
                                int[] dices = sequenceRollOfDices(playerList[i]);
                                m_yahtzeeView.showWereToPlaceScore();
                                switch (versionOfGame)
                                {
                                case 1:
                                    playerList[i].placePlayerScore(dices);
                                    break;

                                case 2:
                                    //Adds 1 to numbers of turns the player as done, 13 is max
                                    playerList[i].addOneToNumbersOfTurn();
                                    playerList[i].placePlayerScoreInOrder(dices, playerList[i].getNumbersOfTurn());
                                    break;
                                }

                                playerList[i].updateUpperScore();
                                playerList[i].updateTotalScore();

                                m_mainMenuView.showYahtzeeHeader();
                                m_yahtzeeView.showBoard(playerList);
                                if (playerList[i].checkIfEndOfGame())
                                {
                                    playGame = false;
                                }

                                break;

                            case ConsoleKey.S:
                                m_yahtzeeGame.saveOnGoingGame();
                                m_mainMenuView.showPressAnyKeyToQuit();
                                Console.ReadLine();
                                Environment.Exit(0);
                                break;

                            case ConsoleKey.Escape:
                                Environment.Exit(0);
                                break;
                            }
                            break;
                        }
                        catch (Exception)
                        {
                            m_mainMenuView.showYahtzeeHeader();
                            m_yahtzeeView.showBoard(playerList);
                            m_yahtzeeView.showPlayersTurn(playerList[i]);
                            m_yahtzeeView.rollTheDiceMessage();
                        }
                    }
                    playerList[i].setDate();
                }
            } while (playGame);

            m_mainMenuView.showPressAnyKeyToGoBackToMainMenu();
            m_yahtzeeGame.saveEndGameScore();
            Console.ReadLine();
            MasterController mc = new MasterController();

            mc.run();
        }
コード例 #7
0
        public void runClassicYahtzee()
        {
            m_yahtzeeView.showClassicYahtzeeMenu();
            var input = Console.ReadKey();

            switch (input.Key)
            {
            //Play Classic Yahtzee
            case ConsoleKey.D1:
            case ConsoleKey.NumPad1:
                // 1 = Classic Yahtzee
                setVersionOfGame(1);
                playGame();
                break;

            //Show Compact list
            case ConsoleKey.D2:
            case ConsoleKey.NumPad2:
                DBYahtzee     db        = new DBYahtzee();
                List <Player> pl        = db.getEndGameScore();
                ScoreListView scoreList = new ScoreListView();
                scoreList.showCompactList(pl);
                runClassicYahtzee();
                break;

            // Show Detailed list
            case ConsoleKey.D3:
            case ConsoleKey.NumPad3:
                DBYahtzee     db2        = new DBYahtzee();
                List <Player> pl2        = db2.getEndGameScore();
                ScoreListView scoreList2 = new ScoreListView();
                scoreList2.showDetailedList(pl2);
                runClassicYahtzee();
                break;

            case ConsoleKey.D4:
            case ConsoleKey.NumPad4:
                if (checkIfAnySavedGame() == null)
                {
                    runClassicYahtzee();
                }
                setLoadedGameTrue();
                setVersionOfGame(1);
                playGame();
                break;

            case ConsoleKey.D5:
            case ConsoleKey.NumPad5:
                MasterController mc = new MasterController();
                mc.run();
                break;

            case ConsoleKey.Escape:
                Environment.Exit(0);
                break;

            default:
                runClassicYahtzee();
                break;
            }
        }