oublie point virgule
continuous-integration/drone/push Build is failing Details

master
Céleste BARBOSA 1 year ago
parent ff4edfe0e4
commit 9d0deda4af

@ -1,114 +1,114 @@
using CoreLibrary.Exceptions; using CoreLibrary.Exceptions;
namespace CoreLibrary namespace CoreLibrary
{ {
public class ReglesClassiques : IRegles public class ReglesClassiques : IRegles
{ {
private int nbJoueurs = 0; private int nbJoueurs = 0;
private int? joueurCourant; private int? joueurCourant;
private readonly Joueur[] joueurs; private readonly Joueur[] joueurs;
public string Nom { get => "Règles classiques"; } public string Nom { get => "Règles classiques"; }
public int TourMaximum { get => 12; } public int TourMaximum { get => 12; }
public int TailleCodeMaximum { get => 4; } public int TailleCodeMaximum { get => 4; }
public int NbJoueurs { get => nbJoueurs; } public int NbJoueurs { get => nbJoueurs; }
public int NbJoueursMaximum { get => 2; } public int NbJoueursMaximum { get => 2; }
public ReglesClassiques() public ReglesClassiques()
{ {
joueurs = new Joueur[NbJoueursMaximum]; joueurs = new Joueur[NbJoueursMaximum];
} }
public Joueur AjouterJoueur(string nom) public Joueur AjouterJoueur(string nom)
{ {
Joueur joueur = new Joueur(nom, new Plateau(TailleCodeMaximum, TourMaximum)) Joueur joueur = new Joueur(nom, new Plateau(TailleCodeMaximum, TourMaximum));
joueurs[nbJoueurs++] = joueur; joueurs[nbJoueurs++] = joueur;
return joueur; return joueur;
} }
public Joueur JoueurCourant() public Joueur JoueurCourant()
{ {
if (!joueurCourant.HasValue) if (!joueurCourant.HasValue)
throw new PartieNonCommenceeException(); throw new PartieNonCommenceeException();
return joueurs[joueurCourant.Value]; return joueurs[joueurCourant.Value];
} }
public void PasserLaMain() public void PasserLaMain()
{ {
if (!joueurCourant.HasValue) if (!joueurCourant.HasValue)
{ {
throw new PartieNonCommenceeException(); throw new PartieNonCommenceeException();
} }
joueurCourant++; joueurCourant++;
if (joueurCourant >= joueurs.Length) if (joueurCourant >= joueurs.Length)
{ {
joueurCourant = 0; joueurCourant = 0;
} }
} }
public Code GenererCode() public Code GenererCode()
{ {
return new Code(TailleCodeMaximum); return new Code(TailleCodeMaximum);
} }
public void CommencerLaPartie() public void CommencerLaPartie()
{ {
joueurCourant = 0; joueurCourant = 0;
} }
public bool EstTerminee() public bool EstTerminee()
{ {
if (!joueurCourant.HasValue || joueurCourant != 0) if (!joueurCourant.HasValue || joueurCourant != 0)
return false; return false;
if (JoueurCourant().Plateau.Tour > TourMaximum) if (JoueurCourant().Plateau.Tour > TourMaximum)
return true; return true;
for (int i = 0; i < joueurs.Length; ++i) for (int i = 0; i < joueurs.Length; ++i)
{ {
if (joueurs[i].Plateau.Victoire) if (joueurs[i].Plateau.Victoire)
return true; return true;
} }
return false; return false;
} }
public IEnumerable<Joueur> Gagnants() public IEnumerable<Joueur> Gagnants()
{ {
Joueur[] gagnants = []; Joueur[] gagnants = [];
for (int i = 0; i < joueurs.Length; ++i) for (int i = 0; i < joueurs.Length; ++i)
{ {
if (joueurs[i].Plateau.Victoire) if (joueurs[i].Plateau.Victoire)
{ {
gagnants = gagnants.Append(joueurs[i]).ToArray(); gagnants = gagnants.Append(joueurs[i]).ToArray();
} }
} }
return gagnants; return gagnants;
} }
public IEnumerable<Joueur> Perdants() public IEnumerable<Joueur> Perdants()
{ {
Joueur[] perdants = []; Joueur[] perdants = [];
for (int i = 0; i < joueurs.Length; ++i) for (int i = 0; i < joueurs.Length; ++i)
{ {
if (!joueurs[i].Plateau.Victoire) if (!joueurs[i].Plateau.Victoire)
{ {
perdants = perdants.Append(joueurs[i]).ToArray(); perdants = perdants.Append(joueurs[i]).ToArray();
} }
} }
return perdants; return perdants;
} }
} }
} }

Loading…
Cancel
Save