|
|
@ -13,24 +13,24 @@ namespace CoreLibrary
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public event EventHandler<PartieDemanderJoueurEventArgs>? PartieDemanderJoueur;
|
|
|
|
public event EventHandler<PartieDemanderJoueurEventArgs>? PartieDemanderJoueur;
|
|
|
|
public event EventHandler<PartieDebutPartieEventArgs>? PartieDebutPartie;
|
|
|
|
public event EventHandler<PartieDebutPartieEventArgs>? PartieDebutPartie;
|
|
|
|
public event EventHandler<PartieNouveauTourEventArgs>? PartieNouveauTour;
|
|
|
|
public event EventHandler<PartieDemanderJoueurJouerEventArgs>? PartieDemanderJoueurJouer;
|
|
|
|
public event EventHandler<PartiePasserLaMainEventArgs>? PartiePasserLaMain;
|
|
|
|
public event EventHandler<PartiePasserLaMainEventArgs>? PartiePasserLaMain;
|
|
|
|
public event EventHandler<PartiePartieTermineeEventArgs>? PartiePartieTerminee;
|
|
|
|
public event EventHandler<PartiePartieTermineeEventArgs>? PartiePartieTerminee;
|
|
|
|
|
|
|
|
|
|
|
|
private void QuandPartieDemanderJoueur(Joueur joueurDemande) => PartieDemanderJoueur?.Invoke(this, new PartieDemanderJoueurEventArgs(joueurs.Count + 1, joueurDemande));
|
|
|
|
private void QuandPartieDemanderJoueur(Joueur joueurDemande) => PartieDemanderJoueur?.Invoke(this, new PartieDemanderJoueurEventArgs(joueurs.Count + 1, joueurDemande));
|
|
|
|
private void QuandPartieDebutPartie() => PartieDebutPartie?.Invoke(this, new PartieDebutPartieEventArgs());
|
|
|
|
private void QuandPartieDebutPartie() => PartieDebutPartie?.Invoke(this, new PartieDebutPartieEventArgs());
|
|
|
|
private void QuandPartieNouveauTour() => PartieNouveauTour?.Invoke(this, new PartieNouveauTourEventArgs(Tour, joueurs.ElementAt(courant), plateaux.ElementAt(courant), new Code(Regles.TailleCode)));
|
|
|
|
private void QuandPartieDemanderJoueurJouer() => PartieDemanderJoueurJouer?.Invoke(this, new PartieDemanderJoueurJouerEventArgs(Tour, Joueurs.ElementAt(courant), plateaux.ElementAt(courant), new Code(Regles.TailleCode), joueurs[Joueurs.ElementAt(courant)]));
|
|
|
|
private void QuandPartiePasserLaMain() => PartiePasserLaMain?.Invoke(this, new PartiePasserLaMainEventArgs(joueurs.ElementAt(courant)));
|
|
|
|
private void QuandPartiePasserLaMain() => PartiePasserLaMain?.Invoke(this, new PartiePasserLaMainEventArgs(Joueurs.ElementAt(courant)));
|
|
|
|
private void QuandPartiePartieTerminee(IReadOnlyList<string> gagnants, IReadOnlyList<string> perdants) => PartiePartieTerminee?.Invoke(this, new PartiePartieTermineeEventArgs(gagnants, perdants));
|
|
|
|
private void QuandPartiePartieTerminee(IReadOnlyList<string> gagnants, IReadOnlyList<string> perdants) => PartiePartieTerminee?.Invoke(this, new PartiePartieTermineeEventArgs(gagnants, perdants));
|
|
|
|
|
|
|
|
|
|
|
|
[DataMember]
|
|
|
|
[DataMember]
|
|
|
|
private readonly List<string> joueurs = new List<string>();
|
|
|
|
private readonly Dictionary<string, bool> joueurs = new Dictionary<string, bool>();
|
|
|
|
[DataMember]
|
|
|
|
[DataMember]
|
|
|
|
private readonly List<Plateau> plateaux = new List<Plateau>();
|
|
|
|
private readonly List<Plateau> plateaux = new List<Plateau>();
|
|
|
|
[DataMember]
|
|
|
|
[DataMember]
|
|
|
|
private int courant = 0;
|
|
|
|
private int courant = 0;
|
|
|
|
|
|
|
|
|
|
|
|
public IReadOnlyList<string> Joueurs => joueurs;
|
|
|
|
public IReadOnlyList<string> Joueurs => joueurs.Keys.ToList();
|
|
|
|
[DataMember]
|
|
|
|
[DataMember]
|
|
|
|
public bool Termine { get; private set; } = false;
|
|
|
|
public bool Termine { get; private set; } = false;
|
|
|
|
[DataMember]
|
|
|
|
[DataMember]
|
|
|
@ -54,7 +54,7 @@ namespace CoreLibrary
|
|
|
|
|
|
|
|
|
|
|
|
partie.PartieDemanderJoueur = null;
|
|
|
|
partie.PartieDemanderJoueur = null;
|
|
|
|
partie.PartieDebutPartie = null;
|
|
|
|
partie.PartieDebutPartie = null;
|
|
|
|
partie.PartieNouveauTour = null;
|
|
|
|
partie.PartieDemanderJoueurJouer = null;
|
|
|
|
partie.PartiePasserLaMain = null;
|
|
|
|
partie.PartiePasserLaMain = null;
|
|
|
|
partie.PartiePartieTerminee = null;
|
|
|
|
partie.PartiePartieTerminee = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -77,9 +77,11 @@ namespace CoreLibrary
|
|
|
|
|
|
|
|
|
|
|
|
private void JoueurConnecte(object? sender, JoueurSeConnecterEventArgs e)
|
|
|
|
private void JoueurConnecte(object? sender, JoueurSeConnecterEventArgs e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
joueurs.Add(e.Nom);
|
|
|
|
joueurs.Add(e.Joueur.Nom, e.Joueur.GetType().Equals(typeof(Joueur)));
|
|
|
|
plateaux.Add(new Plateau(Regles.TailleCode, Regles.NbTour));
|
|
|
|
plateaux.Add(new Plateau(Regles.TailleCode, Regles.NbTour));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
e.Joueur.JouerPartie(this);
|
|
|
|
|
|
|
|
|
|
|
|
if (joueurs.Count < Regles.NbJoueurs)
|
|
|
|
if (joueurs.Count < Regles.NbJoueurs)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DemanderJoueur();
|
|
|
|
DemanderJoueur();
|
|
|
@ -107,7 +109,7 @@ namespace CoreLibrary
|
|
|
|
|
|
|
|
|
|
|
|
private void NouveauTour()
|
|
|
|
private void NouveauTour()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QuandPartieNouveauTour();
|
|
|
|
QuandPartieDemanderJoueurJouer();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void PlateauAjouterCode(object? sender, PlateauAjouterCodeEventArgs e)
|
|
|
|
private void PlateauAjouterCode(object? sender, PlateauAjouterCodeEventArgs e)
|
|
|
@ -142,9 +144,9 @@ namespace CoreLibrary
|
|
|
|
for (int i = 0; i < joueurs.Count; ++i)
|
|
|
|
for (int i = 0; i < joueurs.Count; ++i)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (plateaux.ElementAt(i).Victoire)
|
|
|
|
if (plateaux.ElementAt(i).Victoire)
|
|
|
|
gagnants.Add(joueurs[i]);
|
|
|
|
gagnants.Add(Joueurs[i]);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
perdants.Add(joueurs[i]);
|
|
|
|
perdants.Add(Joueurs[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QuandPartiePartieTerminee(gagnants, perdants);
|
|
|
|
QuandPartiePartieTerminee(gagnants, perdants);
|
|
|
|