コード例 #1
0
        /// <summary>
        /// Action roll dice for player
        /// </summary>
        public void RollDice()
        {
            turnCount++;

            // Roll dice process
            int roll1 = DieOne.Roll();
            int roll2 = DieSecond.Roll();

            int sum = roll1 + roll2;

            doPlayAgain = roll1 == roll2;

            // If number are the same player can re-roll dices
            if (doPlayAgain)
            {
                InfoBulle = "Double, Relancez!!";

                Reader(infoBulle);

                doubleDiceCount++;

                if (doubleDiceCount >= 3)
                {
                    //TODO send player to jail

                    SetNextPlayerTurn();
                }
            }
            else
            {
                InfoBulle = "Avancez de " + sum + " cases";
                Reader(infoBulle);

                SetNextPlayerTurn();
            }

            // Move
            AbstractCase currentCase = Cases[CurrentPlayer.CurrentCaseIndex];

            CurrentPlayer.CurrentCaseIndex = CalculateNextCase(CurrentPlayer.CurrentCaseIndex, sum);
            AbstractCase nextCase = Cases[CurrentPlayer.CurrentCaseIndex];

            currentCase.Players.Remove(CurrentPlayer);
            nextCase.Players.Add(CurrentPlayer);

            // Execute case action
            string result = nextCase.Action(CurrentPlayer, (Platter)Model);

            if (nextCase.GetType() == typeof(PropertyCase) || nextCase.GetType() == typeof(StationCase))
            {
                MsgBoxYesNo msgbox = new MsgBoxYesNo(result);
                if ((bool)msgbox.ShowDialog())
                {
                    // Todo Buy property
                }
            }
            else
            {
                new MsgBoxOk(result).ShowDialog();
            }
        }