more and more documentation, again
continuous-integration/drone/push Build is passing Details

master
rportet 11 months ago
parent ffbd8aba48
commit d24b19e757

@ -60,9 +60,9 @@ namespace QwirkleClassLibrary.Boards
} }
/// <summary> /// <summary>
/// This method is used to check if a cell in the board whether it already contains a tile or not. /// This method is used to check if a cell in the board whether already contains a tile or not.
/// </summary> /// </summary>
/// <returns>Returns a boolean : true if the cell doesn't contain any tile, false if it already contains a tile.</returns> /// <returns>Returns a boolean : true if the cell doesn't contain any tile, false if already contains a tile.</returns>
public bool HasOccupiedCase() public bool HasOccupiedCase()
{ {
foreach (var cell in cells) foreach (var cell in cells)

@ -4,14 +4,15 @@ using System.Runtime.CompilerServices;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using QwirkleClassLibrary.Tiles; using QwirkleClassLibrary.Tiles;
namespace QwirkleClassLibrary.Boards; namespace QwirkleClassLibrary.Boards
/// <summary>
/// Our board is made with a list of this class. It can stock infos such as its position on the board and the tile it contains.
/// </summary>
[DataContract]
public class Cell : INotifyPropertyChanged
{ {
/// <summary>
/// Our board is made with a list of this class. It can stock infos such as its position on the board and the tile it contains.
/// </summary>
[DataContract]
public class Cell : INotifyPropertyChanged
{
public event PropertyChangedEventHandler? PropertyChanged; public event PropertyChangedEventHandler? PropertyChanged;
[DataMember] [DataMember]
@ -21,7 +22,7 @@ public class Cell : INotifyPropertyChanged
private readonly int y; private readonly int y;
[DataMember] [DataMember]
public Tile? Tile { get; private set;} public Tile? Tile { get; private set; }
/// <summary> /// <summary>
/// This is the constructor for a Cell. /// This is the constructor for a Cell.
@ -59,7 +60,7 @@ public class Cell : INotifyPropertyChanged
} }
/// <summary> /// <summary>
/// Check if the Cell whether is empty or contains a tile. /// Checks if the Cell whether is empty or contains a tile.
/// </summary> /// </summary>
/// <returns>True if the cell is empty, false if the cell contains a tile.</returns> /// <returns>True if the cell is empty, false if the cell contains a tile.</returns>
public bool IsFree public bool IsFree
@ -92,4 +93,5 @@ public class Cell : INotifyPropertyChanged
{ {
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
} }
}
} }

@ -122,7 +122,12 @@ namespace QwirkleClassLibrary.Games
OnPlayerNotified(new AddPlayerNotifiedEventArgs("Players were correctly added.")); OnPlayerNotified(new AddPlayerNotifiedEventArgs("Players were correctly added."));
return true; return true;
} }
/// <summary>
/// This function is used to check if the player name that the user has entered meets the criteria set by the application.
/// </summary>
/// <param name="playersTag">A list that contains all the names entered when the game was started.</param>
/// <param name="pos">The position of the name we want to check in this list.</param>
/// <returns>boolean true if everything is okay, false if there was a problem in the player name.</returns>
public bool CheckPlayerTag(List<string> playersTag, int pos) public bool CheckPlayerTag(List<string> playersTag, int pos)
{ {
if (string.IsNullOrWhiteSpace(playersTag[pos])) if (string.IsNullOrWhiteSpace(playersTag[pos]))

@ -3,13 +3,14 @@ using QwirkleClassLibrary.Boards;
using QwirkleClassLibrary.Players; using QwirkleClassLibrary.Players;
using QwirkleClassLibrary.Tiles; using QwirkleClassLibrary.Tiles;
namespace QwirkleClassLibrary.Games; namespace QwirkleClassLibrary.Games
/// <summary>
/// This interface is used for all methods related to the player, such as the moves he can make.
/// </summary>
public interface IPlayer
{ {
/// <summary>
/// This interface is used for all methods related to the player, such as the moves he can make.
/// </summary>
public interface IPlayer
{
public Player CreatePlayer(string playerTag); public Player CreatePlayer(string playerTag);
public string SetNextPlayer(); public string SetNextPlayer();
@ -29,4 +30,5 @@ public interface IPlayer
int CalculateLineScore(ReadOnlyCollection<Cell> cellsPlayed, Cell cell, Tuple<int, int> direction, int CalculateLineScore(ReadOnlyCollection<Cell> cellsPlayed, Cell cell, Tuple<int, int> direction,
Tuple<int, int> orientation, ref int nbCellsInLine, ref int nbCellsInPerpLine, ref List<Cell> checkedCells); Tuple<int, int> orientation, ref int nbCellsInLine, ref int nbCellsInPerpLine, ref List<Cell> checkedCells);
}
} }

@ -1,10 +1,17 @@
using System.Runtime.Serialization; using System.Runtime.Serialization;
using QwirkleClassLibrary.Games; using QwirkleClassLibrary.Games;
namespace QwirkleClassLibrary.Persistences; namespace QwirkleClassLibrary.Persistences
public class GamePersistenceXml : IGamePersistence
{ {
/// <summary>
/// This class takes care of managing persistence with regard to the information of the current game, allowing the last game played to be resumed even when returning to the menu or exiting the application.
/// </summary>
public class GamePersistenceXml : IGamePersistence
{
/// <summary>
/// The main purpose of this method is to save the data from the game when the user quits the app, so players can continue it later.
/// </summary>
/// <param name="game"></param>
public void SaveGame(Game game) public void SaveGame(Game game)
{ {
var serializer = new DataContractSerializer(typeof(Game), var serializer = new DataContractSerializer(typeof(Game),
@ -15,7 +22,10 @@ public class GamePersistenceXml : IGamePersistence
serializer.WriteObject(writer, game); serializer.WriteObject(writer, game);
} }
} }
/// <summary>
/// This method is used to retrieve the information needed to resume the last game launched on the application.
/// </summary>
/// <returns>A Game.</returns>
public Game LoadGame() public Game LoadGame()
{ {
var serializer = new DataContractSerializer(typeof(Game)); var serializer = new DataContractSerializer(typeof(Game));
@ -33,4 +43,5 @@ public class GamePersistenceXml : IGamePersistence
return new Game(); return new Game();
} }
} }
}
} }

@ -1,10 +1,17 @@
using System.Runtime.Serialization.Json; using System.Runtime.Serialization.Json;
using QwirkleClassLibrary.Players; using QwirkleClassLibrary.Players;
namespace QwirkleClassLibrary.Persistences; namespace QwirkleClassLibrary.Persistences
public class LeaderboardPersistenceJson : ILeaderboardPersistence
{ {
/// <summary>
/// This is the persistence class for the leaderboard : it is in charge of managing all the parameters necessary for the backup and recovery of data concerning the leaderboard.
/// </summary>
public class LeaderboardPersistenceJson : ILeaderboardPersistence
{
/// <summary>
/// As the name suggest, this class is used to save the data from the leaderboard.
/// </summary>
/// <param name="leaderboard">The current leaderboard we want to save data from.</param>
public void SaveLeaderboard(Leaderboard leaderboard) public void SaveLeaderboard(Leaderboard leaderboard)
{ {
var serializer = new DataContractJsonSerializer(typeof(Leaderboard)); var serializer = new DataContractJsonSerializer(typeof(Leaderboard));
@ -14,7 +21,11 @@ public class LeaderboardPersistenceJson : ILeaderboardPersistence
serializer.WriteObject(writer, leaderboard); serializer.WriteObject(writer, leaderboard);
} }
} }
/// <summary>
/// This method is used to load the leaderboard into the app when the application starts.
/// </summary>
/// <returns>Leaderboard</returns>
/// <exception cref="InvalidOperationException"></exception>
public Leaderboard LoadLeaderboard() public Leaderboard LoadLeaderboard()
{ {
var serializer = new DataContractJsonSerializer(typeof(Leaderboard)); var serializer = new DataContractJsonSerializer(typeof(Leaderboard));
@ -24,4 +35,5 @@ public class LeaderboardPersistenceJson : ILeaderboardPersistence
return serializer.ReadObject(reader) as Leaderboard ?? throw new InvalidOperationException(); return serializer.ReadObject(reader) as Leaderboard ?? throw new InvalidOperationException();
} }
} }
}
} }
Loading…
Cancel
Save