blob: 5ea9402a92b76a73d4338a7ce629fdc58dc91454 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
using System;
using DotnetPgn.Models;
namespace DotnetPgn
{
public static class PieceParser
{
public static Piece ParsePiece(string sanPiece)
{
return sanPiece switch
{
"P" or "p" or "" => Piece.Pawn,
"N" or "n" => Piece.Knight,
"B" or "b" => Piece.Bishop,
"R" or "r" => Piece.Rook,
"Q" or "q" => Piece.Queen,
"K" or "k" => Piece.King,
_ => throw new ArgumentException($"'{sanPiece} is not a valid piece.'"),
};
}
}
}
|