Finalisation de la doc des fonctions
continuous-integration/drone/push Build is failing Details

pull/67/head
Remi NEVEU 11 months ago
parent 34c76e5602
commit 4c693cc935

@ -126,4 +126,9 @@ foreach (var item in game.UsedMap.Zones)
Console.Write(" |\n");
}
Console.WriteLine(game.GameRules.FinalCalculusOfZones(game.UsedMap.Zones));
Console.WriteLine(game.GameRules.FinalCalculusOfZones(game.UsedMap.Zones));
Map maaaap = new Map("background");
Game Gaaame = new(new Player("Luka"), maaaap);
Gaaame.InitializeGame();

@ -9,7 +9,11 @@ namespace Models
{
public class BestScore
{
/// <summary>
/// Initialize a new instance of the BestScore class.
/// </summary>
/// <param name="gamesPlayed">Number of games played by the new user</param>
/// <param name="score">Best score</param>
public BestScore(int gamesPlayed, int score)
{
GamesPlayed = gamesPlayed;
@ -20,8 +24,14 @@ namespace Models
Score = 0;
}
/// <summary>
/// Number of games played by the user.
/// </summary>
public int GamesPlayed { get; private set; }
/// <summary>
/// Best score of the player.
/// </summary>
private int _score;
public int Score
{
@ -36,11 +46,18 @@ namespace Models
}
}
/// <summary>
/// Increment the number of games played by the user.
/// </summary>
public void IncrGamesPlayed()
{
GamesPlayed += 1;
}
/// <summary>
/// Update the best score of the player.
/// </summary>
/// <param name="newScore">New best score</param>
public void UpdateScore(int newScore)
{
Score = newScore;

@ -2,6 +2,9 @@
public class Cell : Position, IEquatable<Cell>
{
/// <summary>
/// The value of the cell.
/// </summary>
private int? _value;
public int? Value {
get => _value;
@ -15,18 +18,39 @@ public class Cell : Position, IEquatable<Cell>
}
}
/// <summary>
/// The fact that the cell is dangerous or not.
/// </summary>
private bool IsDangerous { get; set; }
/// <summary>
/// Atribute to know if the cell is a penalty cell.
/// </summary>
private bool Penalty { get; set; }
/// <summary>
/// Constructor of the Cell class.
/// </summary>
/// <param name="x">the x position</param>
/// <param name="y">the y position</param>
/// <param name="isDangerous">if the cell is a dangerous cell or not</param>
public Cell(int x, int y,bool isDangerous = false):base(x,y)
{
IsDangerous = isDangerous;
Penalty = false;
}
/// <summary>
/// Function in order to return the fact that the cell is dangerous or not.
/// </summary>
/// <returns>If the cell is dangerous or not</returns>
public bool GetCellType() => IsDangerous;
/// <summary>
/// Redefine the equal operation between cells.
/// </summary>
/// <param name="obj">The object to compare with the current cell.</param>
/// <returns>true if the specified object is equal to the current cell; otherwise, false.</returns>
public bool Equals(Cell? other)
{
if (other == null) return false;

@ -8,12 +8,25 @@ namespace Models.Game
{
public class Dice
{
/// <summary>
/// Lowest number on the dice.
/// </summary>
public int NbMin { get; private set; }
/// <summary>
/// Highest number on the dice.
/// </summary>
public int NbMax { get; private set; }
/// <summary>
/// Value of the dice.
/// </summary>
public int Value { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="Dice"/> class.
/// </summary>
/// <param name="nbmin">The lowest number on the dice, on which the highest number is set</param>
public Dice(int nbmin)
{
if (nbmin < 0) nbmin = 0;
@ -22,6 +35,9 @@ namespace Models.Game
NbMax = nbmin + 5;
}
/// <summary>
/// Initializes a new instance of the <see cref="Dice"/> class.
/// </summary>
public Dice()
{
NbMin = 0;
@ -33,11 +49,19 @@ namespace Models.Game
return $"Ce dé a pour valeur {Value} et est entre {NbMin} et {NbMax}";
}
/// <summary>
/// Rolls the dice.
/// </summary>
public void Roll()
{
Value = new Random().Next(NbMin, NbMax + 1);
}
/// <summary>
/// Compare 2 dice values.
/// </summary>
/// <param name="dice2">Another dice</param>
/// <returns>true if the dice2 is higher than the dice1; otherwise, false.</returns>
public bool IsLower(Dice dice2)
{
return dice2.Value > this.Value;

@ -18,10 +18,13 @@ public class Map
public List<OperationCell> OperationGrid { get; private set; }
/// <summary>
/// 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
/// </summary>
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>> Zones { get; private set; }
/// <summary>
@ -38,6 +41,10 @@ public class Map
Zones = new List<List<Cell>>();
}
/// <summary>
/// Initializes the boards of the map.
/// </summary>
/// <returns>Return the boards</returns>
public static List<Cell> InitializeBoards()
{
Cell pos01 = new Cell(0, 0);
@ -93,6 +100,9 @@ public class Map
return list;
}
/// <summary>
/// Dislpay the boards of the map in the console.
/// </summary>
public void DisplayBoards()
{
int cpt = 0;
@ -105,6 +115,10 @@ public class Map
}
}
/// <summary>
/// Ask the player to choose a cell to play.
/// </summary>
/// <returns></returns>
public Cell PlayerChoiceOfPosition()
{
Console.WriteLine("Enter the position of the cell you want to play");

@ -6,8 +6,19 @@ public interface IRules
{
//public bool NearCellIsValid(Position playerChoicePosition, SortedDictionary<Position, Cell> cells);
/// <summary>
/// Return true if the cell is empty, otherwise false.
/// </summary>
/// <param name="playerChoice">The cell that the player chose</param>
/// <returns> Return true if the cell is empty, otherwise false.</returns>
public bool IsCellEmpty(Cell playerChoice);
/// <summary>
/// Check if the cell is valid.
/// </summary>
/// <param name="playerChoicePosition">The cell that the player chose</param>
/// <param name="cells">Boards of the actual game</param>
/// <returns>true if the cell is valid; otherwise, false</returns>
public bool IsCellValid(Cell playerChoicePosition, List<Cell> cells);
//public bool IsRopePath(Cell playerChoice, HashSet<RopePath> ropePaths);

Loading…
Cancel
Save