Mise en place des MatchCommand
All checks were successful
check main state / build (9.0.x) (push) Successful in 1m28s
All checks were successful
check main state / build (9.0.x) (push) Successful in 1m28s
Ajout des données dynamiques au match
This commit was merged in pull request #21.
This commit is contained in:
13
Src/Giants.Core/Src/Commands/BaseMatchCommand.cs
Normal file
13
Src/Giants.Core/Src/Commands/BaseMatchCommand.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace Giants.Core.Commands;
|
||||
|
||||
public abstract class BaseMatchCommand<T> : BaseCommand<T> where T : BaseCommandResult
|
||||
{
|
||||
public required Match InputMatch { get; init; }
|
||||
|
||||
protected abstract T LocalMatchExecute(Match match);
|
||||
|
||||
protected override T LocalExecute()
|
||||
{
|
||||
return LocalMatchExecute(InputMatch.Clone());
|
||||
}
|
||||
}
|
||||
41
Src/Giants.Core/Src/Commands/PrepareMatchCommand.cs
Normal file
41
Src/Giants.Core/Src/Commands/PrepareMatchCommand.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System.Security.Claims;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
|
||||
namespace Giants.Core.Commands;
|
||||
|
||||
public class PrepareMatchCommand : BaseMatchCommand<PrepareMatchResult>
|
||||
{
|
||||
public required int NbPlayer { get; init; }
|
||||
|
||||
protected override PrepareMatchResult LocalMatchExecute(Match match)
|
||||
{
|
||||
if (NbPlayer < 3 || NbPlayer > 5)
|
||||
return new PrepareMatchResult();
|
||||
|
||||
|
||||
//Gestion des assets des joueurs
|
||||
for (int i = 0; i < NbPlayer; i++)
|
||||
{
|
||||
//marqueurs tribaux
|
||||
int nbMarker = NbMarkerPerPlayer(NbPlayer);
|
||||
for (int t = 0; t < nbMarker; t++)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
return new PrepareMatchResult();
|
||||
}
|
||||
|
||||
private int NbMarkerPerPlayer(int nbTotalPlayer)
|
||||
{
|
||||
return nbTotalPlayer switch
|
||||
{
|
||||
3 => 7,
|
||||
4 => 6,
|
||||
5 => 5,
|
||||
_ => throw new Exception("Wrong player count for NbMarkerPerPlayer")
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class PrepareMatchResult : BaseCommandResult { }
|
||||
Reference in New Issue
Block a user