Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mathieu Loiseau
MagicWord
Commits
83b758f1
Commit
83b758f1
authored
May 24, 2019
by
Arnaud Bey
Browse files
try to fix wordstart
parent
3bc9963e
Changes
6
Hide whitespace changes
Inline
Side-by-side
application/src/LexiconBundle/Entity/WordStart.php
View file @
83b758f1
...
@@ -8,6 +8,7 @@ use Doctrine\ORM\Mapping\Index;
...
@@ -8,6 +8,7 @@ use Doctrine\ORM\Mapping\Index;
/**
/**
* @ORM\Table(name="lexicon_word_start", indexes={
* @ORM\Table(name="lexicon_word_start", indexes={
* @Index(columns={"value"}, flags={"fulltext"}),
* @Index(columns={"value"}, flags={"fulltext"}),
* @Index(columns={"value"}, name="value"),
* @Index(name="language", columns={"language"}),
* @Index(name="language", columns={"language"}),
* })
* })
* @ORM\Entity(repositoryClass="LexiconBundle\Repository\WordStartRepository")
* @ORM\Entity(repositoryClass="LexiconBundle\Repository\WordStartRepository")
...
...
application/src/MagicWordBundle/Manager/GridManager.php
View file @
83b758f1
...
@@ -64,7 +64,6 @@ class GridManager
...
@@ -64,7 +64,6 @@ class GridManager
$square
=
$this
->
squareManager
->
create
(
$letter
,
$grid
);
$square
=
$this
->
squareManager
->
create
(
$letter
,
$grid
);
$grid
->
addSquare
(
$square
);
$grid
->
addSquare
(
$square
);
}
}
$words
=
$this
->
findWords
(
$grid
);
$words
=
$this
->
findWords
(
$grid
);
$this
->
foundableFormManager
->
populateFoundables
(
$words
,
$grid
);
$this
->
foundableFormManager
->
populateFoundables
(
$words
,
$grid
);
...
@@ -213,7 +212,7 @@ class GridManager
...
@@ -213,7 +212,7 @@ class GridManager
for
(
$x
=
0
;
$x
<
$side
;
++
$x
)
{
for
(
$x
=
0
;
$x
<
$side
;
++
$x
)
{
$simplifiedGrid
[
$y
][
$x
]
=
(
$grid
->
getSquares
()[
$i
])
$simplifiedGrid
[
$y
][
$x
]
=
(
$grid
->
getSquares
()[
$i
])
?
$grid
->
getSquares
()[
$i
]
->
getLetter
()
->
getValue
()
?
$grid
->
getSquares
()[
$i
]
->
getLetter
()
->
getValue
()
:
'_'
;
:
null
;
++
$i
;
++
$i
;
}
}
...
@@ -226,6 +225,8 @@ class GridManager
...
@@ -226,6 +225,8 @@ class GridManager
$wordStarts
=
array_unique
(
array_merge
(
$wordStarts
,
$this
->
nextLetter
(
''
,
$simplifiedGrid
,
$x
,
$y
,
$side
)),
SORT_STRING
);
$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
// 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
// il faut vérifier si chaque word existe réellement dans le dictionnaire
...
@@ -243,13 +244,17 @@ class GridManager
...
@@ -243,13 +244,17 @@ class GridManager
// ajouter la lettre en x, y au mot courant
// ajouter la lettre en x, y au mot courant
$word
.
=
$grid
[
$y
][
$x
];
$word
.
=
$grid
[
$y
][
$x
];
// la détruire dans la grille
// la détruire dans la grille
$grid
[
$y
][
$x
]
=
'_'
;
$grid
[
$y
][
$x
]
=
null
;
$wordLongEnough
=
mb_strlen
(
$word
)
>
1
;
$wordLongEnough
=
mb_strlen
(
$word
)
>
1
;
if
(
$wordLongEnough
)
{
if
(
$wordLongEnough
)
{
// vérifier en bdd s'il existe des mots qui commencent par $word à partir de 2 lettres
// 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
// 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
)
{
if
(
!
$startExists
)
{
return
[];
return
[];
...
@@ -266,18 +271,18 @@ class GridManager
...
@@ -266,18 +271,18 @@ class GridManager
if
(
$yy
>=
0
)
{
if
(
$yy
>=
0
)
{
$xx
=
$x
-
1
;
$xx
=
$x
-
1
;
// on vérifie que la lettre n'a pas été utilisée (donc détruite)
// 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
// appel en récursif pour ajout d'une nouvelle lettre au mot
$words
=
array_merge
(
$words
,
$this
->
nextLetter
(
$word
,
$grid
,
$xx
,
$yy
,
$side
));
$words
=
array_merge
(
$words
,
$this
->
nextLetter
(
$word
,
$grid
,
$xx
,
$yy
,
$side
));
}
}
$xx
=
$x
;
$xx
=
$x
;
if
(
$grid
[
$yy
][
$xx
]
!=
'_'
)
{
if
(
$grid
[
$yy
][
$xx
]
!=
null
)
{
$words
=
array_merge
(
$words
,
$this
->
nextLetter
(
$word
,
$grid
,
$xx
,
$yy
,
$side
));
$words
=
array_merge
(
$words
,
$this
->
nextLetter
(
$word
,
$grid
,
$xx
,
$yy
,
$side
));
}
}
$xx
=
$x
+
1
;
$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
));
$words
=
array_merge
(
$words
,
$this
->
nextLetter
(
$word
,
$grid
,
$xx
,
$yy
,
$side
));
}
}
}
}
...
@@ -285,11 +290,11 @@ class GridManager
...
@@ -285,11 +290,11 @@ class GridManager
// ligne courante
// ligne courante
$yy
=
$y
;
$yy
=
$y
;
$xx
=
$x
-
1
;
$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
));
$words
=
array_merge
(
$words
,
$this
->
nextLetter
(
$word
,
$grid
,
$xx
,
$yy
,
$side
));
}
}
$xx
=
$x
+
1
;
$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
));
$words
=
array_merge
(
$words
,
$this
->
nextLetter
(
$word
,
$grid
,
$xx
,
$yy
,
$side
));
}
}
...
@@ -297,17 +302,17 @@ class GridManager
...
@@ -297,17 +302,17 @@ class GridManager
$yy
=
$y
+
1
;
$yy
=
$y
+
1
;
if
(
$yy
<
$side
)
{
if
(
$yy
<
$side
)
{
$xx
=
$x
-
1
;
$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
));
$words
=
array_merge
(
$words
,
$this
->
nextLetter
(
$word
,
$grid
,
$xx
,
$yy
,
$side
));
}
}
$xx
=
$x
;
$xx
=
$x
;
if
(
$grid
[
$yy
][
$xx
]
!=
'_'
)
{
if
(
$grid
[
$yy
][
$xx
]
!=
null
)
{
$words
=
array_merge
(
$words
,
$this
->
nextLetter
(
$word
,
$grid
,
$xx
,
$yy
,
$side
));
$words
=
array_merge
(
$words
,
$this
->
nextLetter
(
$word
,
$grid
,
$xx
,
$yy
,
$side
));
}
}
$xx
=
$x
+
1
;
$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
));
$words
=
array_merge
(
$words
,
$this
->
nextLetter
(
$word
,
$grid
,
$xx
,
$yy
,
$side
));
}
}
}
}
...
...
application/src/MagicWordBundle/Resources/views/Round/End/next-challenge.html.twig
View file @
83b758f1
<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>
<i
class=
"fa fa-step-forward"
aria-hidden=
"true"
></i>
{{
"continue"
|
trans
}}
{{
"continue"
|
trans
}}
</a>
</a>
application/src/MagicWordBundle/Resources/views/Round/End/next-massive.html.twig
View file @
83b758f1
<a
class=
"btn btn-
outline-second
ary"
href=
"
{{
path
(
'massive_play'
,
{
"code"
:
round.game.code
}
)
}}
"
>
<a
class=
"btn btn-
prim
ary"
href=
"
{{
path
(
'massive_play'
,
{
"code"
:
round.game.code
}
)
}}
"
>
<i
class=
"fa fa-step-forward"
aria-hidden=
"true"
></i>
<i
class=
"fa fa-step-forward"
aria-hidden=
"true"
></i>
{{
"continue"
|
trans
}}
{{
"continue"
|
trans
}}
</a>
</a>
application/src/MagicWordBundle/Resources/views/Round/End/next-training.html.twig
View file @
83b758f1
<a
class=
"please-wait btn btn-sm btn-
second
ary"
data-message=
"Génération de la grille"
href=
"
{{
path
(
'train'
,
{
id
:
round.grid.language.id
}
)
}}
"
>
<a
class=
"please-wait btn btn-sm btn-
prim
ary"
data-message=
"Génération de la grille"
href=
"
{{
path
(
'train'
,
{
id
:
round.grid.language.id
}
)
}}
"
>
<i
class=
"fas fa-redo-alt"
></i>
<i
class=
"fas fa-redo-alt"
></i>
<span
class=
"d-none d-md-inline"
>
{{
"train_again"
|
trans
}}
</span>
<span
class=
"d-none d-md-inline"
>
{{
"train_again"
|
trans
}}
</span>
</a>
</a>
application/src/MagicWordBundle/Resources/views/Round/end.html.twig
View file @
83b758f1
...
@@ -8,14 +8,24 @@
...
@@ -8,14 +8,24 @@
{%
set
gameType
=
round.game.discr
%}
{%
set
gameType
=
round.game.discr
%}
{%
set
roundType
=
round.discr
%}
{%
set
roundType
=
round.discr
%}
<div
class=
"card"
>
<nav
aria-label=
"breadcrumb"
>
<div
class=
"card-header"
>
<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
}}
Manche
{{
round.displayOrder
+
1
}}
/
{{
round.game.rounds
|
length
}}
-
{{
gameType
|
trans
}}
<span
class=
"float-right"
>
</li>
{%
include
"MagicWordBundle:Round/End:next-"
~
gameType
~
".html.twig"
%}
</ol>
</span>
</nav>
</div>
<div
class=
"card"
>
<div
class=
"card-body"
>
<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=
"jumbotron jumbotron-fluid p-1"
>
<div
class=
"container"
>
<div
class=
"container"
>
<div
class=
"row"
>
<div
class=
"row"
>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment