From 74beb1388aee029dfa75a798c19a9dd8b7d789b0 Mon Sep 17 00:00:00 2001 From: adrien Date: Thu, 8 May 2025 12:19:10 +0200 Subject: [PATCH] =?UTF-8?q?mise=20en=20forme=20des=20d=C3=A9finitions=20da?= =?UTF-8?q?ns=20index.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dico.csv | 4 ++-- dico.php | 9 +-------- index.php | 22 ++++++++++++++++++++-- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/dico.csv b/dico.csv index 816e60c..455e6e3 100644 --- a/dico.csv +++ b/dico.csv @@ -326,7 +326,7 @@ BAHUT Boîte de pions@Bernard Philippet BAI Couleur de la robe d'un cheval BAIE A plus d'eau que de jus@Lionel Leteur BAIL Temps qui paraît long@Marc Aussitot -BAINDESIEGE Avec lui, la lune est dans l'eau (3 mots)@Max Favalelli +BAIN DE SIEGE Avec lui, la lune est dans l'eau@Max Favalelli BAL Pour l'ouvrir, il faut tourner@Lucien Lacau Ne s'ouvre pas tout seul@Jean-Paul Vanden Branden BANLIEUE Avant-centre@Michel Laclos BANQUIER Homme respectable, surtout s’il vous prête@Léon Bloy Il te prête un parapluie par beau temps et te le reprend lorsqu'il commence à pleuvoir@Mark Twain. Personne qui serait d'accord pour vous consentir un prêt à la condition que vous lui apportiez la preuve que vous n'en avez pas besoin @@ -350,7 +350,7 @@ BEE Bouche grande ouverte BEL Un vieux beau@Georges Perec Avant l'été, mais on ne peut en être sûr qu'après@Pangloss Ne peut jamais arriver avant le printemps, contrairement aux trois autres@Pangloss Autrement beau Mesure de puissance sonore BELLE Sûrement pas la première venue, mais la dernière partie, ça c'est sûr !@Pangloss BENIN Anodin sauf en afrique@Jean Teularge -BENIOUIOUI Apparemment, il consent à se marier à l'église@Jacques Drillon +BENI OUI OUI Apparemment, il consent à se marier à l'église@Jacques Drillon BER Charpente qui supporte un bateau en construction Support de navire BERET Complément populaire de la baguette@Jean-Marie Lamy BETON Il est armé pour résister@Jean-Paul Vanden Branden diff --git a/dico.php b/dico.php index 4d1b8ed..b854846 100644 --- a/dico.php +++ b/dico.php @@ -25,13 +25,6 @@ function dico($longueur_max) { $mot = $ligne[0]; $definitions = array_slice($ligne, 1); - - foreach ($definitions as $i => $definition) { - if (strpos($definition, "@") !== false) { - [$definition, $auteur] = explode("@", $definition); - $definitions[$i] = "$definition $auteur"; - } - } $mot = str_replace("-", CASE_NOIRE, $mot); $mot = $transliterator->transliterate($mot); @@ -39,7 +32,7 @@ function dico($longueur_max) { $mots = explode(CASE_NOIRE, $mot); $nb_mots = count($mots); $mot = implode("", $mots); - $definition .= " ($nb_mots mots)"; + $definition .= "#$nb_mots"; } $dico[strlen($mot)][$mot] = $definitions; diff --git a/index.php b/index.php index 94a1cd8..524c2c0 100644 --- a/index.php +++ b/index.php @@ -50,7 +50,16 @@ if ($grille_valide) { foreach ($grille->lignes[$y] as $mot) { $definitions = $grille->dico[strlen($mot)][$mot]; if (count($definitions)) { - $definitions_horizontales[$y][] = $definitions[mt_rand(0, count($definitions) - 1)]; + $definition = $definitions[mt_rand(0, count($definitions) - 1)]; + if (strpos($definition, "#") !== false) { + [$definition, $nb_mots] = explode("#", $definition); + $definition .= " ($nb_mots mots)"; + } + if (strpos($definition, "@") !== false) { + [$definition, $auteur] = explode("@", $definition); + $definition .= " $auteur"; + } + $definitions_horizontales[$y][] = $definition; } } } @@ -60,7 +69,16 @@ if ($grille_valide) { foreach ($grille->colonnes[$x] as $mot) { $definitions = $grille->dico[strlen($mot)][$mot]; if (count($definitions)) { - $definitions_verticales[$x][] = $definitions[mt_rand(0, count($definitions) - 1)]; + $definition = $definitions[mt_rand(0, count($definitions) - 1)]; + if (strpos($definition, "#") !== false) { + [$definition, $nb_mots] = explode("#", $definition); + $definition .= " ($nb_mots mots)"; + } + if (strpos($definition, "@") !== false) { + [$definition, $auteur] = explode("@", $definition); + $definition .= " $auteur"; + } + $definitions_verticales[$x][] = $definition; } } }