Beispiel #1
0
        /// <summary>
        /// Process the end of the turn
        /// </summary>
        public void EndTurnOf(Element element)
        {
            var context = new TurnContext(this, Stage, element, RNG);

            for (int i = 0; i < element.Data.Count; i++)
            {
                IElementDataComponent dC = element.Data[i];
                if (dC is IEndOfTurn)
                {
                    ((IEndOfTurn)dC).EndOfTurn(context);
                }
                if (dC is IDeletable && ((IDeletable)dC).IsDeleted)
                {
                    element.Data.RemoveAt(i);
                    i--;
                }
            }

            // Clean up to end the turn
            CleanUpDeleted();

            if (!Controlled.IsDeleted && Controlled != element) //Pause after player's turn
            {
                NextTurn();
            }
            else
            {
                DelayAITurn(); //Reset the countdown
            }
        }
Beispiel #2
0
        /// <summary>
        /// Process the start of the turn
        /// </summary>
        /// <param name="element"></param>
        public void StartTurnOf(Element element)
        {
            var context = new TurnContext(this, Stage, element, RNG);

            Active = element;
            for (int i = 0; i < element.Data.Count; i++)
            {
                IElementDataComponent dC = element.Data[i];
                if (dC is IStartOfTurn)
                {
                    ((IStartOfTurn)dC).StartOfTurn(context);
                }
                if (dC is IDeletable && ((IDeletable)dC).IsDeleted)
                {
                    element.Data.RemoveAt(i);
                    i--;
                }
            }

            if (element != Controlled)
            {
                var        ai      = new ActionSelectionAI(); //TEMP?
                var        actions = element.GetData <AvailableActions>();
                GameAction tAction = ai.SelectAction(context, actions.Actions);

                tAction.Enact(Log, new EffectContext(element, this));
                EndTurnOf(element);
            }
            else
            {
                var actions = element.GetData <AvailableActions>();
                if (actions == null || actions.Actions.Count == 0)
                {
                    EndTurnOf(element);
                }
            }
        }