Пример #1
0
        public Card PickUpCard(IRummyPlayer sender, CardPiles pile)
        {
            if (sender.PlayerIndex != _currentPlayerIndex)
            {
                throw new Exception("The Player Indexes don't align");
            }
            Card returnitem = null;

            if (pile == CardPiles.Discard)
            {
                _playersHands[sender.PlayerIndex].Hand.Add(_table.DiscardPile[_table.DiscardPile.Count - 1]);
                returnitem = _table.DiscardPile[_table.DiscardPile.Count - 1];
                _table.DiscardPile.RemoveAt(_table.DiscardPile.Count - 1);
                _currentTurnCardPickedUp = returnitem;
            }
            else if (pile == CardPiles.Stock)
            {
                _playersHands[sender.PlayerIndex].Hand.Add(_currentGameDeck.DrawDeck[_currentGameDeck.DrawDeck.Count - 1]);
                returnitem = _currentGameDeck.DrawDeck[_currentGameDeck.DrawDeck.Count - 1];
                _currentGameDeck.DrawDeck.RemoveAt(_currentGameDeck.DrawDeck.Count - 1);
                _currentTurnCardPickedUp = null;
            }
            if (returnitem == null)
            {
                throw new Exception("Picking up a card failed");
            }
            return(returnitem);
        }
Пример #2
0
        public void StartTurn() //this signals to the player that it is their turn.  This is where they will do all their decision making and raising events
        {
            //pick up top card from discard pile or stock pile
            CardPiles mypilechoice = CardPiles.Stock;

            //decide if top card discard looks good...
            if (_RummyTable.TopDiscardCard.Suit == Suit.Hearts) //just a silly example of choosing the card if it is hearts...
            {
                mypilechoice = CardPiles.Discard;
            }
            Card NewCard;

            Debug.Print("Bot " + _MyPlayerIndex + " Hand Size is " + _MyHand.Count);
            ChoosePile(this, mypilechoice, out NewCard);
            _MyHand.Add(NewCard);
            Debug.Print("Bot " + _MyPlayerIndex + " Drew a card!");
            Debug.Print("Bot " + _MyPlayerIndex + " Hand Size is " + _MyHand.Count);
            //check out new card...


            //see if we have any melds...


            //see if we can add any cards to existing melds...


            //Choose what card to get rid of...
            Card CardToDiscard;

            if (_MyHand.Count > 0)
            {
                //make intelligent choice for what card to discard...

                CardToDiscard = _MyHand[0]; //... or not that intelligent...
                _MyHand.Remove(CardToDiscard);
            }
            else
            {
                CardToDiscard = null;
            }

            //Notify that we are done our turn ********this is mandatory
            Debug.Print("Bot " + _MyPlayerIndex + " Discarded.  Hand Size is " + _MyHand.Count);

            if (_MyPlayerIndex == 3)
            {
                DoneTurn(this, CardToDiscard, true);
            }
            else
            {
                DoneTurn(this, CardToDiscard, _MyHand.Count == 0);
            }
        }
Пример #3
0
 private void Bots_ChoosePile(IRummyPlayer sender, CardPiles Pile, out Card DrawCard)
 {
     DrawCard = _mainGame.PickUpCard(sender, Pile);
 }