Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit 83b758f1 authored by Arnaud Bey's avatar Arnaud Bey
Browse files

try to fix wordstart

parent 3bc9963e
......@@ -8,6 +8,7 @@ use Doctrine\ORM\Mapping\Index;
/**
* @ORM\Table(name="lexicon_word_start", indexes={
* @Index(columns={"value"}, flags={"fulltext"}),
* @Index(columns={"value"}, name="value"),
* @Index(name="language", columns={"language"}),
* })
* @ORM\Entity(repositoryClass="LexiconBundle\Repository\WordStartRepository")
......
......@@ -64,7 +64,6 @@ class GridManager
$square = $this->squareManager->create($letter, $grid);
$grid->addSquare($square);
}
$words = $this->findWords($grid);
$this->foundableFormManager->populateFoundables($words, $grid);
......@@ -213,7 +212,7 @@ class GridManager
for ($x = 0; $x < $side; ++$x) {
$simplifiedGrid[$y][$x] = ($grid->getSquares()[$i])
? $grid->getSquares()[$i]->getLetter()->getValue()
: '_';
: null;
++$i;
}
......@@ -226,6 +225,8 @@ class GridManager
$wordStarts = array_unique(array_merge($wordStarts, $this->nextLetter('', $simplifiedGrid, $x, $y, $side)), SORT_STRING);
}
}
// words contient tous les débuts de mots ayant été trouvé dans le dictionnaire
// il faut vérifier si chaque word existe réellement dans le dictionnaire
......@@ -243,13 +244,17 @@ class GridManager
// ajouter la lettre en x, y au mot courant
$word .= $grid[$y][$x];
// la détruire dans la grille
$grid[$y][$x] = '_';
$grid[$y][$x] = null;
$wordLongEnough = mb_strlen($word) > 1;
if ($wordLongEnough) {
// vérifier en bdd s'il existe des mots qui commencent par $word à partir de 2 lettres
$startExists = $this->em->getRepository(WordStart::class)->search($word, $this->currentLanguage->getId());
// $startExists = $this->em->getRepository(WordStart::class)->search($word, $this->currentLanguage->getId());
$startExists = $this->em->getRepository(WordStart::class)->findOneBy([
"value" => $word,
"language" => $this->currentLanguage
]);
// si pas de mot dans le dico commençant par le mot en cours, ne pas retourner le mot et arrêter la recherche
if (!$startExists) {
return [];
......@@ -266,18 +271,18 @@ class GridManager
if ($yy >= 0) {
$xx = $x - 1;
// on vérifie que la lettre n'a pas été utilisée (donc détruite)
if (($xx >= 0) && ($grid[$yy][$xx] != '_')) {
if (($xx >= 0) && ($grid[$yy][$xx] != null)) {
// appel en récursif pour ajout d'une nouvelle lettre au mot
$words = array_merge($words, $this->nextLetter($word, $grid, $xx, $yy, $side));
}
$xx = $x;
if ($grid[$yy][$xx] != '_') {
if ($grid[$yy][$xx] != null) {
$words = array_merge($words, $this->nextLetter($word, $grid, $xx, $yy, $side));
}
$xx = $x + 1;
if (($xx < $side) && ($grid[$yy][$xx] != '_')) {
if (($xx < $side) && ($grid[$yy][$xx] != null)) {
$words = array_merge($words, $this->nextLetter($word, $grid, $xx, $yy, $side));
}
}
......@@ -285,11 +290,11 @@ class GridManager
// ligne courante
$yy = $y;
$xx = $x - 1;
if (($xx >= 0) && ($grid[$yy][$xx] != '_')) {
if (($xx >= 0) && ($grid[$yy][$xx] != null)) {
$words = array_merge($words, $this->nextLetter($word, $grid, $xx, $yy, $side));
}
$xx = $x + 1;
if (($xx < $side) && ($grid[$yy][$xx] != '_')) {
if (($xx < $side) && ($grid[$yy][$xx] != null)) {
$words = array_merge($words, $this->nextLetter($word, $grid, $xx, $yy, $side));
}
......@@ -297,17 +302,17 @@ class GridManager
$yy = $y + 1;
if ($yy < $side) {
$xx = $x - 1;
if (($xx >= 0) && ($grid[$yy][$xx] != '_')) {
if (($xx >= 0) && ($grid[$yy][$xx] != null)) {
$words = array_merge($words, $this->nextLetter($word, $grid, $xx, $yy, $side));
}
$xx = $x;
if ($grid[$yy][$xx] != '_') {
if ($grid[$yy][$xx] != null) {
$words = array_merge($words, $this->nextLetter($word, $grid, $xx, $yy, $side));
}
$xx = $x + 1;
if (($xx < $side) && ($grid[$yy][$xx] != '_')) {
if (($xx < $side) && ($grid[$yy][$xx] != null)) {
$words = array_merge($words, $this->nextLetter($word, $grid, $xx, $yy, $side));
}
}
......
<a class="btn btn-sm" href="{{ path('challenge_continue', {"id": round.game.id}) }}">
<a class="btn btn primary" href="{{ path('challenge_continue', {"id": round.game.id}) }}">
<i class="fa fa-step-forward" aria-hidden="true"></i>
{{ "continue"| trans}}
</a>
<a class="btn btn-outline-secondary" href="{{ path('massive_play', {"code": round.game.code}) }}">
<a class="btn btn-primary" href="{{ path('massive_play', {"code": round.game.code}) }}">
<i class="fa fa-step-forward" aria-hidden="true"></i>
{{ "continue"| trans}}
</a>
<a class="please-wait btn btn-sm btn-secondary" data-message="Génération de la grille" href="{{ path('train', {id: round.grid.language.id}) }}">
<a class="please-wait btn btn-sm btn-primary" data-message="Génération de la grille" href="{{ path('train', {id: round.grid.language.id}) }}">
<i class="fas fa-redo-alt"></i>
<span class="d-none d-md-inline">{{ "train_again" | trans }}</span>
</a>
......@@ -8,14 +8,24 @@
{% set gameType = round.game.discr %}
{% set roundType = round.discr %}
<div class="card">
<div class="card-header">
<nav aria-label="breadcrumb">
<ol class="breadcrumb" style="background-color: #fff;">
<li class="breadcrumb-item"><a href="{{path('home')}}">Accueil</a></li>
<li class="breadcrumb-item" aria-current="page"><a href="{{path('home_play')}}">Jouer</a></li>
<li class="breadcrumb-item active" aria-current="page">
Manche {{ round.displayOrder + 1 }} / {{ round.game.rounds|length}} - {{ gameType | trans }}
<span class="float-right">
{% include "MagicWordBundle:Round/End:next-"~gameType~".html.twig" %}
</span>
</div>
</li>
</ol>
</nav>
<div class="card">
<div class="card-body">
<div class="row mb-2">
<div class="col">
<span class="float-right">{% include "MagicWordBundle:Round/End:next-"~gameType~".html.twig" %}</span>
</div>
</div>
<div class="jumbotron jumbotron-fluid p-1">
<div class="container">
<div class="row">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment