Merge pull request 'ruleBox' (#47) from ruleBox into dev

Reviewed-on: #47
pull/53/head
Lucas DUFLOT 1 year ago
commit 459bbae37e

@ -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)
{
Pos = new Position(x, y);
}
public string GetCellType() => Type;
public bool GetCellType() => IsDangerous;
// Redefinition de l'opérateur == pour comparer deux cellules
@ -48,4 +48,5 @@ public class Cell
{
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 HowMany(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 = HowMany(playerChoice, cells);
foreach (var pos in cells)
{
if (pos.Equals(playerChoice))
{
if (valueChoice > val)
{
playerChoice.Background = "notcontent";
}
playerChoice.Value = valueChoice;
}
}
}
}
}
Loading…
Cancel
Save