Rassemblement des méthodes de règles dans la même classe

pull/57/head
Rémi LAVERGNE 12 months ago
parent 86eb33c89b
commit 96dee898ad
No known key found for this signature in database
GPG Key ID: CA264B55E97FD220

@ -40,5 +40,76 @@ namespace Models.Rules
return false; return false;
} }
public bool IsZone(Cell playerChoice, List<Cell> cells)
{
foreach (var item in cells)
{
if (playerChoice.Pos.X == item.Pos.X + 1 || playerChoice.Pos.X == item.Pos.X - 1
|| playerChoice.Pos.Y == item.Pos.Y + 1 || playerChoice.Pos.Y == item.Pos.Y - 1)
{
if (playerChoice.Value == item.Value)
{
return true;
}
}
}
return false;
}
public bool IsCheminDeCorde(Cell playerChoice, List<Cell> cells, List<Cell> cheminsDeCorde)
{
foreach (var item in cells)
{
if (playerChoice.Pos.X == item.Pos.X + 1 || playerChoice.Pos.X == item.Pos.X - 1
|| playerChoice.Pos.Y == item.Pos.Y + 1 || playerChoice.Pos.Y == item.Pos.Y - 1)
{
if (playerChoice.Value == item.Value+1 || playerChoice.Value == item.Value-1)
{
foreach (var chemin in cheminsDeCorde)
{
if (chemin.Equals(playerChoice))
{
return true;
}
}
return IsCheminDeCorde(item, cells, cheminsDeCorde);
}
}
}
return false;
}
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;
}
}
}
} }
} }

@ -1,43 +0,0 @@
namespace Models.Rules;
public class Zones
{
public bool IsZone(Cell playerChoice, List<Cell> cells)
{
foreach (var item in cells)
{
if (playerChoice.Pos.X == item.Pos.X + 1 || playerChoice.Pos.X == item.Pos.X - 1
|| playerChoice.Pos.Y == item.Pos.Y + 1 || playerChoice.Pos.Y == item.Pos.Y - 1)
{
if (playerChoice.Value == item.Value)
{
return true;
}
}
}
return false;
}
public bool IsCheminDeCorde(Cell playerChoice, List<Cell> cells, List<Cell> cheminsDeCorde)
{
foreach (var item in cells)
{
if (playerChoice.Pos.X == item.Pos.X + 1 || playerChoice.Pos.X == item.Pos.X - 1
|| playerChoice.Pos.Y == item.Pos.Y + 1 || playerChoice.Pos.Y == item.Pos.Y - 1)
{
if (playerChoice.Value == item.Value+1 || playerChoice.Value == item.Value-1)
{
foreach (var chemin in cheminsDeCorde)
{
if (chemin.Equals(playerChoice))
{
return true;
}
}
return IsCheminDeCorde(item, cells, cheminsDeCorde);
}
}
}
return false;
}
}

@ -1,45 +0,0 @@
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