aboutsummaryrefslogtreecommitdiff
path: root/DotnetPgn/Models
diff options
context:
space:
mode:
Diffstat (limited to 'DotnetPgn/Models')
-rw-r--r--DotnetPgn/Models/Enums.cs18
-rw-r--r--DotnetPgn/Models/HalfMove.cs11
-rw-r--r--DotnetPgn/Models/Square.cs22
3 files changed, 51 insertions, 0 deletions
diff --git a/DotnetPgn/Models/Enums.cs b/DotnetPgn/Models/Enums.cs
new file mode 100644
index 0000000..893f2fa
--- /dev/null
+++ b/DotnetPgn/Models/Enums.cs
@@ -0,0 +1,18 @@
+namespace DotnetPgn.Models
+{
+ public enum Piece
+ {
+ Pawn,
+ Knight,
+ Bishop,
+ Rook,
+ Queen,
+ King,
+ }
+
+ public enum Player
+ {
+ White,
+ Black,
+ }
+} \ No newline at end of file
diff --git a/DotnetPgn/Models/HalfMove.cs b/DotnetPgn/Models/HalfMove.cs
new file mode 100644
index 0000000..b94d77d
--- /dev/null
+++ b/DotnetPgn/Models/HalfMove.cs
@@ -0,0 +1,11 @@
+namespace DotnetPgn.Models
+{
+ public record HalfMove
+ {
+ public int MoveNumber {get; init;}
+ public Player Player { get; init; }
+ public Piece Piece { get; init; }
+ public Square SourceSquare { get; init; }
+ public Square TargetSquare { get; init; }
+ }
+} \ No newline at end of file
diff --git a/DotnetPgn/Models/Square.cs b/DotnetPgn/Models/Square.cs
new file mode 100644
index 0000000..a3910d3
--- /dev/null
+++ b/DotnetPgn/Models/Square.cs
@@ -0,0 +1,22 @@
+using System;
+
+namespace DotnetPgn.Models
+{
+ public record Square
+ {
+ public char Rank { get; }
+ public int File { get; }
+
+ public Square(char rank, int file)
+ {
+ if (rank < 'a' || rank > 'h')
+ throw new ArgumentException($"Invalid rank '{rank}'.");
+
+ if (file < 1 || file > 8)
+ throw new ArgumentException($"Invalid file '{file}'.");
+
+ Rank = rank;
+ File = file;
+ }
+ }
+} \ No newline at end of file