|
|
|
@ -12,6 +12,7 @@ namespace CoreLibrary.Regles
|
|
|
|
|
private int nbJoueurs = 0;
|
|
|
|
|
private int? joueurCourant;
|
|
|
|
|
private readonly Joueur[] joueurs;
|
|
|
|
|
private readonly Plateau[] plateaux;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Le nom des règles.
|
|
|
|
@ -46,6 +47,7 @@ namespace CoreLibrary.Regles
|
|
|
|
|
public ReglesClassiques()
|
|
|
|
|
{
|
|
|
|
|
joueurs = new Joueur[NbJoueursMaximum];
|
|
|
|
|
plateaux = new Plateau[NbJoueursMaximum];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -55,8 +57,9 @@ namespace CoreLibrary.Regles
|
|
|
|
|
/// <returns>Le joueur ajouté.</returns>
|
|
|
|
|
public Joueur AjouterJoueur(string nom)
|
|
|
|
|
{
|
|
|
|
|
Joueur joueur = new Joueur(nom, new Plateau(TailleCodeMaximum, TourMaximum));
|
|
|
|
|
joueurs[nbJoueurs++] = joueur;
|
|
|
|
|
Joueur joueur = new Joueur(nom);
|
|
|
|
|
joueurs[nbJoueurs] = joueur;
|
|
|
|
|
plateaux[nbJoueurs++] = new Plateau(TailleCodeMaximum, TourMaximum);
|
|
|
|
|
return joueur;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -66,12 +69,12 @@ namespace CoreLibrary.Regles
|
|
|
|
|
/// <returns>Le joueur actuel.</returns>
|
|
|
|
|
/// <exception cref="PartieNonCommenceeException">Levée lorsque la partie n'a pas commencée.</exception>
|
|
|
|
|
|
|
|
|
|
public Joueur JoueurCourant()
|
|
|
|
|
public (Joueur, Plateau) JoueurCourant()
|
|
|
|
|
{
|
|
|
|
|
if (!joueurCourant.HasValue)
|
|
|
|
|
throw new PartieNonCommenceeException();
|
|
|
|
|
|
|
|
|
|
return joueurs[joueurCourant.Value];
|
|
|
|
|
return (joueurs[joueurCourant.Value], plateaux[joueurCourant.Value]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -120,12 +123,12 @@ namespace CoreLibrary.Regles
|
|
|
|
|
if (!joueurCourant.HasValue || joueurCourant != 0)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (JoueurCourant().Plateau.Tour > TourMaximum)
|
|
|
|
|
if (JoueurCourant().Item2.Tour > TourMaximum)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < joueurs.Length; ++i)
|
|
|
|
|
{
|
|
|
|
|
if (joueurs[i].Plateau.Victoire)
|
|
|
|
|
if (plateaux[i].Victoire)
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -141,7 +144,7 @@ namespace CoreLibrary.Regles
|
|
|
|
|
Joueur[] gagnants = [];
|
|
|
|
|
for (int i = 0; i < joueurs.Length; ++i)
|
|
|
|
|
{
|
|
|
|
|
if (joueurs[i].Plateau.Victoire)
|
|
|
|
|
if (plateaux[i].Victoire)
|
|
|
|
|
{
|
|
|
|
|
gagnants = gagnants.Append(joueurs[i]).ToArray();
|
|
|
|
|
}
|
|
|
|
@ -159,7 +162,7 @@ namespace CoreLibrary.Regles
|
|
|
|
|
Joueur[] perdants = [];
|
|
|
|
|
for (int i = 0; i < joueurs.Length; ++i)
|
|
|
|
|
{
|
|
|
|
|
if (!joueurs[i].Plateau.Victoire)
|
|
|
|
|
if (!plateaux[i].Victoire)
|
|
|
|
|
{
|
|
|
|
|
perdants = perdants.Append(joueurs[i]).ToArray();
|
|
|
|
|
}
|
|
|
|
|