Beispiel #1
0
        bool ChooseAction(int index, Simulator sim)
        {
            bool success = false;

            if (index < _hand.Count && _hand[index]._type == Card.Type.Action)
            {
                Card.Action action = (Card.Action)_hand[index];
                action.PerformAction(this, sim);
                _currentAction = action;
                sim._lastNumberPressed = -1;
                success = true;
            }

            return success;
        }
Beispiel #2
0
        public void UpdateActionState(Simulator sim)
        {
            //Console.WriteLine("    " + _actionState.ToString());

            if (_actionState == ActionState.Idle)
            {
                if (AreThereActions())
                {
                    // 1. List Actions in hand
                    _actionState = ActionState.Choose;
                    PrintActions(6);
                }
                else
                {
                    // go to buy phase if no actions
                    Console.Write(" no actions, go to buy phase.\n");
                    _currentPhase = Phase.Buy;
                }
            }
            else if (_actionState == ActionState.Choose)
            {
                // Wait for input
                if (sim._lastNumberPressed > -1)
                {
                    // 2. Choose Action
                    _actionState = ActionState.Perform;

                    //Console.WriteLine("      Pressed: " + sim._lastNumberPressed);
                    ChooseAction(sim._lastNumberPressed, sim);
                }
                else
                {
                    Console.Write(" needs to play an action or skip.\n");
                }
            }
            else if (_actionState == ActionState.Perform)
            {
                if (_currentAction != null)
                {
                    Console.WriteLine(" is playing " + _currentAction._name + ".");

                    bool done = _currentAction.Update(this, sim);

                    // TODO: More actions? Repeat #2

                    if (done)
                    {
                        _currentAction = null;
                        _actionState = ActionState.Idle;
                        _currentPhase = Phase.Buy;
                    }
                }
                else
                {
                    _actionState = ActionState.Idle;
                    _currentPhase = Phase.Buy;
                }
            }
        }