From f400674c1acac84bf9ee030ac34bc6b087ef0327 Mon Sep 17 00:00:00 2001 From: mcmuzzle Date: Wed, 12 Mar 2025 15:57:21 +0100 Subject: [PATCH] Format code et ajout de l'interface repository --- .editorconfig | 10 ++++++ .../Src/GiantApplication.cs | 6 +--- .../Src/MatchRepositoryMock.cs | 31 +++++++++++++++++++ Src/Giants.Core/Src/Entities/Match.cs | 19 +++++++++++- .../Src/Interfaces/IHexagonalGrid.cs | 2 +- .../Src/Interfaces/IMatchRepository.cs | 14 +++++++++ .../Src/ValuesObjects/BoardLayout.cs | 2 +- .../HexagonalLib.Net/HexagonalLib.Net.csproj | 2 +- Tests/Giants.Core.Tests/ApplicationTests.cs | 2 +- 9 files changed, 78 insertions(+), 10 deletions(-) create mode 100644 .editorconfig create mode 100644 Src/Giants.Application/Src/MatchRepositoryMock.cs create mode 100644 Src/Giants.Core/Src/Interfaces/IMatchRepository.cs diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..0b8efc7 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +# top-most EditorConfig file +root = true + +[*.cs] +indent_style = space +indent_size = 4 +charset = utf-8 + +[Src/HexagonalLib/**] +generated_code = true \ No newline at end of file diff --git a/Src/Giants.Application/Src/GiantApplication.cs b/Src/Giants.Application/Src/GiantApplication.cs index 21bb61b..3af37f0 100644 --- a/Src/Giants.Application/Src/GiantApplication.cs +++ b/Src/Giants.Application/Src/GiantApplication.cs @@ -1,18 +1,14 @@ namespace Giants.Application; -using Giants.Core.Interfaces; -using Giants.Infrastructure; - /// /// Une application Giants permettant l'instanciations des services, utilisé pour une console /// ou autre archi sans injections de dependances -/// /// +/// public class GiantApplication { /// Constructeur de base public GiantApplication() { - IHexagonalGrid grid = new HexagonalGridImpl(); } } \ No newline at end of file diff --git a/Src/Giants.Application/Src/MatchRepositoryMock.cs b/Src/Giants.Application/Src/MatchRepositoryMock.cs new file mode 100644 index 0000000..461a1a1 --- /dev/null +++ b/Src/Giants.Application/Src/MatchRepositoryMock.cs @@ -0,0 +1,31 @@ +using Giants.Core.Interfaces; +using Giants.Core; +using Giants.Infrastructure; + +namespace Giants.Application; + +/// +/// Implementation temporaire du repository de match +/// +public class MatchRepositoryMock : IMatchRepository +{ + private readonly IHexagonalGrid _gridLayout; + + /// + /// constructeur + /// + public MatchRepositoryMock() + { + _gridLayout = new HexagonalGridImpl(); + } + + /// + public Match? GetMatch(int matchId) + { + Match result = new Match(_gridLayout); + + // Ajout des données statiques + return result; + } + +} \ No newline at end of file diff --git a/Src/Giants.Core/Src/Entities/Match.cs b/Src/Giants.Core/Src/Entities/Match.cs index 308797c..e95bd53 100644 --- a/Src/Giants.Core/Src/Entities/Match.cs +++ b/Src/Giants.Core/Src/Entities/Match.cs @@ -1,10 +1,13 @@ +using System.Security.Cryptography.X509Certificates; using Giants.Core.Interfaces; namespace Giants.Core; /// /// Il s'agit d'une instance d'une partie de Giants, c'est la racine de toutes les entitées de l'instance -/// /// +/// l'objectif de cette classe est de pouvoir etre copiée tres rapidement avec la plus petite utilisation mémoire +/// Il faut également que la comparaison soit rapide et intelligente pour les besoins de l'IA +/// public class Match { #region données statiques @@ -20,4 +23,18 @@ public class Match { _grid = grid; } + + /// Permet de comparer des Match, cette methode est critique pour l'ia pour reduire son parcour d'arbre + /// + /// + public override bool Equals(object? obj) + { + return base.Equals(obj); + } + + /// + public override int GetHashCode() + { + return base.GetHashCode(); + } } \ No newline at end of file diff --git a/Src/Giants.Core/Src/Interfaces/IHexagonalGrid.cs b/Src/Giants.Core/Src/Interfaces/IHexagonalGrid.cs index 037403c..d362ddb 100644 --- a/Src/Giants.Core/Src/Interfaces/IHexagonalGrid.cs +++ b/Src/Giants.Core/Src/Interfaces/IHexagonalGrid.cs @@ -5,5 +5,5 @@ namespace Giants.Core.Interfaces; /// public interface IHexagonalGrid { - + } \ No newline at end of file diff --git a/Src/Giants.Core/Src/Interfaces/IMatchRepository.cs b/Src/Giants.Core/Src/Interfaces/IMatchRepository.cs new file mode 100644 index 0000000..0f548e2 --- /dev/null +++ b/Src/Giants.Core/Src/Interfaces/IMatchRepository.cs @@ -0,0 +1,14 @@ +namespace Giants.Core.Interfaces; + +/// +/// Interface de tout fournisseur de match, ils sont responsable d'instancier les match a partir d'un ID ou d'en créer des nouveaux +/// +public interface IMatchRepository +{ + /// + /// Récupérer un match a patir de son ID, + /// + /// L'id unique du match a récupérer + /// le match s'il existe ou null dans le cas contraire + Match? GetMatch(int matchId); +} \ No newline at end of file diff --git a/Src/Giants.Core/Src/ValuesObjects/BoardLayout.cs b/Src/Giants.Core/Src/ValuesObjects/BoardLayout.cs index b8960bd..0ec0373 100644 --- a/Src/Giants.Core/Src/ValuesObjects/BoardLayout.cs +++ b/Src/Giants.Core/Src/ValuesObjects/BoardLayout.cs @@ -1,4 +1,4 @@ -namespace Giants.Core; +namespace Giants.Core; /// /// Represente l'organisation d'un plateau, il ne contient aucune informations liées a une partie mais il permet diff --git a/Src/HexagonalLib/src/HexagonalLib.Net/HexagonalLib.Net/HexagonalLib.Net.csproj b/Src/HexagonalLib/src/HexagonalLib.Net/HexagonalLib.Net/HexagonalLib.Net.csproj index 400ca8b..c9f3dfe 100644 --- a/Src/HexagonalLib/src/HexagonalLib.Net/HexagonalLib.Net/HexagonalLib.Net.csproj +++ b/Src/HexagonalLib/src/HexagonalLib.Net/HexagonalLib.Net/HexagonalLib.Net.csproj @@ -2,7 +2,7 @@ HexagonalLib - net472;net48;netcoreapp3.1 + net8.0 true HexagonalLib Ivan Murashka diff --git a/Tests/Giants.Core.Tests/ApplicationTests.cs b/Tests/Giants.Core.Tests/ApplicationTests.cs index 3c97a2e..344445a 100644 --- a/Tests/Giants.Core.Tests/ApplicationTests.cs +++ b/Tests/Giants.Core.Tests/ApplicationTests.cs @@ -1,4 +1,4 @@ -namespace Giants.Core.Tests; +namespace Giants.Core.Tests; using Giants.Application; -- 2.49.1