-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f0500ca
commit 7b7b753
Showing
48 changed files
with
893 additions
and
466 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,61 @@ | ||
// Dot | ||
// Copyright (C) 2020-2024 Dust in the Wind | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Text.RegularExpressions; | ||
using Dot.GameHosting; | ||
using DustInTheWind.Dot.AdventureGame.ActionModel; | ||
using DustInTheWind.Dot.Domain; | ||
|
||
namespace DustInTheWind.Dot.Application.GameHostActions | ||
namespace DustInTheWind.Dot.Application.GameHostActions; | ||
|
||
public class ExitAction : ActionBase | ||
{ | ||
public class ExitAction : ActionBase | ||
{ | ||
private readonly IGameApplication gameApplication; | ||
private readonly IModuleHost moduleHost; | ||
|
||
public ExitAction(IGameApplication gameApplication) | ||
: base("exit", "quit", "x") | ||
{ | ||
this.gameApplication = gameApplication ?? throw new ArgumentNullException(nameof(gameApplication)); | ||
} | ||
public ExitAction(IModuleHost moduleHost) | ||
: base("exit", "quit", "x") | ||
{ | ||
this.moduleHost = moduleHost ?? throw new ArgumentNullException(nameof(moduleHost)); | ||
} | ||
|
||
public override string Description => "Exits the game."; | ||
public override string Description => "Exits the game."; | ||
|
||
public override List<string> Usage => new List<string> { "<<:exit>>", "<<:quit>>", "<<:x>>" }; | ||
public override List<string> Usage => new() { "<<:exit>>", "<<:quit>>", "<<:x>>" }; | ||
|
||
public override ActionType ActionType => ActionType.EnvironmentCommand; | ||
public override ActionType ActionType => ActionType.EnvironmentCommand; | ||
|
||
protected override List<Regex> CreateMatchers() | ||
protected override List<Regex> CreateMatchers() | ||
{ | ||
return new List<Regex> | ||
{ | ||
return new List<Regex> | ||
{ | ||
new Regex(@"^\s*(:exit|:quit|:x)\s*$", RegexOptions.IgnoreCase | RegexOptions.Singleline) | ||
}; | ||
} | ||
new(@"^\s*(:exit|:quit|:x)\s*$", RegexOptions.IgnoreCase | RegexOptions.Singleline) | ||
}; | ||
} | ||
|
||
protected override string[] ExtractParameters(Match match) | ||
{ | ||
return new string[0]; | ||
} | ||
protected override string[] ExtractParameters(Match match) | ||
{ | ||
return Array.Empty<string>(); | ||
} | ||
|
||
public override IEnumerable Execute(params object[] parameters) | ||
{ | ||
gameApplication.Close(); | ||
public override IEnumerable Execute(params object[] parameters) | ||
{ | ||
moduleHost.Close(); | ||
|
||
yield break; | ||
} | ||
yield break; | ||
} | ||
} |
71 changes: 43 additions & 28 deletions
71
sources/Dot.Application/GameHostActions/LoadGameAction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,62 @@ | ||
// Dot | ||
// Copyright (C) 2020-2024 Dust in the Wind | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Text.RegularExpressions; | ||
using DustInTheWind.Dot.AdventureGame.ActionModel; | ||
using DustInTheWind.Dot.Application.UseCases.LoadGame; | ||
|
||
namespace DustInTheWind.Dot.Application.GameHostActions | ||
namespace DustInTheWind.Dot.Application.GameHostActions; | ||
|
||
public class LoadGameAction : ActionBase | ||
{ | ||
public class LoadGameAction : ActionBase | ||
{ | ||
private readonly IUseCaseFactory useCaseFactory; | ||
private readonly IUseCaseFactory useCaseFactory; | ||
|
||
public LoadGameAction(IUseCaseFactory useCaseFactory) | ||
: base("load") | ||
{ | ||
this.useCaseFactory = useCaseFactory ?? throw new ArgumentNullException(nameof(useCaseFactory)); | ||
} | ||
public LoadGameAction(IUseCaseFactory useCaseFactory) | ||
: base("load") | ||
{ | ||
this.useCaseFactory = useCaseFactory ?? throw new ArgumentNullException(nameof(useCaseFactory)); | ||
} | ||
|
||
public override string Description => "Loads a previously saved game."; | ||
public override string Description => "Loads a previously saved game."; | ||
|
||
public override List<string> Usage => new List<string> { "<<:load>>" }; | ||
public override List<string> Usage => new() { "<<:load>>" }; | ||
|
||
public override ActionType ActionType => ActionType.EnvironmentCommand; | ||
public override ActionType ActionType => ActionType.EnvironmentCommand; | ||
|
||
protected override List<Regex> CreateMatchers() | ||
protected override List<Regex> CreateMatchers() | ||
{ | ||
return new List<Regex> | ||
{ | ||
return new List<Regex> | ||
{ | ||
new Regex(@"^\s*:load\s*$", RegexOptions.IgnoreCase | RegexOptions.Singleline) | ||
}; | ||
} | ||
new(@"^\s*:load\s*$", RegexOptions.IgnoreCase | RegexOptions.Singleline) | ||
}; | ||
} | ||
|
||
protected override string[] ExtractParameters(Match match) | ||
{ | ||
return new string[0]; | ||
} | ||
protected override string[] ExtractParameters(Match match) | ||
{ | ||
return Array.Empty<string>(); | ||
} | ||
|
||
public override IEnumerable Execute(params object[] parameters) | ||
{ | ||
LoadGameUseCase useCase = useCaseFactory.Create<LoadGameUseCase>(); | ||
useCase.Execute(); | ||
public override IEnumerable Execute(params object[] parameters) | ||
{ | ||
LoadGameUseCase useCase = useCaseFactory.Create<LoadGameUseCase>(); | ||
useCase.Execute(); | ||
|
||
yield break; | ||
} | ||
yield break; | ||
} | ||
} |
71 changes: 43 additions & 28 deletions
71
sources/Dot.Application/GameHostActions/MainMenuAction.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,61 @@ | ||
// Dot | ||
// Copyright (C) 2020-2024 Dust in the Wind | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Text.RegularExpressions; | ||
using Dot.GameHosting; | ||
using DustInTheWind.Dot.AdventureGame.ActionModel; | ||
using DustInTheWind.Dot.Domain.ModuleModel; | ||
|
||
namespace DustInTheWind.Dot.Application.GameHostActions | ||
namespace DustInTheWind.Dot.Application.GameHostActions; | ||
|
||
public class MainMenuAction : ActionBase | ||
{ | ||
public class MainMenuAction : ActionBase | ||
{ | ||
private readonly ModuleEngine moduleEngine; | ||
private readonly ModuleEngine moduleEngine; | ||
|
||
public MainMenuAction(ModuleEngine moduleEngine) | ||
: base("menu", "m") | ||
{ | ||
this.moduleEngine = moduleEngine ?? throw new ArgumentNullException(nameof(moduleEngine)); | ||
} | ||
public MainMenuAction(ModuleEngine moduleEngine) | ||
: base("menu", "m") | ||
{ | ||
this.moduleEngine = moduleEngine ?? throw new ArgumentNullException(nameof(moduleEngine)); | ||
} | ||
|
||
public override string Description => "Displays the main menu of the game."; | ||
public override string Description => "Displays the main menu of the game."; | ||
|
||
public override List<string> Usage => new List<string> { "<<:menu>>", "<<:m>>" }; | ||
public override List<string> Usage => new() { "<<:menu>>", "<<:m>>" }; | ||
|
||
public override ActionType ActionType => ActionType.EnvironmentCommand; | ||
public override ActionType ActionType => ActionType.EnvironmentCommand; | ||
|
||
protected override List<Regex> CreateMatchers() | ||
protected override List<Regex> CreateMatchers() | ||
{ | ||
return new List<Regex> | ||
{ | ||
return new List<Regex> | ||
{ | ||
new Regex(@"^\s*(:menu|:m)\s*$", RegexOptions.IgnoreCase | RegexOptions.Singleline) | ||
}; | ||
} | ||
new(@"^\s*(:menu|:m)\s*$", RegexOptions.IgnoreCase | RegexOptions.Singleline) | ||
}; | ||
} | ||
|
||
protected override string[] ExtractParameters(Match match) | ||
{ | ||
return new string[0]; | ||
} | ||
protected override string[] ExtractParameters(Match match) | ||
{ | ||
return Array.Empty<string>(); | ||
} | ||
|
||
public override IEnumerable Execute(params object[] parameters) | ||
{ | ||
moduleEngine.RequestToChangeModule("main-menu"); | ||
public override IEnumerable Execute(params object[] parameters) | ||
{ | ||
moduleEngine.RequestToChangeModule("main-menu"); | ||
|
||
yield break; | ||
} | ||
yield break; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,62 @@ | ||
// Dot | ||
// Copyright (C) 2020-2024 Dust in the Wind | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Text.RegularExpressions; | ||
using DustInTheWind.Dot.AdventureGame.ActionModel; | ||
using DustInTheWind.Dot.Application.UseCases.NewGame; | ||
|
||
namespace DustInTheWind.Dot.Application.GameHostActions | ||
namespace DustInTheWind.Dot.Application.GameHostActions; | ||
|
||
public class NewGameAction : ActionBase | ||
{ | ||
public class NewGameAction : ActionBase | ||
{ | ||
private readonly IUseCaseFactory useCaseFactory; | ||
private readonly IUseCaseFactory useCaseFactory; | ||
|
||
public NewGameAction(IUseCaseFactory useCaseFactory) | ||
: base("new") | ||
{ | ||
this.useCaseFactory = useCaseFactory ?? throw new ArgumentNullException(nameof(useCaseFactory)); | ||
} | ||
public NewGameAction(IUseCaseFactory useCaseFactory) | ||
: base("new") | ||
{ | ||
this.useCaseFactory = useCaseFactory ?? throw new ArgumentNullException(nameof(useCaseFactory)); | ||
} | ||
|
||
public override string Description => "Starts a new game."; | ||
public override string Description => "Starts a new game."; | ||
|
||
public override List<string> Usage => new List<string> { "<<:new>>" }; | ||
public override List<string> Usage => new() { "<<:new>>" }; | ||
|
||
public override ActionType ActionType => ActionType.EnvironmentCommand; | ||
public override ActionType ActionType => ActionType.EnvironmentCommand; | ||
|
||
protected override List<Regex> CreateMatchers() | ||
protected override List<Regex> CreateMatchers() | ||
{ | ||
return new List<Regex> | ||
{ | ||
return new List<Regex> | ||
{ | ||
new Regex(@"^\s*:new\s*$", RegexOptions.IgnoreCase | RegexOptions.Singleline) | ||
}; | ||
} | ||
new(@"^\s*:new\s*$", RegexOptions.IgnoreCase | RegexOptions.Singleline) | ||
}; | ||
} | ||
|
||
protected override string[] ExtractParameters(Match match) | ||
{ | ||
return new string[0]; | ||
} | ||
protected override string[] ExtractParameters(Match match) | ||
{ | ||
return Array.Empty<string>(); | ||
} | ||
|
||
public override IEnumerable Execute(params object[] parameters) | ||
{ | ||
CreateNewGameUseCase useCase = useCaseFactory.Create<CreateNewGameUseCase>(); | ||
useCase.Execute(); | ||
public override IEnumerable Execute(params object[] parameters) | ||
{ | ||
CreateNewGameUseCase useCase = useCaseFactory.Create<CreateNewGameUseCase>(); | ||
useCase.Execute(); | ||
|
||
yield break; | ||
} | ||
yield break; | ||
} | ||
} |
Oops, something went wrong.