Exemplo n.º 1
0
        public object Clone()
        {
            ChineseChessPiece piece = new ChineseChessPiece()
            {
                Name     = Name,
                Position = (ChineseChessPosition)Position.Clone()
            };

            return(piece);
        }
Exemplo n.º 2
0
        public static IEnumerable <ChineseChessPosition> PossibleMovesByPiece(ChineseChessPiece piece,
                                                                              Dictionary <ChineseChessPosition, Boolean> boardStates,
                                                                              Boolean isLowerTeam)
        {
            var name = piece.Name;
            List <ChineseChessPosition> listMoves = new List <ChineseChessPosition>();
            var curRow = piece.Position.Row;
            var curCol = piece.Position.Column;

            switch (name)
            {
            case "j":
                listMoves = PossibleMovesForJu(curRow, curCol, boardStates);
                break;

            case "m":
                listMoves = PossibleMovesForMa(curRow, curCol, boardStates);
                break;

            case "x":
                listMoves = PossibleMovesForXiang(curRow, curCol, boardStates, isLowerTeam);
                break;

            case "s":
                listMoves = PossibleMovesForShi(curRow, curCol, boardStates, isLowerTeam);
                break;

            case "k":
                listMoves = PossibleMovesForKing(curRow, curCol, boardStates).ToList <ChineseChessPosition>();
                break;

            case "p":
                listMoves = PossibleMovesForPao(curRow, curCol, boardStates);
                break;

            case "z":
                listMoves = PossibleMovesForZu(curRow, curCol, boardStates, isLowerTeam);
                break;

            default:
                throw new Exception("Unsupported name");
            }

            return(FilterBoundedMoves(curRow, curCol, listMoves, boardStates));
        }
Exemplo n.º 3
0
        public void MovePieceTo(ChineseChessPiece piece, ChineseChessPosition pos, Boolean?isCapture)
        {
            piece.MoveToPosition(pos);

            Boolean bCap = false;

            if (isCapture == null)
            {
                foreach (var piece2 in OppoPieces)
                {
                    if (piece2.Position == pos)
                    {
                        bCap = true;
                        break;
                    }
                }
            }

            if (bCap)
            {
                CaptureOppoPiece(pos);
            }
        }