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
c76cc139
Commit
c76cc139
authored
May 07, 2019
by
Arnaud Bey
Browse files
WIP replace lemma by root
parent
2dec3c73
Changes
3
Hide whitespace changes
Inline
Side-by-side
application/src/MagicWordBundle/Entity/Grid.php
View file @
c76cc139
...
...
@@ -130,27 +130,22 @@ class Grid implements \JsonSerializable
];
foreach
(
$this
->
getFoundableForms
()
as
$foundable
)
{
$form
=
$foundable
->
getForm
();
$jsonArray
[
'inflections'
][
$form
]
=
[
'id'
=>
$foundable
->
getId
(),
'points'
=>
$foundable
->
getPoints
(),
'infos'
=>
[],
'ids'
=>
[],
'lemmaIds'
=>
[]];
$jsonArray
[
'inflections'
][
$form
]
=
[
'id'
=>
$foundable
->
getId
(),
'points'
=>
$foundable
->
getPoints
(),
'features'
=>
[],
'ids'
=>
[],
'rootIds'
=>
[]
];
foreach
(
$foundable
->
getWords
()
as
$word
)
{
$root
=
$word
->
getRoot
();
$jsonArray
[
'inflections'
][
$form
][
'infos'
][]
=
1
;
/*
[
'category' => !$root->getCategory() ? null : $root->getCategory()->getId(),
'number' => !$word->getNumber() ? null : $word->getNumber()->getId(),
'gender' => !$word->getGender() ? null : $word->getGender()->getId(),
'person' => !$word->getPerson() ? null : $word->getPerson()->getId(),
'mood' => !$word->getMood() ? null : $word->getMood()->getId(),
'tense' => !$word->getTense() ? null : $word->getTense()->getId(),
];
*/
foreach
(
$word
->
getFeatures
()
as
$feature
)
{
$jsonArray
[
'inflections'
][
$form
][
'features'
][
$feature
->
getId
()]
=
$feature
->
getValue
();
}
$jsonArray
[
'inflections'
][
$form
][
'ids'
][]
=
$word
->
getId
();
$rootId
=
$root
->
getId
();
if
(
!
in_array
(
$rootId
,
$jsonArray
[
'inflections'
][
$form
][
'
lemma
Ids'
]))
{
$jsonArray
[
'inflections'
][
$form
][
'
lemma
Ids'
][]
=
$rootId
;
if
(
!
in_array
(
$rootId
,
$jsonArray
[
'inflections'
][
$form
][
'
root
Ids'
]))
{
$jsonArray
[
'inflections'
][
$form
][
'
root
Ids'
][]
=
$rootId
;
}
}
}
...
...
application/src/MagicWordBundle/Entity/Round.php
View file @
c76cc139
...
...
@@ -254,49 +254,46 @@ class Round implements \JsonSerializable
public
function
jsonSerialize
()
{
$jsonArray
=
array
(
$jsonArray
=
[
'id'
=>
$this
->
id
,
'findWords'
=>
array
()
,
'combos'
=>
array
()
,
'constraints'
=>
array
()
,
'findWords'
=>
[]
,
'combos'
=>
[]
,
'constraints'
=>
[]
,
'type'
=>
$this
->
discr
,
)
;
]
;
if
(
$this
->
discr
==
'conquer'
)
{
foreach
(
$this
->
getFindWords
()
as
$findWord
)
{
$jsonArray
[
'findWords'
][
$findWord
->
getInflection
()]
=
[
'id'
=>
$findWord
->
getId
(),
'hint'
=>
$findWord
->
getHint
(),
'lemmaIds'
=>
[],
$jsonArray
[
'findWords'
][
$findWord
->
getInflection
()]
=
[
'id'
=>
$findWord
->
getId
(),
'hint'
=>
$findWord
->
getHint
(),
'lemmaIds'
=>
[],
];
foreach
(
$findWord
->
get
Lemma
s
()
as
$
lemma
)
{
$jsonArray
[
'findWords'
][
$findWord
->
getInflection
()][
'
lemma
Ids'
][]
=
$
lemma
->
getId
();
foreach
(
$findWord
->
get
Root
s
()
as
$
root
)
{
$jsonArray
[
'findWords'
][
$findWord
->
getInflection
()][
'
root
Ids'
][]
=
$
root
->
getId
();
}
}
foreach
(
$this
->
getCombos
()
as
$combo
)
{
$jsonArray
[
'combos'
][]
=
[
'id'
=>
$combo
->
getId
(),
'length'
=>
$combo
->
getLenght
(),
'number'
=>
$combo
->
getNumber
(),
];
$jsonArray
[
'combos'
][]
=
[
'id'
=>
$combo
->
getId
(),
'length'
=>
$combo
->
getLenght
(),
'number'
=>
$combo
->
getNumber
(),
];
}
foreach
(
$this
->
getConstraints
()
as
$constraint
)
{
$jsonArray
[
'constraints'
][]
=
[
'id'
=>
$constraint
->
getId
(),
'numberToFind'
=>
$constraint
->
getNumberToFind
(),
'category'
=>
$constraint
->
getCategory
()
?
$constraint
->
getCategory
()
->
getId
()
:
null
,
'gender'
=>
$constraint
->
getGender
()
?
$constraint
->
getGender
()
->
getId
()
:
null
,
'number'
=>
$constraint
->
getNumber
()
?
$constraint
->
getNumber
()
->
getId
()
:
null
,
'tense'
=>
$constraint
->
getTense
()
?
$constraint
->
getTense
()
->
getId
()
:
null
,
'mood'
=>
$constraint
->
getMood
()
?
$constraint
->
getMood
()
->
getId
()
:
null
,
'person'
=>
$constraint
->
getPerson
()
?
$constraint
->
getPerson
()
->
getId
()
:
null
,
];
$jsonArray
[
'constraints'
][]
=
[
'id'
=>
$constraint
->
getId
(),
'numberToFind'
=>
$constraint
->
getNumberToFind
(),
'category'
=>
$constraint
->
getCategory
()
?
$constraint
->
getCategory
()
->
getId
()
:
null
,
'gender'
=>
$constraint
->
getGender
()
?
$constraint
->
getGender
()
->
getId
()
:
null
,
'number'
=>
$constraint
->
getNumber
()
?
$constraint
->
getNumber
()
->
getId
()
:
null
,
'tense'
=>
$constraint
->
getTense
()
?
$constraint
->
getTense
()
->
getId
()
:
null
,
'mood'
=>
$constraint
->
getMood
()
?
$constraint
->
getMood
()
->
getId
()
:
null
,
'person'
=>
$constraint
->
getPerson
()
?
$constraint
->
getPerson
()
->
getId
()
:
null
,
];
}
}
...
...
application/src/MagicWordBundle/Resources/public/js/play/combo.js
View file @
c76cc139
...
...
@@ -2,24 +2,24 @@ var combo = {
newIds
:
[],
previousIds
:
[],
currentComboLength
:
0
,
currentCombo
Lemma
s
:
[],
currentCombo
Root
s
:
[],
comboSelector
:
$
(
"
#combo
"
),
handleNewIds
:
function
(
callback
){
var
increment
=
false
;
var
comboEnded
=
false
;
if
(
this
.
currentCombo
Lemma
s
.
length
===
0
)
{
if
(
this
.
currentCombo
Root
s
.
length
===
0
)
{
//ajout des nouveaux lemmes dans currentcombos
for
(
var
i
=
this
.
newIds
.
length
;
i
--
;)
{
this
.
currentCombo
Lemma
s
.
push
(
this
.
newIds
[
i
]);
this
.
currentCombo
Root
s
.
push
(
this
.
newIds
[
i
]);
}
this
.
currentComboLength
=
1
;
increment
=
true
;
}
else
{
// suppression dans current combos des lemmes qui ne font pas partie des nouveaux lemmes.
for
(
var
i
=
this
.
currentCombo
Lemma
s
.
length
;
i
--
;)
{
if
(
$
.
inArray
(
this
.
currentCombo
Lemma
s
[
i
],
this
.
newIds
)
==
-
1
)
{
this
.
currentCombo
Lemma
s
.
splice
(
i
,
1
);
for
(
var
i
=
this
.
currentCombo
Root
s
.
length
;
i
--
;)
{
if
(
$
.
inArray
(
this
.
currentCombo
Root
s
[
i
],
this
.
newIds
)
==
-
1
)
{
this
.
currentCombo
Root
s
.
splice
(
i
,
1
);
}
else
if
(
!
increment
)
{
increment
=
true
;
this
.
currentComboLength
++
;
...
...
@@ -47,8 +47,8 @@ var combo = {
// ajout des nouveaux lemmes dans currentcombos
for
(
var
i
=
this
.
newIds
.
length
;
i
--
;)
{
if
(
$
.
inArray
(
this
.
newIds
[
i
],
this
.
currentCombo
Lemma
s
)
==
-
1
)
{
this
.
currentCombo
Lemma
s
.
push
(
this
.
newIds
[
i
]);
if
(
$
.
inArray
(
this
.
newIds
[
i
],
this
.
currentCombo
Root
s
)
==
-
1
)
{
this
.
currentCombo
Root
s
.
push
(
this
.
newIds
[
i
]);
if
(
!
increment
)
{
this
.
currentComboLength
=
1
;
}
...
...
@@ -61,7 +61,7 @@ var combo = {
handleNewInflection
:
function
(
inflection
){
this
.
previousIds
=
this
.
newIds
;
this
.
newIds
=
gridJSON
.
inflections
[
inflection
.
toLowerCase
()].
lemma
Ids
;
this
.
newIds
=
gridJSON
.
inflections
[
inflection
.
toLowerCase
()].
root
Ids
;
this
.
handleNewIds
(
objectiveCombo
.
checkLastObjective
);
return
;
...
...
@@ -87,7 +87,7 @@ var combo = {
this
.
newIds
=
[];
this
.
previousIds
=
[];
this
.
currentComboLength
=
0
;
this
.
currentCombo
Lemma
s
=
[];
this
.
currentCombo
Root
s
=
[];
this
.
showCombo
();
},
...
...
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