L'ajout aux chemins de cordes est pas bon, donc le calcul final n'est pas bon🎅
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is failing Details

pull/87/head
Remi NEVEU 11 months ago
parent b58f363881
commit 25ae73f4b5

@ -55,6 +55,7 @@ class Program
static void OnGameEnded(object sender, GameEndedEventArgs e) static void OnGameEnded(object sender, GameEndedEventArgs e)
{ {
Console.WriteLine($"The game has ended! Player: {e.CurrentPlayer.Pseudo}"); Console.WriteLine($"The game has ended! Player: {e.CurrentPlayer.Pseudo}");
Console.WriteLine($"Points: {e.Point}");
} }
/// <summary> /// <summary>

@ -9,9 +9,12 @@ namespace Models.Events
{ {
public Player CurrentPlayer { get; } public Player CurrentPlayer { get; }
public GameEndedEventArgs(Player winner) public int? Point { get; }
public GameEndedEventArgs(Player winner, int? point)
{ {
CurrentPlayer = winner; CurrentPlayer = winner;
Point = point;
} }
} }
} }

@ -189,10 +189,10 @@ namespace Models.Game
/// <summary> /// <summary>
/// Ends the game. /// Ends the game.
/// </summary> /// </summary>
private void EndGame() private void EndGame(int? pts)
{ {
_isRunning = false; _isRunning = false;
GameEnded?.Invoke(this, new GameEndedEventArgs(CurrentPlayer)); GameEnded?.Invoke(this, new GameEndedEventArgs(CurrentPlayer, pts));
} }
/// <summary> /// <summary>
@ -204,7 +204,17 @@ namespace Models.Game
{ {
if (Turn == 20) if (Turn == 20)
{ {
EndGame(); foreach(var cells in UsedMap.Boards)
{
GameRules.IsZoneValidAndAddToZones(cells, UsedMap);
AddToRopePath(cells, GameRules.EveryAdjacentCells(cells, UsedMap.Boards));
}
int? points = GameRules.FinalCalculusOfZones(UsedMap.Zones);
for (int i = 0; i < UsedMap.RopePaths.Count; i++)
{
points += GameRules.ScoreRopePaths(UsedMap.RopePaths[i]);
}
EndGame(points);
break; break;
} }

@ -236,5 +236,22 @@ namespace Models.Rules
return calculus; return calculus;
} }
public int? ScoreRopePaths(List<Cell> paths)
{
int? score = 0;
IEnumerable<Cell> sortPaths =
from cell in paths
orderby cell.Value descending
select cell;
foreach (var item in sortPaths)
{
if (score == 0)
score += item.Value;
else
score++;
}
return score;
}
} }
} }
Loading…
Cancel
Save