Rectification de certain bugs dans la création de partie.
This commit is contained in:
parent
21b319f922
commit
7139225d0c
|
@ -296,10 +296,10 @@ function decodeAndInsertGame($user,$game) {
|
|||
if(count($badWords) > 0) {
|
||||
echo JSON_encode($badWords);
|
||||
} else if (count($cloud) < 5) {
|
||||
echo "false";
|
||||
echo JSON_encode(false);
|
||||
} else {
|
||||
insertCreatedGame($centerEid,$cloud,$r1,$r2,10,$user);
|
||||
echo "true";
|
||||
echo JSON_encode(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ $(function() {
|
|||
url: "server.php?",
|
||||
data: "action=4&word="+word, //+"&user="+user+"&passwd="+passwd,
|
||||
success: function(msg){
|
||||
input.closest(".wordLine, #center").addClass(msg == "false" ? "invalid" : "valid");
|
||||
input.closest(".wordLine, #center").addClass(msg == false ? "invalid" : "valid");
|
||||
wordsOK[input.attr("id")] = !(msg == false);
|
||||
}});
|
||||
}
|
||||
|
@ -118,20 +118,20 @@ $(function() {
|
|||
var formOK = function() {
|
||||
displayError("");
|
||||
|
||||
if ($("#relation1").val() == $("#relation2").val())
|
||||
displayError("Les deux relation doivent être différents");
|
||||
else if ($("#centralWord").val() == "")
|
||||
displayError("Le mot central doit être renseigné.");
|
||||
if ($("#relation1").val() == $("#relation2").val())
|
||||
displayError("Les deux relation doivent être différents");
|
||||
else if ($("#centralWord").val() == "")
|
||||
displayError("Le mot central doit être renseigné.");
|
||||
else if (badWord())
|
||||
displayError("Il existe des mots incorrects");
|
||||
else if (nbWordOK() < nbWordMin)
|
||||
displayError("Le nuage doit contenir au moins "+nbWordMin+" mots valides.");
|
||||
else if (!relationsOK())
|
||||
displayError("Tout les mots ne sont pas liés à une relation");
|
||||
else
|
||||
sendGame();
|
||||
else if (nbWordOK() < nbWordMin)
|
||||
displayError("Le nuage doit contenir au moins "+nbWordMin+" mots valides.");
|
||||
else if (!relationsOK())
|
||||
displayError("Tout les mots ne sont pas liés à une relation");
|
||||
else
|
||||
sendGame();
|
||||
|
||||
return false;
|
||||
return false;
|
||||
};
|
||||
|
||||
var nbWordOK = function() {
|
||||
|
@ -150,64 +150,69 @@ $(function() {
|
|||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
var relationsOK = function() {
|
||||
for(i = 1; i < numWord; i++) {
|
||||
if(wordsOK["word-"+i]) {
|
||||
if(!$("#r1-"+i).is(":checked") && !$("#r2-"+i).is(":checked") && !$("#r3-"+i).is(":checked") && !$("#r4-"+i).is(":checked"))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
var sendGame = function() {
|
||||
var exit;
|
||||
var cloud = "";
|
||||
|
||||
exit = {center:$("#centralWord").val(),
|
||||
relations:[$("#relation1").val(),$("#relation2").val(),0,-1],
|
||||
cloud:[]};
|
||||
|
||||
for(i=1;i<numWord;i++) {
|
||||
exit.cloud.push({
|
||||
name:$("#word-"+i).val(),
|
||||
relations:[
|
||||
$("#r1-"+i).is(":checked") ? "1":"0",
|
||||
$("#r2-"+i).is(":checked") ? "1":"0",
|
||||
$("#r3-"+i).is(":checked") ? "1":"0",
|
||||
$("#r4-"+i).is(":checked") ? "1":"0"
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
$.get("server.php",{action:"6",game:exit},function (data) {
|
||||
//$(".word").closest(".wordLine, #center").removeClass("valid invalid");
|
||||
if(data == "true") {
|
||||
displaySuccess("La partie à bien été enregistrée");
|
||||
$('#newCreationLink').show();
|
||||
$('#center').hide();
|
||||
$('#relations').hide();
|
||||
$('#wordLines').hide();
|
||||
$('#button').hide();
|
||||
} else if (data == "false") {
|
||||
displayError("Le nuage doit contenir au moins "+nbWordMin+" mots valides.");
|
||||
} else if (data != "true") {
|
||||
$('input').removeAttr('disabled');
|
||||
var that = $(this);
|
||||
$.each(data,function(i,e) {
|
||||
$('.word')
|
||||
.filter(function() { return that.val() == e; })
|
||||
.closest(".wordLine, #center")
|
||||
.removeClass("valid invalid")
|
||||
.addClass("invalid");
|
||||
});
|
||||
var relationsOK = function() {
|
||||
for(i = 1; i < numWord; i++) {
|
||||
if(wordsOK["word-"+i]) {
|
||||
if(!$("#r1-"+i).is(":checked") && !$("#r2-"+i).is(":checked") && !$("#r3-"+i).is(":checked") && !$("#r4-"+i).is(":checked"))
|
||||
return false;
|
||||
}
|
||||
});
|
||||
$('input').attr('disabled', 'disabled');
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
var sendGame = function() {
|
||||
var exit;
|
||||
var cloud = "";
|
||||
|
||||
exit = {center:$("#centralWord").val(),
|
||||
relations:[$("#relation1").val(),$("#relation2").val(),0,-1],
|
||||
cloud:[]};
|
||||
|
||||
for(i=1;i<numWord;i++) {
|
||||
exit.cloud.push({
|
||||
name:$("#word-"+i).val(),
|
||||
relations:[
|
||||
$("#r1-"+i).is(":checked") ? "1":"0",
|
||||
$("#r2-"+i).is(":checked") ? "1":"0",
|
||||
$("#r3-"+i).is(":checked") ? "1":"0",
|
||||
$("#r4-"+i).is(":checked") ? "1":"0"
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
$.get("server.php",{action:"6",game:exit},function (data) {
|
||||
//$(".word").closest(".wordLine, #center").removeClass("valid invalid");
|
||||
if(data == true) {
|
||||
displaySuccess("La partie à bien été enregistrée");
|
||||
$('#newCreationLink').show();
|
||||
$('#center').hide();
|
||||
$('#relations').hide();
|
||||
$('#wordLines').hide();
|
||||
$('#button').hide();
|
||||
}
|
||||
else if (data == false) {
|
||||
$('input').removeAttr('disabled');
|
||||
displayError("Le nuage doit contenir au moins "+nbWordMin+" mots valides.");
|
||||
}
|
||||
else if (data != true) {
|
||||
$('input').removeAttr('disabled');
|
||||
var that = $(this);
|
||||
console.log("mot incorrect");
|
||||
$.each(data,function(i,e) {
|
||||
$('.word')
|
||||
.filter(function() { return that.val() == e; })
|
||||
.closest(".wordLine, #center")
|
||||
.removeClass("valid invalid")
|
||||
.addClass("invalid");
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$('input').attr('disabled', 'disabled');
|
||||
}
|
||||
|
||||
var displayError = function(message) {
|
||||
if (message != "")
|
||||
|
|
|
@ -77,22 +77,23 @@ function main()
|
|||
// Requête POST : http://serveur/server.php?action=0&user=foo&passwd=bar
|
||||
echo game2json($user, isset($_GET['pgid']) ? $_GET['pgid'] : null);
|
||||
}
|
||||
else if($action == 1) { // "Set partie"
|
||||
else if($action == 1) { // "Set partie"
|
||||
// Requête POST : http://serveur/server.php?action=1&mode=normal&user=foo&passwd=bar&gid=1234&pgid=12357&0=0&1=-1&2=22&3=13&9=-1
|
||||
if (!isset($_GET['pgid']) || !isset($_GET['gid']) || !isset($_GET['answers']))
|
||||
throw new Exception("La requête est incomplète", 2);
|
||||
|
||||
setGameGetScore($user, $_GET['pgid'], $_GET['gid'], $_GET['answers']);
|
||||
} else if($action == 4) { // CheckWord
|
||||
}
|
||||
else if($action == 4) { // CheckWord
|
||||
if (!isset($_GET['word']))
|
||||
throw new Exception("La requête est incomplète", 2);
|
||||
|
||||
if(wordExist($_GET['word']))
|
||||
echo "true";
|
||||
echo JSON_encode(true);
|
||||
else
|
||||
echo "false";
|
||||
echo JSON_encode(false);
|
||||
}
|
||||
else if($action == 5) { // Get relations (JSON)
|
||||
else if($action == 5) { // Get relations (JSON)
|
||||
echo getGameRelations();
|
||||
}
|
||||
else if($action == 6) {
|
||||
|
@ -100,15 +101,18 @@ function main()
|
|||
throw new Exception("La requête est incomplète", 2);
|
||||
|
||||
decodeAndInsertGame($user,$_GET['game']);
|
||||
} elseif ($action == 7) { // Get user prefs
|
||||
}
|
||||
elseif ($action == 7) { // Get user prefs
|
||||
userPrefs($user);
|
||||
} elseif ($action == 8) { // Set user pref
|
||||
}
|
||||
elseif ($action == 8) { // Set user pref
|
||||
if (!isset($_GET['key']) || !isset($_GET['value']))
|
||||
throw new Exception("La requête est incomplète", 2);
|
||||
|
||||
setUserPref($user, $_GET['key'], $_GET['value']);
|
||||
userPrefs($user);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
throw new Exception("Commande inconnue", 2);
|
||||
}
|
||||
}
|
||||
|
@ -139,6 +143,7 @@ function server() {
|
|||
logError($e->getCode(), $e->getMessage(), date("c"));
|
||||
closeDB();
|
||||
}
|
||||
|
||||
if(isset($_GET['callback']))
|
||||
echo ')';
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user