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>
/// 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>
/// <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()
{
foreach (var cell in cells)

@ -4,14 +4,15 @@ using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using QwirkleClassLibrary.Tiles;
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
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
{
public event PropertyChangedEventHandler? PropertyChanged;
[DataMember]
@ -21,7 +22,7 @@ public class Cell : INotifyPropertyChanged
private readonly int y;
[DataMember]
public Tile? Tile { get; private set;}
public Tile? Tile { get; private set; }
/// <summary>
/// This is the constructor for a Cell.
@ -59,7 +60,7 @@ public class Cell : INotifyPropertyChanged
}
/// <summary>
/// Check if the Cell whether is empty or contains a tile.
/// Checks if the Cell whether is empty or contains a tile.
/// </summary>
/// <returns>True if the cell is empty, false if the cell contains a tile.</returns>
public bool IsFree
@ -92,4 +93,5 @@ public class Cell : INotifyPropertyChanged
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}

@ -122,7 +122,12 @@ namespace QwirkleClassLibrary.Games
OnPlayerNotified(new AddPlayerNotifiedEventArgs("Players were correctly added."));
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)
{
if (string.IsNullOrWhiteSpace(playersTag[pos]))

@ -3,13 +3,14 @@ using QwirkleClassLibrary.Boards;
using QwirkleClassLibrary.Players;
using QwirkleClassLibrary.Tiles;
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
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
{
public Player CreatePlayer(string playerTag);
public string SetNextPlayer();
@ -29,4 +30,5 @@ public interface IPlayer
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);
}
}

@ -1,10 +1,17 @@
using System.Runtime.Serialization;
using QwirkleClassLibrary.Games;
namespace QwirkleClassLibrary.Persistences;
public class GamePersistenceXml : IGamePersistence
namespace QwirkleClassLibrary.Persistences
{
/// <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)
{
var serializer = new DataContractSerializer(typeof(Game),
@ -15,7 +22,10 @@ public class GamePersistenceXml : IGamePersistence
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()
{
var serializer = new DataContractSerializer(typeof(Game));
@ -33,4 +43,5 @@ public class GamePersistenceXml : IGamePersistence
return new Game();
}
}
}
}

@ -1,10 +1,17 @@
using System.Runtime.Serialization.Json;
using QwirkleClassLibrary.Players;
namespace QwirkleClassLibrary.Persistences;
public class LeaderboardPersistenceJson : ILeaderboardPersistence
namespace QwirkleClassLibrary.Persistences
{
/// <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)
{
var serializer = new DataContractJsonSerializer(typeof(Leaderboard));
@ -14,7 +21,11 @@ public class LeaderboardPersistenceJson : ILeaderboardPersistence
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()
{
var serializer = new DataContractJsonSerializer(typeof(Leaderboard));
@ -24,4 +35,5 @@ public class LeaderboardPersistenceJson : ILeaderboardPersistence
return serializer.ReadObject(reader) as Leaderboard ?? throw new InvalidOperationException();
}
}
}
}
Loading…
Cancel
Save