Ajout des DataContract & DataMembers pour la persistance.

pull/100/head
Rémi LAVERGNE 1 year ago
parent 49ed6ac387
commit f8e7dc1d24

@ -1,14 +1,18 @@
namespace Models.Game
using System.Runtime.Serialization;
namespace Models.Game
{
/// <summary>
/// The Cell class represents a cell in the application.
/// </summary>
[DataContract]
public class Cell : Position, IEquatable<Cell>
{
/// <summary>
/// The value of the cell.
/// </summary>
private int? _value;
[DataMember]
public int? Value {
get => _value;
set
@ -24,14 +28,17 @@
/// <summary>
/// The fact that the cell is dangerous or not.
/// </summary>
[DataMember]
public bool IsDangerous { get; set; }
[DataMember]
public bool Valid { get; set; }
/// <summary>
/// Atribute to know if the cell is a penalty cell.
/// </summary>
[DataMember]
private bool Penalty { get; set; }
/// <summary>

@ -5,6 +5,7 @@ using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;
@ -19,6 +20,7 @@ namespace Models.Game
/// The Game class represents a game session in the application.
/// It contains all the necessary properties and methods to manage a game, including the game loop, dice rolling, and use of the game rules.
/// </summary>
[DataContract]
public class Game : INotifyPropertyChanged
{
/* Persistence */
@ -74,19 +76,24 @@ namespace Models.Game
}
private bool _isRunning;
[DataMember]
public bool IsRunning
{
get => _isRunning;
private set => _isRunning = value;
}
public Player CurrentPlayer { get; private set; }
[DataMember]
public Player? CurrentPlayer { get; private set; }
public Map UsedMap { get; private set; }
[DataMember]
public Map? UsedMap { get; private set; }
public Dice Dice1 { get; private set;}
public Dice Dice2 { get; private set; }
[DataMember]
public int Turn { get; private set; }
public Rules.Rules GameRules { get; }

@ -1,4 +1,5 @@
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
namespace Models.Game
{
@ -6,33 +7,39 @@ namespace Models.Game
/// <summary>
/// The Map class is the representation of the game map with the board and the operations table.
/// </summary>
[DataContract]
public class Map
{
/// <summary>
/// It is the list of cells on the map.
/// </summary>
[DataMember]
public ReadOnlyObservableCollection<Cell> Boards { get; private set; }
ObservableCollection<Cell> board = new ObservableCollection<Cell>();
/// <summary>
/// It is the backgrond image of the map
/// </summary>
[DataMember]
public string Background { get; private set; }
/// <summary>
/// It is the grid of the possible operation in the game
/// </summary>
[DataMember]
public ReadOnlyObservableCollection<OperationCell> OperationGrid { get; private set; }
ObservableCollection<OperationCell> operationGrid = new ObservableCollection<OperationCell>();
/// <summary>
/// It is a list of a list containing user's rope paths in the current game
/// </summary>
[DataMember]
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>
[DataMember]
public List<List<Cell>> Zones { get; private set; }
/// <summary>

@ -1,15 +1,18 @@
using System.ComponentModel;
using System.Runtime.Serialization;
namespace Models.Game
{
/// <summary>
/// Represents a cell in the operation grid of the game.
/// </summary>
[DataContract]
public class OperationCell : Position
{
/// <summary>
/// It tells if the operation is checked or not in the operation grid of the game.
/// </summary>
[DataMember]
public bool IsChecked { get; private set; }
/// <summary>

@ -1,5 +1,6 @@
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
namespace Models.Game
{
@ -7,16 +8,19 @@ namespace Models.Game
/// <summary>
/// The Position (x,y) of a cell in the game.
/// </summary>
[DataContract]
public class Position
{
/// <summary>
/// The X coordinate.
/// </summary>
[DataMember]
public int X { get; set; }
/// <summary>
/// The Y coordinate.
/// </summary>
[DataMember]
public int Y { get; set; }
/// <summary>

Loading…
Cancel
Save