Skip to content
Snippets Groups Projects
Commit 74d6c97e authored by thest's avatar thest
Browse files

Implementation de la partie

parent f8a825cb
No related merge requests found
......@@ -6,16 +6,20 @@ using System.Text;
namespace fichier1.Model
{
public class Partie : IObservable<MainForm>
public class Partie : IObservable<Partie>
{
private List<string[]> correction;
private List<string[]> decoupage;
private int motCourant;
private readonly BddContext context;
private List<IObserver<Partie>> observers;
public int nbMots;
public Partie(int nbMots, float complexite, BddContext context)
{
this.nbMots = nbMots;
this.context = context;
this.observers = new List<IObserver<Partie>>();
}
public void genererMots(int nb, float complexite)
......@@ -41,42 +45,70 @@ namespace fichier1.Model
public void formaterPropositions()
{
decoupage = new List<string[]>();
for (int i = 0; i < correction.Count; i++)
{
string mot = "";
for (int j = 0; j < correction[i].Length; j++)
{
mot += correction[i][j];
}
string[] m = new string[1];
m[0] = mot;
decoupage.Add(m);
}
}
public string[] getMot(int nb)
{
return null;
return decoupage[nb];
}
public void setMot(int nb, string[] mot)
{
decoupage[nb] = mot;
}
public int compterPoints()
{
// TODO:
return 0;
}
public string[] getCorrection(int nb)
{
return null;
return correction[nb];
}
public string[] getMotCourant()
{
return null;
return getMot(motCourant);
}
public void validerMotCourant(string[] mot)
{
setMot(motCourant, mot);
motCourant++;
if (motCourant < correction.Count)
{
foreach(IObserver<Partie> obs in observers)
{
obs.OnNext(this);
}
}
else
{
foreach (IObserver<Partie> obs in observers)
{
obs.OnCompleted();
}
}
}
public IDisposable Subscribe(IObserver<MainForm> observer)
public IDisposable Subscribe(IObserver<Partie> observer)
{
throw new NotImplementedException();
observers.Add(observer);
return null;
}
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment