Ajout de la doc

pull/67/head
Remi NEVEU 11 months ago
parent 812dbf5fc7
commit 9dc4aac9ec

@ -2,16 +2,32 @@
public class Map
{
/// <summary>
/// It is the list of cells on the map.
/// </summary>
public List<Cell> Boards { get; set; }
/// <summary>
/// It is the backgrond image of the map
/// </summary>
public string Background { get; private set; }
/// <summary>
/// It is the grid of the possible operation in the game
/// </summary>
public List<OperationCell> OperationGrid { get; private set; }
//public List<List<Cell>> RopePaths { get; private set; }
/// <summary>
/// It is a list of a list containing user's zones in the current game
/// </summary>
public List<List<Cell>> RopePaths { get; private set; }
public List<List<Cell>> Zones { get; private set; }
/// <summary>
/// Initializes a new instance of the Map class.
/// </summary>
/// <param name="background">The background of the map.</param>
public Map(string background)
{
Boards = new List<Cell>();
@ -19,7 +35,5 @@ public class Map
OperationGrid = new List<OperationCell>();
//RopePaths = new List<List<Cell>>();
Zones = new List<List<Cell>>();
}
}
}

@ -6,6 +6,9 @@ using System.Threading.Tasks;
namespace Models
{
/// <summary>
/// Represents the available operations in the game.
/// </summary>
public enum Operation
{
LOWER,

@ -3,6 +3,9 @@ namespace Models;
public class OperationCell : Position
{
/// <summary>
/// It tells if the operation is checked or not in the operation grid of the game.
/// </summary>
public bool IsChecked { get; private set; }
public OperationCell (int x,int y) :base (x,y)

@ -2,33 +2,60 @@
public class Player
{
/// <summary>
/// It is he pseudo of the player.
/// </summary>
public string Pseudo { get; private set; }
/// <summary>
/// It is the profile picture of the player.
/// </summary>
public string ProfilePicture { get; private set; }
/// <summary>
/// It is the creation date of the player.
/// </summary>
public string? CreationDate { get; private set; }
/// <summary>
/// It tells when was the last time the player played.
/// </summary>
public string? LastPlayed { get; private set; }
/// <summary>
/// Constructor with default values.
/// </summary>
public Player()
{
Pseudo = "Player";
ProfilePicture = "DefaultProfilePicture";
}
/// <summary>
/// Construct a new instance of Player with specified pseudo and profile picture.
/// </summary>
/// <param name="pseudo">The pseudo of the player.</param>
/// <param name="profilePicture">The profile picture of the player.</param>
public Player(string pseudo, string profilePicture = "DefaultProfilePicture")
{
Pseudo = pseudo;
ProfilePicture = profilePicture;
}
/// <summary>
/// Chooses the operation for the player.
/// </summary>
/// <returns>The chosen operation.</returns>
public Operation ChooseOperation()
{
return Operation.LOWER;
}
/// <summary>
/// Redefine the equal operation between player.
/// </summary>
/// <param name="obj">The object to compare with the current player.</param>
/// <returns>true if the specified object is equal to the current player; otherwise, false.</returns>
public override bool Equals(object? obj)
{
if (obj == null || GetType() != obj.GetType())
@ -39,7 +66,10 @@ public class Player
return (Pseudo == c.Pseudo);
}
// Redefinition de la méthode de Hash pour l'opérateur ==
/// <summary>
/// Returns the hash code for the current player, in order for the Equals operation to work
/// </summary>
/// <returns>The hash code for the current player.</returns>
public override int GetHashCode()
{
return Pseudo.GetHashCode();

@ -2,12 +2,24 @@
public class Position
{
/// <summary>
/// The X coordinate.
/// </summary>
public int X { get; set; }
/// <summary>
/// The Y coordinate.
/// </summary>
public int Y { get; set; }
/// <summary>
/// Constructor of the Position class.
/// </summary>
/// <param name="x">The X coordinate.</param>
/// <param name="y">The Y coordinate.</param>
public Position(int x, int y)
{
X = x;
Y = y;
}
}
}

@ -18,26 +18,95 @@ public interface IRules
//public void SetValueAndPenalty(int valueChoice, Cell playerChoice, List<Position, Cell> cells);
/// <summary>
/// Check if the given cell is adjacent to the target cell.
/// </summary>
/// <param name="choosenCell">The chosen cell.</param>
/// <param name="targetCell">The target cell.</param>
/// <returns>True if the given cell is adjacent to the target cell; otherwise false.</returns>
public bool IsCellAdjacent(Cell choosenCell, Cell targetCell);
/// <summary>
/// Check if the given cell can be played there.
/// If there isn't any adjacent cell with a value, or if the cell is null, it returns false.
/// </summary>
/// <param name="choosenCell">The chosen cell.</param>
/// <param name="cells">The list of cells.</param>
/// <returns>True if the chosen cell can be played here; otherwise false.</returns>
public bool NearCellIsValid(Cell choosenCell, List<Cell> cells);
public bool IsZoneValidAndAddToZones(Cell chosenCell, Map map);
/// <summary>
/// Check if the chosen cell is valid and add it to the matching zone.
/// If there is a nearby cell with matching value but no zone already created, it creates one
/// </summary>
/// <param name="chosenCell">The chosen cell.</param>
/// <param name="map">The map.</param>
/// <returns></returns>
public void IsZoneValidAndAddToZones(Cell chosenCell, Map map);
/// <summary>
/// Check if the value of the chosen cell is in the zones of the player.
/// </summary>
/// <param name="chosenCell">The cell chosen by the player.</param>
/// <param name="zones">The list of the player's zones.</param>
/// <returns>True if the value is in the zones; otherwise false.</returns>
public bool IsValueInZones(Cell chosenCell, List<List<Cell>> zones);
/// <summary>
/// Check if the chosen cell is in any of the player's zones.
/// </summary>
/// <param name="chosenCell">The chosen cell.</param>
/// <param name="zones">The list of the player's zones.</param>
/// <returns>True if the cell is in any of the zones; otherwise false.</returns>
public bool IsCellInZone(Cell chosenCell, List<List<Cell>> zones);
/// <summary>
/// Add the chosen cell to the list of zones.
/// The zone must be created before.
/// </summary>
/// <param name="chosenCell">The chosen cell.</param>
/// <param name="zones">The list of zones.</param>
public void AddToZone(Cell chosenCell, List<List<Cell>> zones);
/// <summary>
/// Create a new zone with the two cells and add it to the map.
/// </summary>
/// <param name="firstCell">The first cell.</param>
/// <param name="secondCell">The second cell.</param>
/// <param name="map">The map.</param>
public void NewZoneIsCreated(Cell firstCell, Cell secondCell, Map map);
/// <summary>
/// Get every adjacent cell of the chosen cell.
/// </summary>
/// <param name="choosenCell">The chosen cell.</param>
/// <param name="cells">The list of cells.</param>
/// <returns>The list of adjacent cells.</returns>
public List<Cell> EveryAdjacentCells(Cell choosenCell, List<Cell> cells);
/// <summary>
/// Calculate the final score by summing up the values of all the zones.
/// </summary>
/// <param name="zones">The list of zones.</param>
/// <returns>The final score.</returns>
public int? FinalCalculusOfZones(List<List<Cell>> zones);
/// <summary>
/// Check if the adjacent cell is in any of the rope paths.
/// </summary>
/// <param name="adjacente">The adjacent cell.</param>
/// <param name="ropePaths">The list of rope paths.</param>
/// <param name="index">The index of the rope path.</param>
/// <returns>True if the adjacent cell is in the rope path; otherwise false.</returns>
public bool IsInRopePaths(Cell adjacente, List<List<Cell>> ropePaths, int index);
/// <summary>
/// Check if the chosen cell has the same value as the rope path at the given index.
/// </summary>
/// <param name="choosenCell">The chosen cell.</param>
/// <param name="ropePaths">The list of rope paths.</param>
/// <param name="index">The index of the rope path.</param>
/// <returns>True if the chosen cell has the same value as the rope path; otherwise false.</returns>
public bool AsValue(Cell choosenCell, List<List<Cell>> ropePaths, int index);
}
}

@ -70,7 +70,7 @@ namespace Models.Rules
return false;
}
public bool IsZoneValidAndAddToZones(Cell chosenCell, Map map)
public void IsZoneValidAndAddToZones(Cell chosenCell, Map map)
{
if (chosenCell == null ||chosenCell.Value == null) return false;

Loading…
Cancel
Save