parent
a7e6a152f7
commit
c06c60efa7
@ -1,12 +1,22 @@
|
|||||||
<?php
|
<?php
|
||||||
|
include_once "EnigmeFactory.php";
|
||||||
|
include_once "../Model/Partie.php";
|
||||||
class PartieFactory{
|
class PartieFactory{
|
||||||
public static function create($results)
|
public static function createPartie($idMax,$resultsEnigme) : Partie
|
||||||
{
|
{
|
||||||
$tabPartie=array();
|
$tempsResolutionPartie=0;
|
||||||
foreach($results as $row)
|
$tabEnigme=array();
|
||||||
|
$tabIndex=range(0,strlen($resultsEnigme)-1);
|
||||||
|
$randomNumber=0;
|
||||||
|
while($tempsResolutionPartie <= 30)
|
||||||
{
|
{
|
||||||
$tabPartie= new Partie($row['id']);
|
$randomNumber=$tabIndex[array_rand($tabIndex)];
|
||||||
|
$tabEnigme=EnigmeFactory::create($resultsEnigme[$randomNumber]);
|
||||||
|
$TempsResolutionPartie+=$resultsEnigme[$randomNumber]['tempsDeResolution'];
|
||||||
|
unset($tabIndex[$randomNumber]);
|
||||||
}
|
}
|
||||||
return $tabPartie;
|
$partie=new Partie($idMax,$resultsEnigme);
|
||||||
|
return $partie;
|
||||||
}
|
}
|
||||||
|
//public static function createListePartie()
|
||||||
}
|
}
|
Loading…
Reference in new issue