コード例 #1
0
        public ActionResult <PieceRead> Start(PieceCreate pieceRead)
        {
            var piecePosition = new Core.Entities.Position(pieceRead.Position.Row, pieceRead.Position.Col);
            var piece         = new Piece(
                piecePosition,
                (Core.Entities.PieceType)pieceRead.PieceType);

            piece.Move(piecePosition);
            _pieceRepostiory.SavePiece(piece);

            return(Ok(piece.ToPieceRead()));
        }
コード例 #2
0
        public ActionResult <Piece> Move(PieceUpdate pieceUpdate)
        {
            var piece         = _pieceRepostiory.GetPiece();
            var piecePosition = new Core.Entities.Position(pieceUpdate.Position.Row, pieceUpdate.Position.Col);


            if (!piece.IsCorrectMove(piecePosition))
            {
                return(UnprocessableEntity("Not allowed move"));
            }
            else
            {
                piece.Move(piecePosition);
                return(Ok(piece.ToPieceRead()));
            }
        }
コード例 #3
0
ファイル: PieceMappings.cs プロジェクト: wojciechN9/Chess
 public static Application.Models.Position ToPosition(this Core.Entities.Position position)
 {
     return(new Application.Models.Position(position.Row, position.Col));
 }