public void ShouldParsePromotion(string notation, ChessPieceName piece)
        {
            StandardAlgebraicNotation.TryParse(notation, out var an).ShouldBeTrue();

            an.PromotionPiece.HasValue.ShouldBeTrue();
            an.PromotionPiece.Value.ShouldBe(piece);
        }
        public void ShouldParsePieceName(string notation, ChessPieceName piece)
        {
            StandardAlgebraicNotation.Parse(notation);

            StandardAlgebraicNotation.TryParse(notation, out var an).ShouldBeTrue();

            an.Piece.ShouldBe(piece);
        }
Exemplo n.º 3
0
        protected ChessPieceEntity(Colours player, ChessPieceName piece)
        {
            EntityType = (int)piece;
            EntityName = piece.ToString();
            Owner      = (int)player;

            Player = player;
            Piece  = piece;
        }
 public StandardAlgebraicNotation(ChessPieceName piece,
                                  int?fromFileX, int?fromRankY, int toFileX, int toRankY,
                                  SanMoveTypes moveType         = SanMoveTypes.Move,
                                  ChessPieceName?promotionPiece = null, bool inCheck = false)
 {
     Piece          = piece;
     FromFileX      = fromFileX;
     FromRankY      = fromRankY;
     ToFileX        = toFileX;
     ToRankY        = toRankY;
     MoveType       = moveType;
     PromotionPiece = promotionPiece;
     InCheck        = inCheck;
     CastleMove     = CastleSide.None;
 }
Exemplo n.º 5
0
 public static char ToSanToken(ChessPieceName piece)
 {
     return(SanPieceNames[piece]);
 }
        public void Should_find_promotions(string sanText, string expectedMoveText, Colours toPlay, ChessPieceName promotionPiece)
        {
            var builder = new ChessBoardBuilder()
                          .Board("    k   " +
                                 "       P" +
                                 "        " +
                                 "        " +
                                 "        " +
                                 "        " +
                                 "        " +
                                 "    K   "
                                 );

            var game = ChessFactory.CustomChessGame(builder.ToGameSetup(), toPlay);
            var move = new SanMoveFinder(game.BoardState)
                       .Find(sanText.ToSan(), toPlay);

            Assert.NotNull(move, "No move found!");

            Assert.That(move.ToChessCoords(), Is.EqualTo(expectedMoveText));

            var moveExtraData = move.ExtraData;

            Assert.NotNull(moveExtraData);
            var data = ChessFactory.MoveExtraData(toPlay, promotionPiece);

            Assert.That(move.ToChessCoords(), Is.EqualTo(expectedMoveText));
            Assert.That(data, Is.EqualTo(moveExtraData), $"Unexpected promotion: {moveExtraData}");
        }
Exemplo n.º 7
0
 public ChessPieceEntityFactoryTypeExtraData(Colours owner, ChessPieceName piece)
 {
     Owner     = owner;
     PieceName = piece;
 }
Exemplo n.º 8
0
 public ChessPieceEntity Create(ChessPieceName pieceName, Colours colour)
 {
     return(Factory[pieceName](colour));
 }
Exemplo n.º 9
0
 public bool Is(ChessPieceName piece) => piece == Piece;
Exemplo n.º 10
0
 public bool Is(Colours owner, ChessPieceName piece) => owner == Player && piece == Piece;
        public static char ToChar(ChessPieceName piece, Colours owner)
        {
            var c = PieceNames.FirstOrDefault(n => n.Value == piece).Key;

            return(owner == Colours.White ? char.ToUpper(c) : char.ToLower(c));
        }
Exemplo n.º 12
0
 public static ChessPieceEntityFactory.ChessPieceEntityFactoryTypeExtraData MoveExtraData(Colours owner,
                                                                                          ChessPieceName piece)
 => new ChessPieceEntityFactory.ChessPieceEntityFactoryTypeExtraData(owner, piece);
Exemplo n.º 13
0
 private void WithPiece(ChessPieceName c) => _piece         = c;