Ajout des règles des Box et petite modif dans la class Cell

pull/47/head
Remi NEVEU 1 year ago
parent 95e45780fb
commit 54d75d3078

@ -20,16 +20,16 @@ public class Cell
} }
} }
private string Type { get; set; } public bool IsDangerous { get; set; }
private string? Background { get; set; } public string? Background { get; set; }
public Cell(int x, int y) public Cell(int x, int y)
{ {
Pos = new Position(x, y); Pos = new Position(x, y);
} }
public string GetCellType() => Type; public bool GetCellType() => IsDangerous;
// Redefinition de l'opérateur == pour comparer deux cellules // Redefinition de l'opérateur == pour comparer deux cellules
@ -48,4 +48,5 @@ public class Cell
{ {
return Pos.X * Pos.Y; return Pos.X * Pos.Y;
} }
} }

@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Models;
namespace Models.Rules
{
public class ruleBox
{
public int HowMuch(Cell playerChoice, List<Cell> cells)
{
foreach(var pos in cells)
{
if (pos.Equals(playerChoice))
{
if (pos.GetCellType())
{
return 6;
}
return 12;
}
}
return 0;
}
public void SetValueAndPenalty(int valueChoice, Cell playerChoice, List<Cell> cells)
{
int val = HowMuch(playerChoice, cells);
foreach (var pos in cells)
{
if (pos.Equals(playerChoice))
{
if (valueChoice > val)
{
playerChoice.Background = "notcontent";
}
playerChoice.Value = valueChoice;
}
}
}
}
}
Loading…
Cancel
Save