renommage

This commit is contained in:
Adrien MALINGREY 2025-04-24 10:55:47 +02:00
parent cb4c6c91ed
commit 5537607011
2 changed files with 14 additions and 14 deletions

View File

@ -25,15 +25,15 @@ class Grille {
$dimensions = [$hauteur, $largeur]; $dimensions = [$hauteur, $largeur];
} }
$this->mots_commencant_par = []; $this->mots_commencant_par = [];
foreach ($dimensions as $dimension) { foreach ($dimensions as $longueur) {
$this->mots_commencant_par[$dimension] = []; $this->mots_commencant_par[$longueur] = [];
foreach(mots_espaces($dimension, MIN_LETTRES) as $mot) { foreach(mots_espaces($longueur, MIN_LETTRES) as $mot) {
for ($i = 0; $i <= $dimension; $i++) { for ($i = 0; $i <= $longueur; $i++) {
$debut = substr($mot, 0, $i); $debut = substr($mot, 0, $i);
if (!isset($this->mots_commencant_par[$dimension][$debut])) { if (!isset($this->mots_commencant_par[$longueur][$debut])) {
$this->mots_commencant_par[$dimension][$debut] = []; $this->mots_commencant_par[$longueur][$debut] = [];
} }
$this->mots_commencant_par[$dimension][$debut][] = $mot; $this->mots_commencant_par[$longueur][$debut][] = $mot;
} }
} }
} }
@ -41,10 +41,10 @@ class Grille {
$this->grilles->current(); $this->grilles->current();
} }
public function get_ligne($l, $max = 100) { public function get_ligne($l, $longueur = 100) {
$longueur = min($longueur, $this->largeur);
$ligne = ""; $ligne = "";
$min = min($this->largeur, $max); for ($i = 0; $i < $longueur; $i++) {
for ($i = 0; $i < $min; $i++) {
$ligne .= $this->grille[$l][$i]; $ligne .= $this->grille[$l][$i];
} }
return $ligne; return $ligne;
@ -56,10 +56,10 @@ class Grille {
} }
} }
public function get_colonne($c, $max = 100) { public function get_colonne($c, $longueur = 100) {
$longueur = min($longueur, $this->hauteur);
$colonne = ""; $colonne = "";
$min = min($this->hauteur, $max); for ($i = 0; $i < $longueur; $i++) {
for ($i = 0; $i < $min; $i++) {
$colonne .= $this->grille[$i][$c]; $colonne .= $this->grille[$i][$c];
} }
return $colonne; return $colonne;

View File

@ -51,7 +51,7 @@ $grille = new Grille($hauteur, $largeur);
<?php for ($c = 0; $c < $largeur; $c++): ?> <?php for ($c = 0; $c < $largeur; $c++): ?>
<td class="case <?= $grille->grille[$l][$c]==" "?"noire": "blanche" ?>"> <td class="case <?= $grille->grille[$l][$c]==" "?"noire": "blanche" ?>">
<?php if ($grille->grille[$l][$c] == " "): ?> <?php if ($grille->grille[$l][$c] == " "): ?>
<input type="text" maxlength="1" size="1" name="<?= $l . $c ?>" disabled/> <input type="text" maxlength="1" size="1" name="<?= $l . $c ?>" value=" " disabled/>
<?php else: ?> <?php else: ?>
<input type="text" maxlength="1" size="1" name="<?= $l . $c ?>" /> <input type="text" maxlength="1" size="1" name="<?= $l . $c ?>" />
<?php endif; ?> <?php endif; ?>