mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-23 07:29:02 -08:00
Add move logic
This commit is contained in:
13
67_One_Check/csharp/Move.cs
Normal file
13
67_One_Check/csharp/Move.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace OneCheck;
|
||||
|
||||
internal class Move
|
||||
{
|
||||
public int From { get; init; }
|
||||
public int To { get; init; }
|
||||
public int Jumped => (From + To) / 2;
|
||||
|
||||
public bool IsInRange => From >= 1 && From <= 64 && To >= 1 && To <= 64;
|
||||
public bool IsTwoSpacesDiagonally => RowDelta == 2 && ColumnDelta == 2;
|
||||
private int RowDelta => Math.Abs(From / 8 - To / 8);
|
||||
private int ColumnDelta => Math.Abs(From % 8 - To % 8);
|
||||
}
|
||||
Reference in New Issue
Block a user