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

This commit was merged in pull request #29.
This commit is contained in:
2025-04-24 22:31:19 +02:00
parent c1c5f6bab8
commit 3dba66344d
11 changed files with 163 additions and 32 deletions

View File

@@ -1,5 +1,6 @@
using Giants.Application;
using Giants.Core.Commands;
using Giants.Core.Enums;
using Giants.Core.Interfaces;
using Giants.Infrastructure;
@@ -19,12 +20,13 @@ public class PrepareMatchCommandTest
[Fact]
void SimpleInit5Players()
{
NewMatchCommand command = new NewMatchCommand(_repo);
Random random = new Random(1);
NewMatchCommand command = new NewMatchCommand(_repo) { Random = random };
NewMatchResult result = command.Execute();
Match? m = result.Match;
Assert.NotNull(m);
PrepareMatchCommand prepCommand = new PrepareMatchCommand() { InputMatch = m, PlayerIDs = new List<int>() { 12, 15, 5, 14, 9 } };
PrepareMatchCommand prepCommand = new PrepareMatchCommand() { InputMatch = m, PlayerIDs = new List<int>() { 12, 15, 5, 14, 9 }, Random = random };
var resultPrep = prepCommand.Execute();
Assert.True(resultPrep.Success);
Assert.NotNull(resultPrep?.Match);
@@ -34,24 +36,29 @@ public class PrepareMatchCommandTest
Player? p = resultPrep.Match.GetPlayer(i);
Assert.NotNull(p);
Assert.Equal(2, p.NbVisibleTribalTokenCount);
Assert.Equal(0, p.NbHiddenTribalTokenCount);
Assert.Equal(0, p.NbVisibleTribalTokenCount);
Assert.Equal(2, 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));
Assert.Equal(5, p.NbHiddenBase);
Assert.Equal(p.HiddenPosition, resultPrep.Match.GetPiece(p.Chef));
Assert.Equal(p.HiddenPosition, resultPrep.Match.GetPiece(p.Shaman));
Assert.Equal(1, p.Workers.Count(w => resultPrep.Match.GetPiece(w) == p.HiddenPosition));
Assert.Equal(5, p.Workers.Count(w => resultPrep.Match.GetPiece(w) == Enums.PiecePosition.Urne));
Assert.Equal(0, p.Score);
Assert.NotEqual(PiecePosition.boite, resultPrep.Match.GetPiece(PieceIndex.StartPlayer));
}
}
[Fact]
void SimpleInit4Players()
{
NewMatchCommand command = new NewMatchCommand(_repo);
Random random = new Random(1);
NewMatchCommand command = new NewMatchCommand(_repo) { Random = random };
NewMatchResult result = command.Execute();
Match? m = result.Match;
Assert.NotNull(m);
PrepareMatchCommand prepCommand = new PrepareMatchCommand() { InputMatch = m, PlayerIDs = new List<int>() { 12, 15, 5, 14 } };
PrepareMatchCommand prepCommand = new PrepareMatchCommand() { InputMatch = m, PlayerIDs = new List<int>() { 12, 15, 5, 14 }, Random = random };
var resultPrep = prepCommand.Execute();
Assert.True(resultPrep.Success);
Assert.NotNull(resultPrep?.Match);
@@ -61,24 +68,29 @@ public class PrepareMatchCommandTest
Player? p = resultPrep.Match.GetPlayer(i);
Assert.NotNull(p);
Assert.Equal(2, p.NbVisibleTribalTokenCount);
Assert.Equal(0, p.NbHiddenTribalTokenCount);
Assert.Equal(0, p.NbVisibleTribalTokenCount);
Assert.Equal(2, 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));
Assert.Equal(6, p.NbHiddenBase);
Assert.Equal(p.HiddenPosition, resultPrep.Match.GetPiece(p.Chef));
Assert.Equal(p.HiddenPosition, resultPrep.Match.GetPiece(p.Shaman));
Assert.Equal(1, p.Workers.Count(w => resultPrep.Match.GetPiece(w) == p.HiddenPosition));
Assert.Equal(5, p.Workers.Count(w => resultPrep.Match.GetPiece(w) == Enums.PiecePosition.Urne));
Assert.Equal(0, p.Score);
Assert.NotEqual(PiecePosition.boite, resultPrep.Match.GetPiece(PieceIndex.StartPlayer));
}
}
[Fact]
void SimpleInit3Players()
{
NewMatchCommand command = new NewMatchCommand(_repo);
Random random = new Random(1);
NewMatchCommand command = new NewMatchCommand(_repo) { Random = random };
NewMatchResult result = command.Execute();
Match? m = result.Match;
Assert.NotNull(m);
PrepareMatchCommand prepCommand = new PrepareMatchCommand() { InputMatch = m, PlayerIDs = new List<int>() { 12, 15, 5 } };
PrepareMatchCommand prepCommand = new PrepareMatchCommand() { InputMatch = m, PlayerIDs = new List<int>() { 12, 15, 5 }, Random = random };
var resultPrep = prepCommand.Execute();
Assert.True(resultPrep.Success);
Assert.NotNull(resultPrep?.Match);
@@ -88,12 +100,16 @@ public class PrepareMatchCommandTest
Player? p = resultPrep.Match.GetPlayer(i);
Assert.NotNull(p);
Assert.Equal(2, p.NbVisibleTribalTokenCount);
Assert.Equal(0, p.NbHiddenTribalTokenCount);
Assert.Equal(0, p.NbVisibleTribalTokenCount);
Assert.Equal(2, 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));
Assert.Equal(7, p.NbHiddenBase);
Assert.Equal(p.HiddenPosition, resultPrep.Match.GetPiece(p.Chef));
Assert.Equal(p.HiddenPosition, resultPrep.Match.GetPiece(p.Shaman));
Assert.Equal(1, p.Workers.Count(w => resultPrep.Match.GetPiece(w) == p.HiddenPosition));
Assert.Equal(5, p.Workers.Count(w => resultPrep.Match.GetPiece(w) == Enums.PiecePosition.Urne));
Assert.Equal(0, p.Score);
Assert.NotEqual(PiecePosition.boite, resultPrep.Match.GetPiece(PieceIndex.StartPlayer));
}
}
}