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;
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;

@ -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<RopePath>();
}
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;
}

@ -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)
{ }
}

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

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

@ -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<List<Cell>> cells)
public bool NearCellIsValid(Cell choosenCell, List<Cell> cells)
{
if (choosenCell == null) return false;
IEnumerable<Cellule> PlayedCellsQuery =
IEnumerable<Cell> PlayedCellsQuery =
from cell in cells
where cell.Value != null
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
where cell.Value != null
select cell;

Loading…
Cancel
Save