mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2026-01-19 16:20:52 -08:00
Complete game
This commit is contained in:
15
72_Queen/csharp/Move.cs
Normal file
15
72_Queen/csharp/Move.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace Queen;
|
||||
|
||||
internal record struct Move(int Diagonal, int Row)
|
||||
{
|
||||
public static readonly Move Left = new(1, 0);
|
||||
public static readonly Move DownLeft = new(2, 1);
|
||||
public static readonly Move Down = new(1, 1);
|
||||
|
||||
public bool IsValid => Diagonal > 0 && (IsLeft || IsDown || IsDownLeft);
|
||||
private bool IsLeft => Row == 0;
|
||||
private bool IsDown => Row == Diagonal;
|
||||
private bool IsDownLeft => Row * 2 == Diagonal;
|
||||
|
||||
public static Move operator *(Move move, int scale) => new(move.Diagonal * scale, move.Row * scale);
|
||||
}
|
||||
Reference in New Issue
Block a user