annulation de l'autorisation des doublons
This commit is contained in:
parent
2214cf4a05
commit
1987905eb9
@ -101,12 +101,7 @@ class Grille implements Iterator, ArrayAccess {
|
|||||||
if ($x == $this->largeur - 1) {
|
if ($x == $this->largeur - 1) {
|
||||||
foreach (explode(" ", $this->get_ligne($y, $this->largeur)) as $rang => $mot) {
|
foreach (explode(" ", $this->get_ligne($y, $this->largeur)) as $rang => $mot) {
|
||||||
if (strlen($mot) == 1) continue;
|
if (strlen($mot) == 1) continue;
|
||||||
$nb_definitions = count($dico[strlen($mot)][$mot]);
|
if (in_array($mot, array_merge(...$this->lignes, ...$this->colonnes))) continue 2;
|
||||||
$occurences = 1;
|
|
||||||
foreach (array_merge(...$this->lignes, ...$this->colonnes) as $mot2) {
|
|
||||||
if ($mot != $mot2) continue;
|
|
||||||
if (++$occurences >= $nb_definitions) continue 3;
|
|
||||||
}
|
|
||||||
$this->lignes[$y][$rang] = $mot;
|
$this->lignes[$y][$rang] = $mot;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -51,7 +51,7 @@ foreach ($grille->lignes as $y => $mots) {
|
|||||||
foreach ($mots as $mot) {
|
foreach ($mots as $mot) {
|
||||||
$definitions = $dico[strlen($mot)][$mot];
|
$definitions = $dico[strlen($mot)][$mot];
|
||||||
if (count($definitions)) {
|
if (count($definitions)) {
|
||||||
$definitions_horizontales[$y][] = array_pop($definitions);
|
$definitions_horizontales[$y][] = $definitions[mt_rand(0, count($definitions) - 1)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -61,7 +61,7 @@ foreach ($grille->colonnes as $x => $mots) {
|
|||||||
foreach ($mots as $mot) {
|
foreach ($mots as $mot) {
|
||||||
$definitions = $dico[strlen($mot)][$mot];
|
$definitions = $dico[strlen($mot)][$mot];
|
||||||
if (count($definitions)) {
|
if (count($definitions)) {
|
||||||
$definitions_verticales[$x][] = array_pop($definitions);
|
$definitions_verticales[$x][] = $definitions[mt_rand(0, count($definitions) - 1)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user