Пример #1
0
        private void eatCoin(Coin i_Coin, Coin i_RivalCoin)
        {
            if (i_Coin != null && i_RivalCoin != null)
            {
                if (i_Coin is KingCoin)
                {
                    KingCoin kingCopy = i_Coin as KingCoin;

                    if (kingCopy.IsAbleToEat(i_RivalCoin.Coordinates, out Coordinate target))
                    {
                        Board.RemoveCoinFromBoard(kingCopy);
                        kingCopy.Coordinates.CopyCoordinates(target);
                        Board.SetCoinOnBoard(kingCopy);
                        Player rivalPlayer = GetCoinOwner(i_RivalCoin);
                        Board.RemoveCoinFromBoard(i_RivalCoin);
                        rivalPlayer.CoinsList.Remove(i_RivalCoin);
                        kingCopy.UpdateMoves();
                    }
                }
                else if (!i_Coin.IsKing && i_Coin.IsAbleToEat(i_RivalCoin.Coordinates, out Coordinate target))
                {
                    Board.RemoveCoinFromBoard(i_Coin);
                    i_Coin.Coordinates.CopyCoordinates(target);
                    Board.SetCoinOnBoard(i_Coin);
                    Player rivalPlayer = GetCoinOwner(i_RivalCoin);
                    Board.RemoveCoinFromBoard(i_RivalCoin);
                    rivalPlayer.CoinsList.Remove(i_RivalCoin);
                    i_Coin.UpdateMoves();
                }
            }
        }
Пример #2
0
        public void UpdatePlayersAvailableMoves()
        {
            List <Player> players = new List <Player>();

            players.Add(Player1);
            players.Add(Player2);

            foreach (Player currentPlayer in players)
            {
                foreach (Coin currentCoin in currentPlayer.CoinsList)
                {
                    if (!currentCoin.IsKing)
                    {
                        currentCoin.UpdateMoves();
                    }
                    // If king
                    else if (currentCoin is KingCoin)
                    {
                        KingCoin kingCopy = currentCoin as KingCoin;
                        kingCopy.UpdateMoves();
                    }
                }

                // Clean no eating moves
                if (HasEatingMoves(currentPlayer))
                {
                    cleanNoEatingMoves(currentPlayer.CoinsList);
                }
            }
        }