model pour API et EF
continuous-integration/drone/push Build is failing Details

EF
Zakariya SAOULA 2 years ago
parent 498c18ef13
commit 7a2336e933

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model
{
public class Case
{
public int Valeur
{
get => valeur;
set
{
//pas évolutif car case dangereuse c'est 6 MAX
if (value > 12)
{
throw new ArgumentException("a Case must have a value lower or equal to 12");
}
valeur = value;
}
}
private int valeur;
public Case(int valeur)
{
Valeur = valeur;
}
}
}

@ -1,6 +0,0 @@
namespace Model;
public class Class1
{
}

@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model
{
public class Game
{
public TimeSpan Duration { get; set; }
public DateOnly Date { get; set; }
public ReadOnlyCollection<Player> Players { get; private set; }
private List<Player> players = new();
public ReadOnlyCollection<Turn> Turns { get; private set; }
private List<Turn> turns = new();
public ReadOnlyDictionary<Player, Grille> Grilles { get; private set; }
private readonly Dictionary<Player, Grille> grilles = new Dictionary<Player, Grille>();
public ReadOnlyDictionary<Player, int> Scores { get; private set; }
private readonly Dictionary<Player, int> scores = new Dictionary<Player, int>();
public GameMode GameMode { get; set; }
//public Grille Grille
//{
// get => grille;
// private init
// {
// if (value == null)
// throw new ArgumentNullException("A grid can't be null for a game");
// grille = value;
// }
//}
//private Grille grille;
public Game(TimeSpan duration, DateOnly date, Dictionary<Player,Grille> grilles, Dictionary<Player, int> scores, List<Turn> turns, GameMode gameMode)
{
Players = players.AsReadOnly();
Duration = duration;
Date = date;
Grilles = new ReadOnlyDictionary<Player, Grille>(grilles);
Scores = new ReadOnlyDictionary<Player, int>(scores);
Turns = turns.AsReadOnly();
GameMode = gameMode;
}
}
}

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model
{
public class GameMode
{
public string Name
{
get => name;
set
{
if (value == null)
{
throw new ArgumentException("A GameMode's name cannot be null");
}
name = value;
}
}
private string name = "";
public GameMode(string name)
{
Name = name;
}
}
}

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model
{
public class Grille
{
public int NbChaine { get; set; }
public int NbZone { get; set; }
public int MaxChaine { get; set; }
public int MaxZone { get; set; }
public ReadOnlyCollection<Case> Cases { get; private set; }
private List<Case> cases = new();
public Grille(List<Case> cases)
{
Cases = cases.AsReadOnly();
}
}
}

@ -0,0 +1,39 @@
namespace Model;
//public class Player : IEquatable<Player>
public class Player
{
public string Pseudo
{
get => pseudo;
set
{
if (value == null)
{
pseudo = "";
return;
}
pseudo = value;
}
}
private string pseudo = "";
public Stats Stats { get; set; }
public Player(string pseudo)
{
Pseudo = pseudo;
Stats = new Stats();
}
//nécessaire ?
//public bool Equals(Player? other)
// => Pseudo.Equals(other?.Pseudo);
//997 ou un autre chiffre, à voir
//public override int GetHashCode()
// => Pseudo.GetHashCode() % 997;
//public override string ToString()
// => $"{Pseudo}";
}

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model
{
public class Stats
{
public int NbWin { get; set; } = 0;
public int NbPlayed { get; set; } = 0;
public int MaxChain { get; set; } = 0;
public int MaxZone { get; set; } = 0;
public int MaxPoints { get; set; } = 0;
public Stats()
{
}
public override string ToString()
=> $"{NbWin} {NbPlayed} {MaxChain} {MaxZone} {MaxZone}";
}
}

@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model
{
public class Turn
{
public int DiceValue1
{
get => diceValue1;
set
{
if (value > 6)
{
throw new ArgumentException("a Case must have a value lower or equal to 12");
}
diceValue1 = value;
}
}
private int diceValue1;
public int DiceValue2
{
get => diceValue2;
set
{
if (value > 6)
{
throw new ArgumentException("a Case must have a value lower or equal to 12");
}
diceValue2 = value;
}
}
private int diceValue2;
public Turn(int diceValue1, int diceValue2)
{
DiceValue1 = diceValue1;
DiceValue2 = diceValue2;
}
}
}
Loading…
Cancel
Save