Exemplo n.º 1
0
        public void Move(int sourceIndex, int destIndex)
        {
            int offset = Math.Abs(sourceIndex - destIndex);


            if (table.GameTable[destIndex].Owner != CurrentPlayer && table.GameTable[destIndex].Owner != null)
            {
                table.TransferCoins(OtherPlayer, destIndex, OtherPenaltyIndex);
                OtherPlayer.AddPoints(destIndex);
                OtherPlayer.Penalty = true;
                window.UpdateStackView(OtherPenaltyIndex);
            }

            table.TransferCoins(CurrentPlayer, sourceIndex, destIndex);
            window.UpdateStackView(sourceIndex);
            window.UpdateStackView(destIndex);

            if (table.GameTable[PenaltyIndex].CoinCount == 0)
            {
                CurrentPlayer.Penalty = false;
            }


            CurrentPlayer.SubPoints(offset);
            window.UpdatePts();

            if (CheckVictory(destIndex))
            {
                CurrentPlayer.GamePoints += 1;
                EndRound();
                return;
            }


            if (offset == dice[0] + dice[1])
            {
                moves = 0;
            }
            else
            {
                moves--;
                if (offset == dice.Result[0])
                {
                    dice[0] = 0;
                }

                else
                {
                    dice[1] = 0;
                }
                window.UpdateDice();
            }

            if (AI.PossibleMoveCount(this) == 0)
            {
                moves = 0;
            }

            if (moves == 0)
            {
                NextPlayer();
            }
            else
            {
                window.WaitForMove();
            }
        }