truc
This commit is contained in:
42
Grille.php
42
Grille.php
@@ -103,46 +103,20 @@ class Grille implements ArrayAccess
|
||||
$mots = explode_pos(CASE_NOIRE, $this->get_ligne($y, $this->largeur));
|
||||
$this->definitions["horizontales"][$y] = [];
|
||||
foreach($mots as $mot) {
|
||||
$definitions = $this->dico[$mot["longueur"]][$mot["mot"]];
|
||||
if (count($definitions)) {
|
||||
$definition = $definitions[mt_rand(0, count($definitions) - 1)];
|
||||
if (is_array($definition)) {
|
||||
foreach ($definition as $auteur => $def) {
|
||||
$mot["definition"] = $def;
|
||||
$mot["auteur"] = $auteur;
|
||||
}
|
||||
} else if (is_string($definition)) {
|
||||
$mot["definition"] = $definition;
|
||||
}
|
||||
}
|
||||
if (isset($definitions["nb_mots"])) {
|
||||
$mot["nb_mots"] = $definitions["nb_mots"];
|
||||
}
|
||||
unset($mot["mot"]);
|
||||
$this->definitions["horizontales"][$y][] = $mot;
|
||||
$definition = $this->dico[$mot["longueur"]][$mot["mot"]];
|
||||
$definition["debut"] = $mot["debut"];
|
||||
$definition["fin"] = $mot["fin"];
|
||||
$this->definitions["horizontales"][$y][] = $definition;
|
||||
}
|
||||
}
|
||||
for ($x = 0; $x < $this->largeur; $x++) {
|
||||
$mots = explode_pos(CASE_NOIRE, $this->get_colonne($x, $this->hauteur));
|
||||
$this->definitions["verticales"][$x] = [];
|
||||
foreach($mots as $mot) {
|
||||
$definitions = $this->dico[$mot["longueur"]][$mot["mot"]];
|
||||
if (count($definitions)) {
|
||||
$definition = $definitions[mt_rand(0, count($definitions) - 1)];
|
||||
if (is_array($definition)) {
|
||||
foreach ($definition as $auteur => $def) {
|
||||
$mot["definition"] = $def;
|
||||
$mot["auteur"] = $auteur;
|
||||
}
|
||||
} else if (is_string($definition)) {
|
||||
$mot["definition"] = $definition;
|
||||
}
|
||||
}
|
||||
if (isset($definitions["nb_mots"])) {
|
||||
$mot["nb_mots"] = $definitions["nb_mots"];
|
||||
}
|
||||
unset($mot["mot"]);
|
||||
$this->definitions["verticales"][$x][] = $mot;
|
||||
$definition = $this->dico[$mot["longueur"]][$mot["mot"]];
|
||||
$definition["debut"] = $mot["debut"];
|
||||
$definition["fin"] = $mot["fin"];
|
||||
$this->definitions["verticales"][$x][] = $definition;
|
||||
}
|
||||
}
|
||||
$this->save($id);
|
||||
|
||||
13
dico.php
13
dico.php
@@ -30,7 +30,18 @@ function dico($longueur_max) {
|
||||
|
||||
if (strlen($mot) > $longueur_max) continue;
|
||||
|
||||
$dico[strlen($mot)][$mot] = $definitions;
|
||||
$dico[strlen($mot)][$mot] = [];
|
||||
if (count($definitions)) {
|
||||
$definition = $definitions[mt_rand(0, count($definitions) - 1)];
|
||||
if (is_array($definition)) {
|
||||
foreach ($definition as $auteur => $def) {
|
||||
$dico[strlen($mot)][$mot]["definition"] = $def;
|
||||
$dico[strlen($mot)][$mot]["auteur"] = $auteur;
|
||||
}
|
||||
} else if (is_string($definition)) {
|
||||
$dico[strlen($mot)][$mot]["definition"] = $definition;
|
||||
}
|
||||
}
|
||||
if ($nb_mots > 1) $dico[strlen($mot)][$mot]["nb_mots"] = $nb_mots;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user