using CoreLibrary.Events; namespace CoreLibrary { public class Partie { private IRegles regles; public event EventHandler ajouterJoueur; public event EventHandler debutPartie; public event EventHandler nouveauTour; public event EventHandler ajouterJeton; public event EventHandler ajouterCode; public event EventHandler passerMain; public event EventHandler 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 gagnants, IEnumerable perdants) => partieTerminee?.Invoke(this, new PartieTermineeEventArgs(gagnants, perdants)); public Partie(IRegles regles) { this.regles = regles; } public void Jouer() { DefinirJoueurs(); regles.CommencerLaPartie(); QuandDebutPartie(); while (!regles.EstTerminee()) { Joueur joueurCourant = regles.JoueurCourant(); Plateau plateauCourant = joueurCourant.Plateau; QuandNouveauTour(joueurCourant, plateauCourant.Tour); Code code = regles.GenererCode(); while (!code.EstComplet()) { 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() { while(regles.NbJoueurs != regles.NbJoueursMaximum) { string nom = "pauline"; regles.AjouterJoueur(nom); //QuandAjouterJoueur() } } private void PartieTerminee() { regles.Gagnants(); regles.Perdants(); } } }