Exemple #1
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            _sim = new Simulator(2);
        }
Exemple #2
0
        void UpdateBuyState(Simulator sim)
        {
            //Console.WriteLine("    " + _buyState.ToString());

            if (_buyState == BuyState.Idle)
            {
                Console.WriteLine(" buy a card:");
                // Print cards available to buy
                _handTreasure = CountMoneyFromTreasure();
                Console.WriteLine("      Treasure: " + _handTreasure);
                Console.WriteLine("      Treasure Modifier: " + _treasureModifier);
                PrintCardsToBuy(sim);
                _buyState = BuyState.Choose;
            }
            else if (_buyState == BuyState.Choose)
            {
                // Wait for input
                if (sim._lastNumberPressed > -1)
                {
                    //Console.WriteLine("      Pressed: " + sim._lastNumberPressed);

                    if (BuyCard(sim._lastNumberPressed, sim))
                    {
                        _buyState = BuyState.Idle;
                        _currentPhase = Phase.Cleanup;
                    }

                    sim._lastNumberPressed = -1;
                }
                else
                {
                    Console.Write(" buy a card.\n");
                }
            }
        }
Exemple #3
0
        void PrintCardsToBuy(Simulator sim)
        {
            for (int i = 0; i < sim._masterSet.Count; i++)
            {
                Card.Card card = sim._masterSet[i];
                Console.Write("      [" + i + "] [" + card._supplyCount + "] " + card._name);
                if (card._cost <= _handTreasure + _treasureModifier)
                {
                    Console.Write(" [BUY?]");
                }

                Console.Write("\n");
            }
        }
Exemple #4
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;
        }
Exemple #5
0
        bool BuyCard(int index, Simulator sim)
        {
            bool bought = false;
            Card.Card cardToBuy = sim._masterSet[index];

            if (sim._masterSet[index]._supplyCount > 0 && _handTreasure + _treasureModifier >= cardToBuy._cost)
            {
                Console.WriteLine(" bought " + cardToBuy._name + ".");
                _discard.Add(cardToBuy);
                cardToBuy._supplyCount--;

                _handTreasure = -cardToBuy._cost;
                bought = true;
            }
            else
            {
                Console.WriteLine(" can't buy " + sim._masterSet[index]._name + ".\n");
            }

            return bought;
        }
Exemple #6
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;
                }
            }
        }
Exemple #7
0
        public void Update(Simulator sim)
        {
            //Console.WriteLine("  " + _currentPhase.ToString());

            if (_currentPhase == Phase.Idle)
            {
                Console.Write(" turn starts.\n");
                // If hand is empty, pick first five cards
                if (_hand.Count == 0)
                {
                    DrawHand();
                }

                PrintNakedHand(2);

                _currentPhase = Phase.Action;
            }
            // Action Phase
            else if (_currentPhase == Phase.Action)
            {
                UpdateActionState(sim);
            }
            // Buy Phase
            else if (_currentPhase == Phase.Buy)
            {
                UpdateBuyState(sim);
            }
            // Put hand into Discard pile and Fill hand
            else if (_currentPhase == Phase.Cleanup)
            {
                Console.Write(" cleans up.\n");

                foreach (Card.Card card in _hand)
                {
                    _discard.Add(card);
                }

                _hand.Clear();
                _handTreasure = 0;
                _treasureModifier = 0;
                DrawHand();
                _currentPhase = Phase.Idle;
                sim.NextPlayerTurn();
            }
        }