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.
41 lines
1.3 KiB
41 lines
1.3 KiB
<?php
|
|
class PartieFactory{
|
|
public static function createPartieMulti($newId,$tabEnigme) : Partie
|
|
{
|
|
if (count($tabEnigme)==0)
|
|
return new Partie($newId,array());
|
|
$tempsResolutionPartie=0;
|
|
$tabIndex=range(0,count($tabEnigme));
|
|
$randomNumber=0;
|
|
$tabEnigmePartie = array();
|
|
while($tempsResolutionPartie <= 30)
|
|
{
|
|
$randomNumber=$tabIndex[array_rand($tabIndex)];
|
|
$tabEnigmePartie[]=$tabEnigme[$randomNumber];
|
|
$TempsResolutionPartie+=$tabEnigme[$randomNumber]->getTempsDeResolution();
|
|
unset($tabIndex[$randomNumber]);
|
|
}
|
|
$partie=new Partie($newId,$tabEnigme);
|
|
return $partie;
|
|
}
|
|
|
|
public static function createPartieSolo($idMax,$resultsEnigme) : Partie
|
|
{
|
|
$tabEnigme=array();
|
|
foreach($resultsEnigme as $row)
|
|
{
|
|
$tabEnigme[]=EnigmeFactory::create($row);
|
|
}
|
|
$partie=new Partie($idMax+1,$tabEnigme);
|
|
return $partie;
|
|
}
|
|
public static function createPartieHistory($id,$resultsEnigme) : Partie
|
|
{
|
|
foreach($resultsEnigme as $row)
|
|
{
|
|
$tabEnigme[]=EnigmeFactory::create($row);
|
|
}
|
|
$partie=new Partie($id,$tabEnigme);
|
|
return $partie;
|
|
}
|
|
} |