AIsOfCatan.MainActions.DieRoll C# (CSharp) Метод

DieRoll() публичный Метод

Allow the build actions to be called
public DieRoll ( ) : void
Результат void
        public void DieRoll()
        {
            isAfterDieRoll = true;
        }

Usage Example

Пример #1
0
        /// <summary>
        /// Executes all parts of a players turn
        ///     1. Allow the play of a development card before the dice are rolled
        ///     2. Roll the dice, hand out resources to all players, and move the robber if roll is 7
        ///     3. Allow all actions according to the rules
        /// </summary>
        /// <param name="player">The player whose turn it is</param>
        private void TakeTurn(Player player)
        {
            var actions = new MainActions(player, this);

            player.Agent.BeforeDiceRoll(CurrentGamestate(), actions);

            int roll = RollDice();

            actions.DieRoll();
            Log(new RollLogEvent(player.Id, roll));

            if (roll == 7)
            {
                //Discard if over 7 cards
                foreach (var p in players)
                {
                    if (p.Resources.Count > 7)
                    {
                        var cards = p.Agent.DiscardCards(CurrentGamestate(p.Id), p.Resources.Count / 2);
                        if (cards.Length != p.Resources.Count / 2)
                        {
                            //Clone, shuffle, take, convert
                            cards = p.Resources.ToList().OrderBy(e => Guid.NewGuid()).Take(p.Resources.Count / 2).ToArray();
                        }
                        foreach (var c in cards)
                        {
                            PayResource(p, c);
                        }
                        Log(new DiscardCardsLogEvent(p.Id, cards.ToList()));
                    }
                }
                MoveRobber(player, CurrentGamestate());
            }
            else
            {
                HandOutResources(roll);
            }
            var afterResourcesState = CurrentGamestate();

            player.Agent.PerformTurn(afterResourcesState, actions);

            player.NewDevelopmentCards.Clear(); //Reset new development cards
        }
All Usage Examples Of AIsOfCatan.MainActions::DieRoll