fin de l'initialisation d'un match et ajout du random aux commandes
All checks were successful
check main state / build (9.0.x) (push) Successful in 2m46s
All checks were successful
check main state / build (9.0.x) (push) Successful in 2m46s
This commit was merged in pull request #29.
This commit is contained in:
@@ -8,6 +8,9 @@ public abstract class BaseCommand<T> where T : BaseCommandResult
|
||||
{
|
||||
protected abstract T LocalExecute();
|
||||
|
||||
public required Random Random { get; init; }
|
||||
|
||||
|
||||
/// <summary> Executer la commande, si nécessaire il faut avoir rempli les parametres en amont </summary>
|
||||
public T Execute()
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@ public class PrepareMatchCommand : BaseMatchCommand<PrepareMatchResult>
|
||||
{
|
||||
if (nbSocle > 0)
|
||||
{
|
||||
player.PutPieceInVisibleArea(socle);
|
||||
player.PutPieceInHiddenArea(socle);
|
||||
nbSocle--;
|
||||
}
|
||||
else
|
||||
@@ -43,7 +43,7 @@ public class PrepareMatchCommand : BaseMatchCommand<PrepareMatchResult>
|
||||
{
|
||||
if (i < 2)
|
||||
{
|
||||
player.PutPieceInVisibleArea(marker);
|
||||
player.PutPieceInHiddenArea(marker);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -53,8 +53,37 @@ public class PrepareMatchCommand : BaseMatchCommand<PrepareMatchResult>
|
||||
}
|
||||
|
||||
//assigner les ouvriers (1 chef, 1 shaman et 1 worker chacun)
|
||||
match.AssignPiece(player.Chef, player.VisiblePosition);
|
||||
match.AssignPiece(player.Shaman, player.VisiblePosition);
|
||||
match.AssignPiece(player.Chef, player.HiddenPosition);
|
||||
match.AssignPiece(player.Shaman, player.HiddenPosition);
|
||||
int nbWorker = 1;
|
||||
foreach (PieceIndex worker in player.Workers)
|
||||
{
|
||||
if (nbWorker > 0)
|
||||
{
|
||||
match.AssignPiece(worker, player.HiddenPosition);
|
||||
nbWorker--;
|
||||
}
|
||||
else
|
||||
{
|
||||
match.AssignPiece(worker, PiecePosition.Urne);
|
||||
}
|
||||
}
|
||||
match.AssignPiece(player.Workers.First(), player.HiddenPosition);
|
||||
|
||||
//score a zero
|
||||
for (int iteScore = 0; iteScore < match.NbPlayer; iteScore++)
|
||||
{
|
||||
match.SetScore(iteScore, 0);
|
||||
}
|
||||
|
||||
//choix d'un 1er joueur
|
||||
|
||||
Player? firstPlayer = match.GetPlayer(Random.Next(match.NbPlayer));
|
||||
if (null == firstPlayer)
|
||||
throw new InitialisationException("Cannot select first player, indexOutOfRange");
|
||||
match.AssignPiece(PieceIndex.StartPlayer, firstPlayer.VisiblePosition);
|
||||
|
||||
|
||||
}
|
||||
return new PrepareMatchResult()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user