コード例 #1
0
ファイル: Rulebook.cs プロジェクト: mapplet/Chess
        public List<Tuple<int, int>> getValidMoves(Piece currentPiece, Gameboard gameboard, bool doRecurse = true)
        {
            this.copyOfCurrentPiece = new Piece(currentPiece);
            this.gameboard = new Gameboard(gameboard);

            switch (currentPiece.type)
            {
                case (int)type.rock: // tower
                    Rock rock = new Rock();
                    this.validDestinations = rock.Rules(currentPiece, gameboard);
                    if (doRecurse)
                        cleanUp();
                    return validDestinations;
                case (int)type.knight: // horsie
                    Knight knight = new Knight();
                    this.validDestinations = knight.Rules(currentPiece, gameboard);
                    if (doRecurse)
                        cleanUp();
                    return validDestinations;
                case (int)type.bishop: // springare
                    Bishop bishop = new Bishop();
                    this.validDestinations = bishop.Rules(currentPiece, gameboard);
                    if (doRecurse)
                        cleanUp();
                    return validDestinations;
                case (int)type.queen: //los quuenos
                    Queen queen = new Queen();
                    this.validDestinations = queen.Rules(currentPiece, gameboard);
                    if (doRecurse)
                        cleanUp();
                    return validDestinations;
                case (int)type.king: // los kingos
                    King king = new King();
                    this.validDestinations = king.Rules(currentPiece, gameboard);
                    if (doRecurse)
                        cleanUp();
                    return validDestinations;
                case (int)type.pawn: // los farmeros
                    Pawn pawn = new Pawn();
                    this.validDestinations = pawn.Rules(currentPiece, gameboard);
                    if (doRecurse)
                        cleanUp();
                    return validDestinations;
            }
            return new List<Tuple<int,int>>();
        }