Пример #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
        private List <Coordinate> getNextMovesByDirections(eVerticalDirections i_Vertical, eHorizontalDirections i_Horizontal)
        {
            List <Coordinate> moves = new List <Coordinate>();

            Coordinate prevSquare = new Coordinate();

            prevSquare.CopyCoordinates(Coordinates);

            Coin kingCopy = new KingCoin(CoinType, Board);

            kingCopy.Coordinates.CopyCoordinates(Coordinates);
            Coordinate nextSquare = GetNextSquare(ref kingCopy, i_Vertical, i_Horizontal);

            kingCopy.Coordinates = prevSquare;


            while (Board.IsValid(nextSquare))
            {
                if (Board.IsEmptySquare(nextSquare))
                {
                    moves.Add(nextSquare);
                }
                else if (kingCopy.IsAbleToEat(nextSquare, out Coordinate target))
                {
                    moves.Add(target);
                    break;
                }
                else
                {
                    break;
                }
                prevSquare.CopyCoordinates(nextSquare);
                nextSquare = GetNextSquare(ref kingCopy, i_Vertical, i_Horizontal);
            }

            return(moves);
        }