You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.0 KiB
79 lines
2.0 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace BibliothequeClasses
|
|
{
|
|
/// <summary>
|
|
/// Représente une partie du jeu.
|
|
/// </summary>
|
|
public class Partie
|
|
{
|
|
private int tour;
|
|
private Joueur joueur1;
|
|
private Joueur joueur2;
|
|
private Joueur joueurCourant;
|
|
|
|
/// <summary>
|
|
/// Initialise une nouvelle instance de la classe Partie avec les noms des joueurs.
|
|
/// </summary>
|
|
/// <param name="nomJoueur1">Le nom du premier joueur.</param>
|
|
/// <param name="nomJoueur2">Le nom du deuxième joueur.</param>
|
|
public Partie(string nomJoueur1, string nomJoueur2)
|
|
{
|
|
this.tour = 1;
|
|
this.joueur1 = new Joueur(nomJoueur1);
|
|
this.joueur2 = new Joueur(nomJoueur2);
|
|
this.joueurCourant = this.joueur1;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Récupère le joueur qui joue actuellement.
|
|
/// </summary>
|
|
/// <returns>Le joueur actuel.</returns>
|
|
public Joueur GetJoueur()
|
|
{
|
|
return this.joueurCourant;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Passe la main au prochain joueur.
|
|
/// </summary>
|
|
public void PasserlaMain()
|
|
{
|
|
if (this.joueurCourant == this.joueur1)
|
|
{
|
|
this.joueurCourant = this.joueur2;
|
|
}
|
|
else
|
|
{
|
|
this.joueurCourant = this.joueur1;
|
|
}
|
|
tour++;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Détermine si la partie est terminée.
|
|
/// </summary>
|
|
/// <returns>True si la partie est terminée, sinon False.</returns>
|
|
public bool EstTerminer()
|
|
{
|
|
const int nbMaxTour = 24;
|
|
if (joueurCourant.AGagne())
|
|
{
|
|
return true;
|
|
}
|
|
|
|
if (tour == nbMaxTour)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|