diff --git a/source/Trek-12/ConsoleApp/Program.cs b/source/Trek-12/ConsoleApp/Program.cs
index cd0a03e..c9af02e 100644
--- a/source/Trek-12/ConsoleApp/Program.cs
+++ b/source/Trek-12/ConsoleApp/Program.cs
@@ -126,4 +126,9 @@ foreach (var item in game.UsedMap.Zones)
Console.Write(" |\n");
}
-Console.WriteLine(game.GameRules.FinalCalculusOfZones(game.UsedMap.Zones));
\ No newline at end of file
+Console.WriteLine(game.GameRules.FinalCalculusOfZones(game.UsedMap.Zones));
+
+Map maaaap = new Map("background");
+Game Gaaame = new(new Player("Luka"), maaaap);
+
+Gaaame.InitializeGame();
\ No newline at end of file
diff --git a/source/Trek-12/Models/Game/BestScore.cs b/source/Trek-12/Models/Game/BestScore.cs
index 2046daa..e54d58c 100644
--- a/source/Trek-12/Models/Game/BestScore.cs
+++ b/source/Trek-12/Models/Game/BestScore.cs
@@ -9,7 +9,11 @@ namespace Models
{
public class BestScore
{
-
+ ///
+ /// Initialize a new instance of the BestScore class.
+ ///
+ /// Number of games played by the new user
+ /// Best score
public BestScore(int gamesPlayed, int score)
{
GamesPlayed = gamesPlayed;
@@ -20,8 +24,14 @@ namespace Models
Score = 0;
}
+ ///
+ /// Number of games played by the user.
+ ///
public int GamesPlayed { get; private set; }
+ ///
+ /// Best score of the player.
+ ///
private int _score;
public int Score
{
@@ -36,11 +46,18 @@ namespace Models
}
}
+ ///
+ /// Increment the number of games played by the user.
+ ///
public void IncrGamesPlayed()
{
GamesPlayed += 1;
}
-
+
+ ///
+ /// Update the best score of the player.
+ ///
+ /// New best score
public void UpdateScore(int newScore)
{
Score = newScore;
diff --git a/source/Trek-12/Models/Game/Cell.cs b/source/Trek-12/Models/Game/Cell.cs
index 6f2d0c2..9692ac2 100644
--- a/source/Trek-12/Models/Game/Cell.cs
+++ b/source/Trek-12/Models/Game/Cell.cs
@@ -2,6 +2,9 @@
public class Cell : Position, IEquatable
{
+ ///
+ /// The value of the cell.
+ ///
private int? _value;
public int? Value {
get => _value;
@@ -15,18 +18,39 @@ public class Cell : Position, IEquatable
}
}
+ ///
+ /// The fact that the cell is dangerous or not.
+ ///
private bool IsDangerous { get; set; }
+ ///
+ /// Atribute to know if the cell is a penalty cell.
+ ///
private bool Penalty { get; set; }
+ ///
+ /// Constructor of the Cell class.
+ ///
+ /// the x position
+ /// the y position
+ /// if the cell is a dangerous cell or not
public Cell(int x, int y,bool isDangerous = false):base(x,y)
{
IsDangerous = isDangerous;
Penalty = false;
}
+ ///
+ /// Function in order to return the fact that the cell is dangerous or not.
+ ///
+ /// If the cell is dangerous or not
public bool GetCellType() => IsDangerous;
+ ///
+ /// Redefine the equal operation between cells.
+ ///
+ /// The object to compare with the current cell.
+ /// true if the specified object is equal to the current cell; otherwise, false.
public bool Equals(Cell? other)
{
if (other == null) return false;
diff --git a/source/Trek-12/Models/Game/Dice.cs b/source/Trek-12/Models/Game/Dice.cs
index 5df6c9a..b38f5d9 100644
--- a/source/Trek-12/Models/Game/Dice.cs
+++ b/source/Trek-12/Models/Game/Dice.cs
@@ -8,12 +8,25 @@ namespace Models.Game
{
public class Dice
{
+ ///
+ /// Lowest number on the dice.
+ ///
public int NbMin { get; private set; }
+ ///
+ /// Highest number on the dice.
+ ///
public int NbMax { get; private set; }
+ ///
+ /// Value of the dice.
+ ///
public int Value { get; private set; }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The lowest number on the dice, on which the highest number is set
public Dice(int nbmin)
{
if (nbmin < 0) nbmin = 0;
@@ -22,6 +35,9 @@ namespace Models.Game
NbMax = nbmin + 5;
}
+ ///
+ /// Initializes a new instance of the class.
+ ///
public Dice()
{
NbMin = 0;
@@ -33,11 +49,19 @@ namespace Models.Game
return $"Ce dé a pour valeur {Value} et est entre {NbMin} et {NbMax}";
}
+ ///
+ /// Rolls the dice.
+ ///
public void Roll()
{
Value = new Random().Next(NbMin, NbMax + 1);
}
+ ///
+ /// Compare 2 dice values.
+ ///
+ /// Another dice
+ /// true if the dice2 is higher than the dice1; otherwise, false.
public bool IsLower(Dice dice2)
{
return dice2.Value > this.Value;
diff --git a/source/Trek-12/Models/Game/Map.cs b/source/Trek-12/Models/Game/Map.cs
index ab60b79..de9ae3f 100644
--- a/source/Trek-12/Models/Game/Map.cs
+++ b/source/Trek-12/Models/Game/Map.cs
@@ -18,10 +18,13 @@ public class Map
public List OperationGrid { get; private set; }
///
- /// It is a list of a list containing user's zones in the current game
+ /// It is a list of a list containing user's rope paths in the current game
///
public List> RopePaths { get; private set; }
+ ///
+ /// It is a list of a list containing user's zones in the current game
+ ///
public List> Zones { get; private set; }
///
@@ -38,6 +41,10 @@ public class Map
Zones = new List>();
}
+ ///
+ /// Initializes the boards of the map.
+ ///
+ /// Return the boards
public static List InitializeBoards()
{
Cell pos01 = new Cell(0, 0);
@@ -93,6 +100,9 @@ public class Map
return list;
}
+ ///
+ /// Dislpay the boards of the map in the console.
+ ///
public void DisplayBoards()
{
int cpt = 0;
@@ -105,6 +115,10 @@ public class Map
}
}
+ ///
+ /// Ask the player to choose a cell to play.
+ ///
+ ///
public Cell PlayerChoiceOfPosition()
{
Console.WriteLine("Enter the position of the cell you want to play");
diff --git a/source/Trek-12/Models/Interfaces/IRules.cs b/source/Trek-12/Models/Interfaces/IRules.cs
index 691df73..714a44c 100644
--- a/source/Trek-12/Models/Interfaces/IRules.cs
+++ b/source/Trek-12/Models/Interfaces/IRules.cs
@@ -6,8 +6,19 @@ public interface IRules
{
//public bool NearCellIsValid(Position playerChoicePosition, SortedDictionary cells);
+ ///
+ /// Return true if the cell is empty, otherwise false.
+ ///
+ /// The cell that the player chose
+ /// Return true if the cell is empty, otherwise false.
public bool IsCellEmpty(Cell playerChoice);
+ ///
+ /// Check if the cell is valid.
+ ///
+ /// The cell that the player chose
+ /// Boards of the actual game
+ /// true if the cell is valid; otherwise, false
public bool IsCellValid(Cell playerChoicePosition, List cells);
//public bool IsRopePath(Cell playerChoice, HashSet ropePaths);
| | | |