diff --git a/source/Trek-12/Models/Game/Map.cs b/source/Trek-12/Models/Game/Map.cs index 816bb5c..2b094db 100644 --- a/source/Trek-12/Models/Game/Map.cs +++ b/source/Trek-12/Models/Game/Map.cs @@ -2,16 +2,32 @@ public class Map { + /// + /// It is the list of cells on the map. + /// public List Boards { get; set; } - + + /// + /// It is the backgrond image of the map + /// public string Background { get; private set; } + /// + /// It is the grid of the possible operation in the game + /// public List OperationGrid { get; private set; } - //public List> RopePaths { get; private set; } + /// + /// It is a list of a list containing user's zones in the current game + /// + public List> RopePaths { get; private set; } public List> Zones { get; private set; } + /// + /// Initializes a new instance of the Map class. + /// + /// The background of the map. public Map(string background) { Boards = new List(); @@ -19,7 +35,5 @@ public class Map OperationGrid = new List(); //RopePaths = new List>(); Zones = new List>(); - } - -} \ No newline at end of file +} diff --git a/source/Trek-12/Models/Game/Operation.cs b/source/Trek-12/Models/Game/Operation.cs index 7c92573..1a9f9c4 100644 --- a/source/Trek-12/Models/Game/Operation.cs +++ b/source/Trek-12/Models/Game/Operation.cs @@ -6,6 +6,9 @@ using System.Threading.Tasks; namespace Models { + /// + /// Represents the available operations in the game. + /// public enum Operation { LOWER, diff --git a/source/Trek-12/Models/Game/OperationCell.cs b/source/Trek-12/Models/Game/OperationCell.cs index 1338f0c..6efcb9c 100644 --- a/source/Trek-12/Models/Game/OperationCell.cs +++ b/source/Trek-12/Models/Game/OperationCell.cs @@ -3,6 +3,9 @@ namespace Models; public class OperationCell : Position { + /// + /// It tells if the operation is checked or not in the operation grid of the game. + /// public bool IsChecked { get; private set; } public OperationCell (int x,int y) :base (x,y) diff --git a/source/Trek-12/Models/Game/Player.cs b/source/Trek-12/Models/Game/Player.cs index c264f47..cf6ffb7 100644 --- a/source/Trek-12/Models/Game/Player.cs +++ b/source/Trek-12/Models/Game/Player.cs @@ -2,33 +2,60 @@ public class Player { + /// + /// It is he pseudo of the player. + /// public string Pseudo { get; private set; } + /// + /// It is the profile picture of the player. + /// public string ProfilePicture { get; private set; } + /// + /// It is the creation date of the player. + /// public string? CreationDate { get; private set; } + /// + /// It tells when was the last time the player played. + /// public string? LastPlayed { get; private set; } + /// + /// Constructor with default values. + /// public Player() { Pseudo = "Player"; ProfilePicture = "DefaultProfilePicture"; } + /// + /// Construct a new instance of Player with specified pseudo and profile picture. + /// + /// The pseudo of the player. + /// The profile picture of the player. public Player(string pseudo, string profilePicture = "DefaultProfilePicture") { Pseudo = pseudo; ProfilePicture = profilePicture; } - - + /// + /// Chooses the operation for the player. + /// + /// The chosen operation. public Operation ChooseOperation() { return Operation.LOWER; } + /// + /// Redefine the equal operation between player. + /// + /// The object to compare with the current player. + /// true if the specified object is equal to the current player; otherwise, false. 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 == + /// + /// Returns the hash code for the current player, in order for the Equals operation to work + /// + /// The hash code for the current player. public override int GetHashCode() { return Pseudo.GetHashCode(); diff --git a/source/Trek-12/Models/Game/Position.cs b/source/Trek-12/Models/Game/Position.cs index 0be2153..40c23d6 100644 --- a/source/Trek-12/Models/Game/Position.cs +++ b/source/Trek-12/Models/Game/Position.cs @@ -2,12 +2,24 @@ public class Position { + /// + /// The X coordinate. + /// public int X { get; set; } + + /// + /// The Y coordinate. + /// public int Y { get; set; } - + + /// + /// Constructor of the Position class. + /// + /// The X coordinate. + /// The Y coordinate. public Position(int x, int y) { X = x; Y = y; } -} \ No newline at end of file +} diff --git a/source/Trek-12/Models/Interfaces/IRules.cs b/source/Trek-12/Models/Interfaces/IRules.cs index fac4d42..cf79a0c 100644 --- a/source/Trek-12/Models/Interfaces/IRules.cs +++ b/source/Trek-12/Models/Interfaces/IRules.cs @@ -18,26 +18,95 @@ public interface IRules //public void SetValueAndPenalty(int valueChoice, Cell playerChoice, List cells); + + /// + /// Check if the given cell is adjacent to the target cell. + /// + /// The chosen cell. + /// The target cell. + /// True if the given cell is adjacent to the target cell; otherwise false. public bool IsCellAdjacent(Cell choosenCell, Cell targetCell); + /// + /// 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. + /// + /// The chosen cell. + /// The list of cells. + /// True if the chosen cell can be played here; otherwise false. public bool NearCellIsValid(Cell choosenCell, List cells); - public bool IsZoneValidAndAddToZones(Cell chosenCell, Map map); - + /// + /// 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 + /// + /// The chosen cell. + /// The map. + /// + public void IsZoneValidAndAddToZones(Cell chosenCell, Map map); + + /// + /// Check if the value of the chosen cell is in the zones of the player. + /// + /// The cell chosen by the player. + /// The list of the player's zones. + /// True if the value is in the zones; otherwise false. public bool IsValueInZones(Cell chosenCell, List> zones); + /// + /// Check if the chosen cell is in any of the player's zones. + /// + /// The chosen cell. + /// The list of the player's zones. + /// True if the cell is in any of the zones; otherwise false. public bool IsCellInZone(Cell chosenCell, List> zones); + /// + /// Add the chosen cell to the list of zones. + /// The zone must be created before. + /// + /// The chosen cell. + /// The list of zones. public void AddToZone(Cell chosenCell, List> zones); + /// + /// Create a new zone with the two cells and add it to the map. + /// + /// The first cell. + /// The second cell. + /// The map. public void NewZoneIsCreated(Cell firstCell, Cell secondCell, Map map); + /// + /// Get every adjacent cell of the chosen cell. + /// + /// The chosen cell. + /// The list of cells. + /// The list of adjacent cells. public List EveryAdjacentCells(Cell choosenCell, List cells); + /// + /// Calculate the final score by summing up the values of all the zones. + /// + /// The list of zones. + /// The final score. public int? FinalCalculusOfZones(List> zones); + /// + /// Check if the adjacent cell is in any of the rope paths. + /// + /// The adjacent cell. + /// The list of rope paths. + /// The index of the rope path. + /// True if the adjacent cell is in the rope path; otherwise false. public bool IsInRopePaths(Cell adjacente, List> ropePaths, int index); + /// + /// Check if the chosen cell has the same value as the rope path at the given index. + /// + /// The chosen cell. + /// The list of rope paths. + /// The index of the rope path. + /// True if the chosen cell has the same value as the rope path; otherwise false. public bool AsValue(Cell choosenCell, List> ropePaths, int index); - -} \ No newline at end of file +} diff --git a/source/Trek-12/Models/Rules/Rules.cs b/source/Trek-12/Models/Rules/Rules.cs index 0c88c32..723a0d6 100644 --- a/source/Trek-12/Models/Rules/Rules.cs +++ b/source/Trek-12/Models/Rules/Rules.cs @@ -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;