43 lines
1.5 KiB
C#
43 lines
1.5 KiB
C#
using System.Collections.Generic;
|
|
using Minesweeper.Core;
|
|
|
|
namespace Minesweeper.Presentation.ReadModels
|
|
{
|
|
public sealed class GameReadModel : IGameReadModel
|
|
{
|
|
private readonly IBoardService boardService;
|
|
private readonly IGameSettingsService settingsService;
|
|
private readonly IGameStateService gameStateService;
|
|
|
|
public GameReadModel(IBoardService boardService, IGameSettingsService settingsService, IGameStateService gameStateService)
|
|
{
|
|
this.boardService = boardService;
|
|
this.settingsService = settingsService;
|
|
this.gameStateService = gameStateService;
|
|
}
|
|
|
|
public GameState State => gameStateService.Current;
|
|
public int Width => boardService.Width > 0 ? boardService.Width : settingsService.SizeX;
|
|
public int Height => boardService.Height > 0 ? boardService.Height : settingsService.SizeY;
|
|
public int MinesCount => boardService.MinesCount > 0 ? boardService.MinesCount : settingsService.MinesCount;
|
|
public int FlaggedCellsCount => boardService.FlaggedCellsCount;
|
|
public int RemainingMinesCount => MinesCount - FlaggedCellsCount;
|
|
|
|
public bool TryGetCell(int x, int y, out BoardCellData cell)
|
|
{
|
|
return boardService.TryGetCell(x, y, out cell);
|
|
}
|
|
|
|
public IReadOnlyList<BoardCellData> GetCells()
|
|
{
|
|
return boardService.GetCells();
|
|
}
|
|
|
|
public IReadOnlyList<BoardCellData> GetChangedCells()
|
|
{
|
|
return boardService.LastChangedCells;
|
|
}
|
|
|
|
}
|
|
}
|