[Add] Field and mine generation

This commit is contained in:
2026-06-06 21:18:10 +07:00
parent 8ed9cc655f
commit 1a6f8901a2
17 changed files with 481 additions and 7 deletions
@@ -1,3 +1,4 @@
using System.Collections.Generic;
using Minesweeper.Config;
using Minesweeper.Core;
@@ -6,17 +7,29 @@ namespace Minesweeper.Presentation.ReadModels
public sealed class GameReadModel : IGameReadModel
{
private readonly MinesweeperGameConfig config;
private readonly IBoardService boardService;
private readonly IGameStateService gameStateService;
public GameReadModel(MinesweeperGameConfig config, IGameStateService gameStateService)
public GameReadModel(MinesweeperGameConfig config, IBoardService boardService, IGameStateService gameStateService)
{
this.config = config;
this.boardService = boardService;
this.gameStateService = gameStateService;
}
public GameState State => gameStateService.Current;
public int Width => config.Width;
public int Height => config.Height;
public int MinesCount => config.MinesCount;
public int Width => boardService.Width > 0 ? boardService.Width : config.Width;
public int Height => boardService.Height > 0 ? boardService.Height : config.Height;
public int MinesCount => boardService.MinesCount > 0 ? boardService.MinesCount : config.MinesCount;
public bool TryGetCell(int x, int y, out BoardCellData cell)
{
return boardService.TryGetCell(x, y, out cell);
}
public IReadOnlyList<BoardCellData> GetCells()
{
return boardService.GetCells();
}
}
}