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

@ -5,6 +5,7 @@ using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow; using System.Threading.Tasks.Dataflow;
@ -19,6 +20,7 @@ namespace Models.Game
/// The Game class represents a game session in the application. /// 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. /// 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> /// </summary>
[DataContract]
public class Game : INotifyPropertyChanged public class Game : INotifyPropertyChanged
{ {
/* Persistence */ /* Persistence */
@ -74,19 +76,24 @@ namespace Models.Game
} }
private bool _isRunning; private bool _isRunning;
[DataMember]
public bool IsRunning public bool IsRunning
{ {
get => _isRunning; get => _isRunning;
private set => _isRunning = value; 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 Dice1 { get; private set;}
public Dice Dice2 { get; private set; } public Dice Dice2 { get; private set; }
[DataMember]
public int Turn { get; private set; } public int Turn { get; private set; }
public Rules.Rules GameRules { get; } public Rules.Rules GameRules { get; }

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

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

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

Loading…
Cancel
Save