ruc
This commit is contained in:
21
Grille.php
21
Grille.php
@@ -104,11 +104,16 @@ class Grille implements ArrayAccess
|
|||||||
$this->definitions["horizontales"][$y] = [];
|
$this->definitions["horizontales"][$y] = [];
|
||||||
foreach($mots as $mot) {
|
foreach($mots as $mot) {
|
||||||
$definitions = $this->dico[$mot["longueur"]][$mot["mot"]];
|
$definitions = $this->dico[$mot["longueur"]][$mot["mot"]];
|
||||||
var_dump($definitions);
|
|
||||||
if (count($definitions)) {
|
if (count($definitions)) {
|
||||||
$definition = $definitions[mt_rand(0, count($definitions) - 1)];
|
$definition = $definitions[mt_rand(0, count($definitions) - 1)];
|
||||||
if (isset($definition["definition"])) $mot["definition"] = $definition["definition"];
|
if (is_array($definition)) {
|
||||||
if (isset($definition["auteur"])) $mot["auteur"] = $definition["auteur"];
|
foreach ($definition as $auteur => $def) {
|
||||||
|
$mot["definition"] = $def;
|
||||||
|
$mot["auteur"] = $auteur;
|
||||||
|
}
|
||||||
|
} else if (is_string($definition)) {
|
||||||
|
$mot["definition"] = $definition;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (isset($definitions["nb_mots"])) {
|
if (isset($definitions["nb_mots"])) {
|
||||||
$mot["nb_mots"] = $definitions["nb_mots"];
|
$mot["nb_mots"] = $definitions["nb_mots"];
|
||||||
@@ -124,8 +129,14 @@ class Grille implements ArrayAccess
|
|||||||
$definitions = $this->dico[$mot["longueur"]][$mot["mot"]];
|
$definitions = $this->dico[$mot["longueur"]][$mot["mot"]];
|
||||||
if (count($definitions)) {
|
if (count($definitions)) {
|
||||||
$definition = $definitions[mt_rand(0, count($definitions) - 1)];
|
$definition = $definitions[mt_rand(0, count($definitions) - 1)];
|
||||||
if (isset($definition["definition"])) $mot["definition"] = $definition["definition"];
|
if (is_array($definition)) {
|
||||||
if (isset($definition["auteur"])) $mot["auteur"] = $definition["auteur"];
|
foreach ($definition as $auteur => $def) {
|
||||||
|
$mot["definition"] = $def;
|
||||||
|
$mot["auteur"] = $auteur;
|
||||||
|
}
|
||||||
|
} else if (is_string($definition)) {
|
||||||
|
$mot["definition"] = $definition;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (isset($definitions["nb_mots"])) {
|
if (isset($definitions["nb_mots"])) {
|
||||||
$mot["nb_mots"] = $definitions["nb_mots"];
|
$mot["nb_mots"] = $definitions["nb_mots"];
|
||||||
|
|||||||
11
dico.php
11
dico.php
@@ -30,17 +30,8 @@ function dico($longueur_max) {
|
|||||||
|
|
||||||
if (strlen($mot) > $longueur_max) continue;
|
if (strlen($mot) > $longueur_max) continue;
|
||||||
|
|
||||||
$dico[strlen($mot)][$mot] = [];
|
$dico[strlen($mot)][$mot] = $definitions;
|
||||||
if ($nb_mots > 1) $dico[strlen($mot)][$mot]["nb_mots"] = $nb_mots;
|
if ($nb_mots > 1) $dico[strlen($mot)][$mot]["nb_mots"] = $nb_mots;
|
||||||
foreach ($definitions as $definition) {
|
|
||||||
if (is_array($definition)) {
|
|
||||||
foreach ($definition as $auteur => $def) {
|
|
||||||
$dico[strlen($mot)][$mot][] = ["auteur" => $auteur, "definition" => $def];
|
|
||||||
}
|
|
||||||
} else if (is_string($definition)) {
|
|
||||||
$dico[strlen($mot)][$mot][] = ["definition" => $definition];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $dico;
|
return $dico;
|
||||||
|
|||||||
Reference in New Issue
Block a user