Exemplo n.º 1
0
            public override bool Update(Player owner, Simulator sim)
            {
                bool done = false;

                Player playerDiscarding = sim._players[_currentPlayerToDiscard];
                if (_currentPhase == MilitiaPhase.DiscardTwoCards)
                {
                    if (playerDiscarding._hand.Count > 3)
                    {
                        Console.WriteLine("      Player " + _currentPlayerToDiscard + " needs to discard 2 cards");
                        playerDiscarding.PrintHand(8);

                        if (sim._lastNumberPressed > -1)
                        {
                            Console.WriteLine("  Selected: " + sim._lastNumberPressed);

                            // Discard card from hand
                            Card card = playerDiscarding._hand[sim._lastNumberPressed];
                            playerDiscarding._discard.Add(card);
                            playerDiscarding._hand.RemoveAt(sim._lastNumberPressed);

                            sim._lastNumberPressed = -1;
                        }
                    }
                    else
                    {
                        // That player has discarded, move to next player
                        _currentPlayerToDiscard++;

                        if (sim._players.Count > _currentPlayerToDiscard)
                        {
                            // skip ahead by 2, if this is the owner
                            if (sim._players[_currentPlayerToDiscard] == owner)
                            {
                                _currentPlayerToDiscard += 2;
                            }
                            // skip ahead once
                            else
                            {
                                _currentPlayerToDiscard++;
                            }
                        }
                        else
                        {
                            _currentPlayerToDiscard = -1;
                            _currentPhase = MilitiaPhase.Idle;
                            done = true;
                        }

                        // check bounds
                        if (_currentPlayerToDiscard >= sim._numberOfPlayers)
                        {
                            _currentPlayerToDiscard = -1;
                            done = true;
                        }
                    }
                }

                return done;
            }
Exemplo n.º 2
0
            public override void PerformAction(Player owner, Simulator sim)
            {
                Console.Write(" begins " + _name + " action.\n");

                // +2 Money
                owner._treasureModifier += 2;

                // Invoke Militia phase
                _currentPhase = MilitiaPhase.DiscardTwoCards;
                _currentPlayerToDiscard = 0;

                if (sim._players[_currentPlayerToDiscard] == owner)
                {
                    _currentPlayerToDiscard++;
                }
            }