From e303b97a397c57b36e3b6e886ea86453035a0869 Mon Sep 17 00:00:00 2001 From: Lucas DUFLOT Date: Fri, 17 May 2024 18:11:14 +0200 Subject: [PATCH] correction des erreurs --- source/Trek-12/Models/Game/Cell.cs | 4 ++-- source/Trek-12/Models/Game/Game.cs | 18 +++++++++--------- source/Trek-12/Models/Game/OperationCell.cs | 6 +++++- source/Trek-12/Models/Game/Position.cs | 2 +- source/Trek-12/Models/Models.csproj | 1 + source/Trek-12/Models/Rules/Rules.cs | 11 ++++++----- 6 files changed, 24 insertions(+), 18 deletions(-) diff --git a/source/Trek-12/Models/Game/Cell.cs b/source/Trek-12/Models/Game/Cell.cs index 0b63cfa..3628445 100644 --- a/source/Trek-12/Models/Game/Cell.cs +++ b/source/Trek-12/Models/Game/Cell.cs @@ -1,6 +1,6 @@ namespace Models; -public class Cell +public class Cell : Position { private int? _value; public int? Value { @@ -19,7 +19,7 @@ public class Cell private bool Penalty { get; set; } - public Cell(bool isDangerous = false) + public Cell(int x, int y,bool isDangerous = false):base(x,y) { IsDangerous = isDangerous; Penalty = false; diff --git a/source/Trek-12/Models/Game/Game.cs b/source/Trek-12/Models/Game/Game.cs index 61e4687..b154e77 100644 --- a/source/Trek-12/Models/Game/Game.cs +++ b/source/Trek-12/Models/Game/Game.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Models.Events; +using Models.Rules; namespace Models.Game { @@ -18,13 +19,13 @@ namespace Models.Game private int Turn { get; set; } - private IRules GameRules { get; } + private Rules.Rules GameRules { get; } // == Events == public event GameStartedEventArgs OnGameStarted; - public event GameStartedEventArgs GameStarted; public Game(Player player, Map map) + public Game(Player player, Map map) { UsedMap = map; CurrentPlayer = player; @@ -32,7 +33,6 @@ namespace Models.Game Dice2 = new Dice(1); Turn = 0; GameRules = new Rules.Rules(); - ropePaths = new HashSet(); } public void RollAllDice() @@ -46,19 +46,19 @@ namespace Models.Game switch (o) { case Operation.LOWER: - return Dice1.IsLower(Dice2) ? Dice1.Nb : Dice2.Nb; + return Dice1.IsLower(Dice2) ? Dice1.Value : Dice2.Value; case Operation.HIGHER: - return Dice1.IsLower(Dice2) ? Dice2.Nb : Dice1.Nb; + return Dice1.IsLower(Dice2) ? Dice2.Value : Dice1.Value; case Operation.SUBTRACTION: - return Dice1.IsLower(Dice2) ? Dice2.Nb - Dice1.Nb : Dice1.Nb - Dice2.Nb; + return Dice1.IsLower(Dice2) ? Dice2.Value - Dice1.Value : Dice1.Value - Dice2.Value; case Operation.ADDITION: - return Dice2.Nb + Dice1.Nb; + return Dice2.Value + Dice1.Value; case Operation.MULTIPLICATION: - return Dice2.Nb * Dice1.Nb; + return Dice2.Value * Dice1.Value; default: return 0; @@ -67,7 +67,7 @@ namespace Models.Game public void PlaceResult (Cell playerChoice, int result) { - if (Turn == 1 || GameRules.NearCell(playerChoice, UsedMap.Cells)) + if (Turn == 1 || GameRules.NearCell(playerChoice, UsedMap.Boards)) { playerChoice.Value = result; } diff --git a/source/Trek-12/Models/Game/OperationCell.cs b/source/Trek-12/Models/Game/OperationCell.cs index 641b7ab..1338f0c 100644 --- a/source/Trek-12/Models/Game/OperationCell.cs +++ b/source/Trek-12/Models/Game/OperationCell.cs @@ -1,6 +1,10 @@ namespace Models; + public class OperationCell : Position { - public bool IsChecked { get ; private set} + public bool IsChecked { get; private set; } + + public OperationCell (int x,int y) :base (x,y) + { } } \ No newline at end of file diff --git a/source/Trek-12/Models/Game/Position.cs b/source/Trek-12/Models/Game/Position.cs index f05bdbc..0be2153 100644 --- a/source/Trek-12/Models/Game/Position.cs +++ b/source/Trek-12/Models/Game/Position.cs @@ -1,6 +1,6 @@ namespace Models; -public struct Position +public class Position { public int X { get; set; } public int Y { get; set; } diff --git a/source/Trek-12/Models/Models.csproj b/source/Trek-12/Models/Models.csproj index 04d698b..e2b0aa0 100644 --- a/source/Trek-12/Models/Models.csproj +++ b/source/Trek-12/Models/Models.csproj @@ -11,6 +11,7 @@ + diff --git a/source/Trek-12/Models/Rules/Rules.cs b/source/Trek-12/Models/Rules/Rules.cs index 4b9c0b6..0daa484 100644 --- a/source/Trek-12/Models/Rules/Rules.cs +++ b/source/Trek-12/Models/Rules/Rules.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Models.Game; +using Models.Interfaces; namespace Models.Rules { @@ -11,17 +12,17 @@ namespace Models.Rules { public bool IsCellAdjacent(Cell choosenCell, Cell targetCell) { - if (Math.Abs(choosenCell.Pos.X - targetCell.Cell.X) > 1 || Math.Abs(choosenCell.Pos.Y - targetCell.Cell.Y) > 1) + if (Math.Abs(choosenCell.X - targetCell.X) > 1 || Math.Abs(choosenCell.Y - targetCell.Y) > 1) return false; return true; } - public bool NearCellIsValid(Cell choosenCell, List> cells) + public bool NearCellIsValid(Cell choosenCell, List cells) { if (choosenCell == null) return false; - IEnumerable PlayedCellsQuery = + IEnumerable PlayedCellsQuery = from cell in cells where cell.Value != null select cell; @@ -34,9 +35,9 @@ namespace Models.Rules } } - public bool IsZone(Cell choosen, List> cells) + public bool IsZone(Cell choosen, List cells,List> zones) { - IEnumerable PlayedCellsQuery = + IEnumerable PlayedCellsQuery = from cell in cells where cell.Value != null select cell;