correction des erreurs
continuous-integration/drone/push Build is failing Details

pull/61/head
Lucas DUFLOT 12 months ago
parent 3e19e6ba55
commit e303b97a39

@ -1,6 +1,6 @@
namespace Models; namespace Models;
public class Cell public class Cell : Position
{ {
private int? _value; private int? _value;
public int? Value { public int? Value {
@ -19,7 +19,7 @@ public class Cell
private bool Penalty { get; set; } private bool Penalty { get; set; }
public Cell(bool isDangerous = false) public Cell(int x, int y,bool isDangerous = false):base(x,y)
{ {
IsDangerous = isDangerous; IsDangerous = isDangerous;
Penalty = false; Penalty = false;

@ -4,6 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Models.Events; using Models.Events;
using Models.Rules;
namespace Models.Game namespace Models.Game
{ {
@ -18,13 +19,13 @@ namespace Models.Game
private int Turn { get; set; } private int Turn { get; set; }
private IRules GameRules { get; } private Rules.Rules GameRules { get; }
// == Events == // == Events ==
public event GameStartedEventArgs OnGameStarted; public event GameStartedEventArgs OnGameStarted;
public event GameStartedEventArgs GameStarted; public Game(Player player, Map map) public Game(Player player, Map map)
{ {
UsedMap = map; UsedMap = map;
CurrentPlayer = player; CurrentPlayer = player;
@ -32,7 +33,6 @@ namespace Models.Game
Dice2 = new Dice(1); Dice2 = new Dice(1);
Turn = 0; Turn = 0;
GameRules = new Rules.Rules(); GameRules = new Rules.Rules();
ropePaths = new HashSet<RopePath>();
} }
public void RollAllDice() public void RollAllDice()
@ -46,19 +46,19 @@ namespace Models.Game
switch (o) switch (o)
{ {
case Operation.LOWER: case Operation.LOWER:
return Dice1.IsLower(Dice2) ? Dice1.Nb : Dice2.Nb; return Dice1.IsLower(Dice2) ? Dice1.Value : Dice2.Value;
case Operation.HIGHER: case Operation.HIGHER:
return Dice1.IsLower(Dice2) ? Dice2.Nb : Dice1.Nb; return Dice1.IsLower(Dice2) ? Dice2.Value : Dice1.Value;
case Operation.SUBTRACTION: 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: case Operation.ADDITION:
return Dice2.Nb + Dice1.Nb; return Dice2.Value + Dice1.Value;
case Operation.MULTIPLICATION: case Operation.MULTIPLICATION:
return Dice2.Nb * Dice1.Nb; return Dice2.Value * Dice1.Value;
default: default:
return 0; return 0;
@ -67,7 +67,7 @@ namespace Models.Game
public void PlaceResult (Cell playerChoice, int result) 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; playerChoice.Value = result;
} }

@ -1,6 +1,10 @@
namespace Models; namespace Models;
public class OperationCell : Position 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)
{ }
} }

@ -1,6 +1,6 @@
namespace Models; namespace Models;
public struct Position public class Position
{ {
public int X { get; set; } public int X { get; set; }
public int Y { get; set; } public int Y { get; set; }

@ -11,6 +11,7 @@
<Folder Include="Exceptions\" /> <Folder Include="Exceptions\" />
<Folder Include="Interfaces\" /> <Folder Include="Interfaces\" />
<Folder Include="Rules\" /> <Folder Include="Rules\" />
<Folder Include="Events\" />
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -4,6 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Models.Game; using Models.Game;
using Models.Interfaces;
namespace Models.Rules namespace Models.Rules
{ {
@ -11,17 +12,17 @@ namespace Models.Rules
{ {
public bool IsCellAdjacent(Cell choosenCell, Cell targetCell) 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 false;
return true; return true;
} }
public bool NearCellIsValid(Cell choosenCell, List<List<Cell>> cells) public bool NearCellIsValid(Cell choosenCell, List<Cell> cells)
{ {
if (choosenCell == null) return false; if (choosenCell == null) return false;
IEnumerable<Cellule> PlayedCellsQuery = IEnumerable<Cell> PlayedCellsQuery =
from cell in cells from cell in cells
where cell.Value != null where cell.Value != null
select cell; select cell;
@ -34,9 +35,9 @@ namespace Models.Rules
} }
} }
public bool IsZone(Cell choosen, List<List<Cell>> cells) public bool IsZone(Cell choosen, List<Cell> cells,List<List<Cell>> zones)
{ {
IEnumerable<Cellule> PlayedCellsQuery = IEnumerable<Cell> PlayedCellsQuery =
from cell in cells from cell in cells
where cell.Value != null where cell.Value != null
select cell; select cell;

Loading…
Cancel
Save