From c1c5f6bab8a77cc5698ee7cc69fa8420cdef3b88 Mon Sep 17 00:00:00 2001 From: mcmuzzle Date: Thu, 24 Apr 2025 09:20:26 +0200 Subject: [PATCH] ajout des chef et shaman a la creation du match --- .../Src/Commands/PrepareMatchCommand.cs | 4 ++++ Src/Giants.Core/Src/Entities/Player.cs | 18 +++++++++++++----- .../Commands/PrepareMatchCommandTest.cs | 6 ++++++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Src/Giants.Core/Src/Commands/PrepareMatchCommand.cs b/Src/Giants.Core/Src/Commands/PrepareMatchCommand.cs index 968c21d..20bd115 100644 --- a/Src/Giants.Core/Src/Commands/PrepareMatchCommand.cs +++ b/Src/Giants.Core/Src/Commands/PrepareMatchCommand.cs @@ -51,6 +51,10 @@ public class PrepareMatchCommand : BaseMatchCommand } i++; } + + //assigner les ouvriers (1 chef, 1 shaman et 1 worker chacun) + match.AssignPiece(player.Chef, player.VisiblePosition); + match.AssignPiece(player.Shaman, player.VisiblePosition); } return new PrepareMatchResult() { diff --git a/Src/Giants.Core/Src/Entities/Player.cs b/Src/Giants.Core/Src/Entities/Player.cs index 4515bdf..29b0103 100644 --- a/Src/Giants.Core/Src/Entities/Player.cs +++ b/Src/Giants.Core/Src/Entities/Player.cs @@ -37,25 +37,33 @@ public class Player #endregion Collections #region Generics + public PiecePosition HiddenPosition => PlayerHiddenAreas[Index]; + public PiecePosition VisiblePosition => PlayerVisibileAreas[Index]; + public void PutPieceInVisibleArea(PieceIndex piece) { - _match.AssignPiece(piece, PlayerVisibileAreas[Index]); + _match.AssignPiece(piece, VisiblePosition); } public void PutPieceInHiddenArea(PieceIndex piece) { - _match.AssignPiece(piece, PlayerHiddenAreas[Index]); + _match.AssignPiece(piece, HiddenPosition); } #endregion + #region workers + public PieceIndex Chef => PlayerPieces[Index].Where(p => p.ToString().Contains("Chief")).FirstOrDefault(); + public PieceIndex Shaman => PlayerPieces[Index].Where(p => p.ToString().Contains("Shaman")).FirstOrDefault(); + #endregion + #region socles public ICollection Bases => PlayerPieces[Index]?.Where(p => p.ToString().Contains("Base")).ToList() ?? []; - public int NbVisibleBase => Bases.Count(p => _match.GetPiece(p) == PlayerVisibileAreas[Index]); + public int NbVisibleBase => Bases.Count(p => _match.GetPiece(p) == VisiblePosition); #endregion #region Tribal markers public ICollection Markers => PlayerPieces[Index]?.Where(p => p.ToString().Contains("TribalMarker")).ToList() ?? []; - public int NbVisibleTribalTokenCount => Markers.Count(p => _match.GetPiece(p) == PlayerVisibileAreas[Index]); - public int NbHiddenTribalTokenCount => Markers.Count(p => _match.GetPiece(p) == PlayerHiddenAreas[Index]); + public int NbVisibleTribalTokenCount => Markers.Count(p => _match.GetPiece(p) == VisiblePosition); + public int NbHiddenTribalTokenCount => Markers.Count(p => _match.GetPiece(p) == HiddenPosition); public int NbUrnTribalTokenCount => Markers.Count(p => _match.GetPiece(p) == PiecePosition.Urne); #endregion } \ No newline at end of file diff --git a/Tests/Giants.Core.Tests/Commands/PrepareMatchCommandTest.cs b/Tests/Giants.Core.Tests/Commands/PrepareMatchCommandTest.cs index 11f34fe..80d20d6 100644 --- a/Tests/Giants.Core.Tests/Commands/PrepareMatchCommandTest.cs +++ b/Tests/Giants.Core.Tests/Commands/PrepareMatchCommandTest.cs @@ -38,6 +38,8 @@ public class PrepareMatchCommandTest Assert.Equal(0, p.NbHiddenTribalTokenCount); Assert.Equal(4, p.NbUrnTribalTokenCount); Assert.Equal(5, p.NbVisibleBase); + Assert.Equal(p.VisiblePosition, resultPrep.Match.GetPiece(p.Chef)); + Assert.Equal(p.VisiblePosition, resultPrep.Match.GetPiece(p.Shaman)); } } @@ -63,6 +65,8 @@ public class PrepareMatchCommandTest Assert.Equal(0, p.NbHiddenTribalTokenCount); Assert.Equal(4, p.NbUrnTribalTokenCount); Assert.Equal(6, p.NbVisibleBase); + Assert.Equal(p.VisiblePosition, resultPrep.Match.GetPiece(p.Chef)); + Assert.Equal(p.VisiblePosition, resultPrep.Match.GetPiece(p.Shaman)); } } @@ -88,6 +92,8 @@ public class PrepareMatchCommandTest Assert.Equal(0, p.NbHiddenTribalTokenCount); Assert.Equal(4, p.NbUrnTribalTokenCount); Assert.Equal(7, p.NbVisibleBase); + Assert.Equal(p.VisiblePosition, resultPrep.Match.GetPiece(p.Chef)); + Assert.Equal(p.VisiblePosition, resultPrep.Match.GetPiece(p.Shaman)); } } } \ No newline at end of file