ajout des chef et shaman a la creation du match #28

Merged
mcmuzzle merged 1 commits from 22_gestionWorkers into main 2025-04-24 21:29:55 +00:00
3 changed files with 23 additions and 5 deletions

View File

@@ -51,6 +51,10 @@ public class PrepareMatchCommand : BaseMatchCommand<PrepareMatchResult>
} }
i++; 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() return new PrepareMatchResult()
{ {

View File

@@ -37,25 +37,33 @@ public class Player
#endregion Collections #endregion Collections
#region Generics #region Generics
public PiecePosition HiddenPosition => PlayerHiddenAreas[Index];
public PiecePosition VisiblePosition => PlayerVisibileAreas[Index];
public void PutPieceInVisibleArea(PieceIndex piece) public void PutPieceInVisibleArea(PieceIndex piece)
{ {
_match.AssignPiece(piece, PlayerVisibileAreas[Index]); _match.AssignPiece(piece, VisiblePosition);
} }
public void PutPieceInHiddenArea(PieceIndex piece) public void PutPieceInHiddenArea(PieceIndex piece)
{ {
_match.AssignPiece(piece, PlayerHiddenAreas[Index]); _match.AssignPiece(piece, HiddenPosition);
} }
#endregion #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 #region socles
public ICollection<PieceIndex> Bases => PlayerPieces[Index]?.Where(p => p.ToString().Contains("Base")).ToList() ?? []; public ICollection<PieceIndex> 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 #endregion
#region Tribal markers #region Tribal markers
public ICollection<PieceIndex> Markers => PlayerPieces[Index]?.Where(p => p.ToString().Contains("TribalMarker")).ToList() ?? []; public ICollection<PieceIndex> Markers => PlayerPieces[Index]?.Where(p => p.ToString().Contains("TribalMarker")).ToList() ?? [];
public int NbVisibleTribalTokenCount => Markers.Count(p => _match.GetPiece(p) == PlayerVisibileAreas[Index]); public int NbVisibleTribalTokenCount => Markers.Count(p => _match.GetPiece(p) == VisiblePosition);
public int NbHiddenTribalTokenCount => Markers.Count(p => _match.GetPiece(p) == PlayerHiddenAreas[Index]); public int NbHiddenTribalTokenCount => Markers.Count(p => _match.GetPiece(p) == HiddenPosition);
public int NbUrnTribalTokenCount => Markers.Count(p => _match.GetPiece(p) == PiecePosition.Urne); public int NbUrnTribalTokenCount => Markers.Count(p => _match.GetPiece(p) == PiecePosition.Urne);
#endregion #endregion
} }

View File

@@ -38,6 +38,8 @@ public class PrepareMatchCommandTest
Assert.Equal(0, p.NbHiddenTribalTokenCount); Assert.Equal(0, p.NbHiddenTribalTokenCount);
Assert.Equal(4, p.NbUrnTribalTokenCount); Assert.Equal(4, p.NbUrnTribalTokenCount);
Assert.Equal(5, p.NbVisibleBase); 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(0, p.NbHiddenTribalTokenCount);
Assert.Equal(4, p.NbUrnTribalTokenCount); Assert.Equal(4, p.NbUrnTribalTokenCount);
Assert.Equal(6, p.NbVisibleBase); 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(0, p.NbHiddenTribalTokenCount);
Assert.Equal(4, p.NbUrnTribalTokenCount); Assert.Equal(4, p.NbUrnTribalTokenCount);
Assert.Equal(7, p.NbVisibleBase); Assert.Equal(7, p.NbVisibleBase);
Assert.Equal(p.VisiblePosition, resultPrep.Match.GetPiece(p.Chef));
Assert.Equal(p.VisiblePosition, resultPrep.Match.GetPiece(p.Shaman));
} }
} }
} }