[Add] Basic project architecture

This commit is contained in:
2026-06-06 20:53:30 +07:00
parent 9ebedb12ec
commit 8ed9cc655f
79 changed files with 1080 additions and 9 deletions
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 648cba2aa826df04aa6de2236d532ff7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,12 @@
using Minesweeper.Core;
namespace Minesweeper.Presentation.Adapters
{
public sealed class GameStateViewAdapter : IGameStateViewAdapter
{
public string GetDisplayName(GameState state)
{
return state.ToString();
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: a10e635e4da16d24db457ead4d139896
@@ -0,0 +1,9 @@
using Minesweeper.Core;
namespace Minesweeper.Presentation.Adapters
{
public interface IGameStateViewAdapter
{
string GetDisplayName(GameState state);
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 058bab5bc0f87f64dbbf668e5e390216
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ec6192ca6506ac64c8aa089466c86db5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,10 @@
namespace Minesweeper.Presentation.Factories
{
public sealed class CellViewFactory : ICellViewFactory
{
public string BuildCellName(int x, int y, int value, bool isMine)
{
return $"bt_{x}_{y}_{(isMine ? "M" : value.ToString())}";
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 681a16a970ddf3546bb4f99d93a184ca
@@ -0,0 +1,7 @@
namespace Minesweeper.Presentation.Factories
{
public interface ICellViewFactory
{
string BuildCellName(int x, int y, int value, bool isMine);
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 34c31a0f01c730440a2bcdac0f775dd8
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3895ae14930e10841a7562a478c871ec
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,50 @@
using Minesweeper.Commands;
using Minesweeper.Presentation.ReadModels;
using Minesweeper.Presentation.Views;
namespace Minesweeper.Presentation.Presenters
{
public sealed class GamePresenter : IPresenter
{
private readonly IGameCommandDispatcher commandDispatcher;
private readonly IGameReadModel readModel;
private readonly IGameView view;
public GamePresenter(IGameCommandDispatcher commandDispatcher, IGameReadModel readModel, IGameView view = null)
{
this.commandDispatcher = commandDispatcher;
this.readModel = readModel;
this.view = view;
}
public void Initialize()
{
_ = readModel.State;
if (view != null)
{
view.RestartRequested += OnRestartRequested;
view.GoToMenuRequested += OnGoToMenuRequested;
}
}
public void Dispose()
{
if (view != null)
{
view.RestartRequested -= OnRestartRequested;
view.GoToMenuRequested -= OnGoToMenuRequested;
}
}
private void OnRestartRequested()
{
commandDispatcher.Dispatch(new RestartCommand());
}
private void OnGoToMenuRequested()
{
commandDispatcher.Dispatch(new GoToMenuCommand());
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 9f85646fc4851054e9efffa3ab1f6853
@@ -0,0 +1,9 @@
using System;
namespace Minesweeper.Presentation.Presenters
{
public interface IPresenter : IDisposable
{
void Initialize();
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e0fcee9aa500b62429eb4ffa2249de9c
@@ -0,0 +1,38 @@
using Minesweeper.Commands;
using Minesweeper.Presentation.Views;
namespace Minesweeper.Presentation.Presenters
{
public sealed class MainMenuPresenter : IPresenter
{
private readonly IGameCommandDispatcher commandDispatcher;
private readonly IMainMenuView view;
public MainMenuPresenter(IGameCommandDispatcher commandDispatcher, IMainMenuView view = null)
{
this.commandDispatcher = commandDispatcher;
this.view = view;
}
public void Initialize()
{
if (view != null)
{
view.StartClicked += OnStartClicked;
}
}
public void Dispose()
{
if (view != null)
{
view.StartClicked -= OnStartClicked;
}
}
private void OnStartClicked()
{
commandDispatcher.Dispatch(new StartGameCommand());
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 835a3b63609e9864fa6154be8b8283ad
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 590e96d08af41e346b49a7ce43641afb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,22 @@
using Minesweeper.Config;
using Minesweeper.Core;
namespace Minesweeper.Presentation.ReadModels
{
public sealed class GameReadModel : IGameReadModel
{
private readonly MinesweeperGameConfig config;
private readonly IGameStateService gameStateService;
public GameReadModel(MinesweeperGameConfig config, IGameStateService gameStateService)
{
this.config = config;
this.gameStateService = gameStateService;
}
public GameState State => gameStateService.Current;
public int Width => config.Width;
public int Height => config.Height;
public int MinesCount => config.MinesCount;
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 1b2a816449e034a4f9635960881ec852
@@ -0,0 +1,12 @@
using Minesweeper.Core;
namespace Minesweeper.Presentation.ReadModels
{
public interface IGameReadModel
{
GameState State { get; }
int Width { get; }
int Height { get; }
int MinesCount { get; }
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e5c921f20dd6f1b40a1f73746265a63d
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0e2357d56da983b478c1cebe1e3ac363
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,10 @@
using System;
namespace Minesweeper.Presentation.Views
{
public interface IGameView : IView
{
event Action RestartRequested;
event Action GoToMenuRequested;
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: a8c5423ea37354a4e82b05aadfbf239f
@@ -0,0 +1,9 @@
using System;
namespace Minesweeper.Presentation.Views
{
public interface IMainMenuView : IView
{
event Action StartClicked;
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 66cad179080f23a479c3418932137653
@@ -0,0 +1,6 @@
namespace Minesweeper.Presentation.Views
{
public interface IView
{
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 66a8b79ae5812744680f9e386b007144
@@ -0,0 +1,19 @@
using System;
namespace Minesweeper.Presentation.Views
{
public sealed class NullGameView : IGameView
{
public event Action RestartRequested
{
add { }
remove { }
}
public event Action GoToMenuRequested
{
add { }
remove { }
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: c800a42df535f9347bea10f164fd2e15
@@ -0,0 +1,13 @@
using System;
namespace Minesweeper.Presentation.Views
{
public sealed class NullMainMenuView : IMainMenuView
{
public event Action StartClicked
{
add { }
remove { }
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 6b41dd95488a1db42adccef0225d2f89