feat: initial project structure with Snake.Core, CLI and Avalonia skeleton
This commit is contained in:
24
Snake.Core/Board.cs
Normal file
24
Snake.Core/Board.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
namespace Snake.Core;
|
||||
|
||||
public sealed class Board
|
||||
{
|
||||
public Board(int width, int height)
|
||||
{
|
||||
if (width < 2)
|
||||
throw new ArgumentOutOfRangeException(nameof(width), "Width must be at least 2.");
|
||||
|
||||
if (height < 2)
|
||||
throw new ArgumentOutOfRangeException(nameof(height), "Height must be at least 2.");
|
||||
|
||||
Width = width;
|
||||
Height = height;
|
||||
}
|
||||
|
||||
public int Width { get; }
|
||||
|
||||
public int Height { get; }
|
||||
|
||||
public bool IsWithinBounds(Position position) =>
|
||||
position.X >= 0 && position.X < Width &&
|
||||
position.Y >= 0 && position.Y < Height;
|
||||
}
|
||||
Reference in New Issue
Block a user