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.
Scripted/WEB/Factory/PartieFactory.php

41 lines
1.3 KiB

<?php
include_once "EnigmeFactory.php";
include_once "../Model/Partie.php";
class PartieFactory{
public static function createPartieMulti($idMax,$resultsEnigme) : Partie
{
$tempsResolutionPartie=0;
$tabEnigme=array();
$tabIndex=range(0,strlen($resultsEnigme)-1);
$randomNumber=0;
while($tempsResolutionPartie <= 30)
{
$randomNumber=$tabIndex[array_rand($tabIndex)];
$tabEnigme[]=EnigmeFactory::create($resultsEnigme[$randomNumber]);
$TempsResolutionPartie+=$resultsEnigme[$randomNumber]['tempsDeResolution'];
unset($tabIndex[$randomNumber]);
}
$partie=new Partie($idMax+1,$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;
}
}