Exemplo n.º 1
0
        public int PlaceCard(Card newCard, int playerNum)
        {
            if (State != ModelState.Play)
            {
                return(-1);
            }

            if (PileData.Turn != playerNum)
            {
                return(-2);
            }

            if (PileData.CardNumber > 0)
            {
                PileData.FirstCardType = PileData.Pile[0].Type;
            }

            switch (PileData.FirstCardType)
            {
            case CardType.None:
            case CardType.Joker:
                break;

            default:
                if (PlayerHandContains(PileData.FirstCardType, playerNum) && newCard.Type != PileData.FirstCardType)
                {
                    return(-3);
                }
                break;
            }

            PileData.Pile[PileData.CardNumber] = newCard;
            PileData.CardNumber++;
            PileData.Turn = GetNextPlayer(PileData.Turn);

            Players[playerNum].Hand.Remove(newCard);

            // If pile is full
            if (PileData.CardNumber == Constants.PlayerNumber)
            {
                int winner = DeterminePileWinner();
                RoundData.PileWins[winner]++;
                PileData.Reset(winner);

                if (RoundOver())
                {
                    GivePoints(); // Not implemented
                    CallData.Reset();
                    RoundData.Reset();
                    StartPlayer = GetNextPlayer(StartPlayer);
                    PileData.Reset(StartPlayer);
                }
            }

            return(0);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initialize the game model
 /// </summary>
 public void InitializeVariables()
 {
     CallData.Reset();
     RoundData.Reset();
     PileData.Reset(0);
 }