|
|
|
@ -1,9 +1,28 @@
|
|
|
|
|
namespace CoreLibrary
|
|
|
|
|
using CoreLibrary.Events;
|
|
|
|
|
|
|
|
|
|
namespace CoreLibrary
|
|
|
|
|
{
|
|
|
|
|
public class Partie
|
|
|
|
|
{
|
|
|
|
|
private IRegles regles;
|
|
|
|
|
|
|
|
|
|
public event EventHandler<AjouterJoueursEventArgs> ajouterJoueur;
|
|
|
|
|
public event EventHandler<DebutPartieEventArgs> debutPartie;
|
|
|
|
|
public event EventHandler<NouveauTourEventArgs> nouveauTour;
|
|
|
|
|
public event EventHandler<AjouterJetonEventArgs> ajouterJeton;
|
|
|
|
|
public event EventHandler<AjouterCodeEventArgs> ajouterCode;
|
|
|
|
|
public event EventHandler<PasserMainEventArgs> passerMain;
|
|
|
|
|
public event EventHandler<PartieTermineeEventArgs> partieTerminee;
|
|
|
|
|
|
|
|
|
|
private void QuandAjouterJoueur(Joueur joueur) => ajouterJoueur?.Invoke(this, new AjouterJoueursEventArgs(joueur));
|
|
|
|
|
private void QuandDebutPartie() => debutPartie?.Invoke(this, new DebutPartieEventArgs());
|
|
|
|
|
private void QuandNouveauTour(Joueur joueur, int tour) => nouveauTour?.Invoke(this, new NouveauTourEventArgs(joueur, tour));
|
|
|
|
|
private void QuandNouveauJeton(Jeton jeton) => ajouterJeton?.Invoke(this, new AjouterJetonEventArgs(jeton));
|
|
|
|
|
private void QuandNouveauCode(Code code) => ajouterCode?.Invoke(this, new AjouterCodeEventArgs(code));
|
|
|
|
|
private void QuandPasserMain() => passerMain?.Invoke(this, new PasserMainEventArgs());
|
|
|
|
|
private void QuandPartieTerminee(IEnumerable<Joueur> gagnants, IEnumerable<Joueur> perdants) => partieTerminee?.Invoke(this, new PartieTermineeEventArgs(gagnants, perdants));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Partie(IRegles regles)
|
|
|
|
|
{
|
|
|
|
|
this.regles = regles;
|
|
|
|
@ -11,34 +30,41 @@
|
|
|
|
|
|
|
|
|
|
public void Jouer()
|
|
|
|
|
{
|
|
|
|
|
DefinirJoueurs();
|
|
|
|
|
DefinirJoueurs();
|
|
|
|
|
|
|
|
|
|
regles.CommencerLaPartie();
|
|
|
|
|
QuandDebutPartie();
|
|
|
|
|
|
|
|
|
|
while (!regles.EstTerminee())
|
|
|
|
|
{
|
|
|
|
|
Joueur joueurCourant = regles.JoueurCourant();
|
|
|
|
|
Plateau plateauCourant = joueurCourant.Plateau;
|
|
|
|
|
Plateau plateauCourant = joueurCourant.Plateau;
|
|
|
|
|
|
|
|
|
|
QuandNouveauTour(joueurCourant, plateauCourant.Tour);
|
|
|
|
|
|
|
|
|
|
Code code = regles.GenererCode();
|
|
|
|
|
|
|
|
|
|
while (!code.EstComplet())
|
|
|
|
|
{
|
|
|
|
|
AjouterJeton(code);
|
|
|
|
|
AjouterJeton(code);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
plateauCourant.AjouterCode(code);
|
|
|
|
|
QuandNouveauCode(code);
|
|
|
|
|
|
|
|
|
|
regles.PasserLaMain();
|
|
|
|
|
QuandPasserMain();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PartieTerminee();
|
|
|
|
|
|
|
|
|
|
QuandPartieTerminee(regles.Gagnants(), regles.Perdants());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AjouterJeton(Code code)
|
|
|
|
|
{
|
|
|
|
|
Jeton jeton = new Jeton(Couleur.ROUGE);
|
|
|
|
|
code.AjouterJeton(jeton);
|
|
|
|
|
QuandNouveauJeton(jeton);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DefinirJoueurs()
|
|
|
|
@ -47,6 +73,7 @@
|
|
|
|
|
{
|
|
|
|
|
string nom = "pauline";
|
|
|
|
|
regles.AjouterJoueur(nom);
|
|
|
|
|
//QuandAjouterJoueur()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|