93 lines
2.5 KiB
C#
93 lines
2.5 KiB
C#
using Minesweeper.Core;
|
|
|
|
namespace Minesweeper.Commands
|
|
{
|
|
public sealed class SelectFieldCommandHandler : IGameCommandHandler<SelectFieldCommand>
|
|
{
|
|
private readonly IGameStateService gameStateService;
|
|
|
|
public SelectFieldCommandHandler(IGameStateService gameStateService)
|
|
{
|
|
this.gameStateService = gameStateService;
|
|
}
|
|
|
|
public void Handle(SelectFieldCommand command)
|
|
{
|
|
gameStateService.SetState(GameState.FieldSelection);
|
|
}
|
|
}
|
|
|
|
public sealed class StartGameCommandHandler : IGameCommandHandler<StartGameCommand>
|
|
{
|
|
private readonly IGameStateService gameStateService;
|
|
|
|
public StartGameCommandHandler(IGameStateService gameStateService)
|
|
{
|
|
this.gameStateService = gameStateService;
|
|
}
|
|
|
|
public void Handle(StartGameCommand command)
|
|
{
|
|
gameStateService.SetState(GameState.Preparing);
|
|
}
|
|
}
|
|
|
|
public sealed class OpenCellCommandHandler : IGameCommandHandler<OpenCellCommand>
|
|
{
|
|
public void Handle(OpenCellCommand command)
|
|
{
|
|
}
|
|
}
|
|
|
|
public sealed class ToggleFlagCommandHandler : IGameCommandHandler<ToggleFlagCommand>
|
|
{
|
|
public void Handle(ToggleFlagCommand command)
|
|
{
|
|
}
|
|
}
|
|
|
|
public sealed class RestartCommandHandler : IGameCommandHandler<RestartCommand>
|
|
{
|
|
private readonly IGameStateService gameStateService;
|
|
|
|
public RestartCommandHandler(IGameStateService gameStateService)
|
|
{
|
|
this.gameStateService = gameStateService;
|
|
}
|
|
|
|
public void Handle(RestartCommand command)
|
|
{
|
|
gameStateService.SetState(GameState.Preparing);
|
|
}
|
|
}
|
|
|
|
public sealed class PauseCommandHandler : IGameCommandHandler<PauseCommand>
|
|
{
|
|
public void Handle(PauseCommand command)
|
|
{
|
|
}
|
|
}
|
|
|
|
public sealed class ResumeCommandHandler : IGameCommandHandler<ResumeCommand>
|
|
{
|
|
public void Handle(ResumeCommand command)
|
|
{
|
|
}
|
|
}
|
|
|
|
public sealed class GoToMenuCommandHandler : IGameCommandHandler<GoToMenuCommand>
|
|
{
|
|
private readonly IGameStateService gameStateService;
|
|
|
|
public GoToMenuCommandHandler(IGameStateService gameStateService)
|
|
{
|
|
this.gameStateService = gameStateService;
|
|
}
|
|
|
|
public void Handle(GoToMenuCommand command)
|
|
{
|
|
gameStateService.SetState(GameState.FieldSelection);
|
|
}
|
|
}
|
|
}
|