commit 06da45beae138518fa3a5bce1e95112251d6e99d
parent 1858538574cb52184bc77aba0dfece58eee72d45
Author: Bertrand BRUN <bertrand0brun@gmail.com>
Date: Thu, 17 Mar 2011 11:16:53 +0100
Petite modif avant le lancement de la premiere beta
Diffstat:
6 files changed, 24 insertions(+), 117 deletions(-)
diff --git a/code/PtiClic/res/values/strings.xml b/code/PtiClic/res/values/strings.xml
@@ -20,4 +20,5 @@
<string name="score_your_score">Votre score</string>
<string name="score_your_answers">Vos réponses</string>
<string name="score_explanation">(Détail du calcul du score entre parenthèse)</string>
+<string name="score_no_answers">(aucune réponse)</string>
</resources>
diff --git a/code/PtiClic/src/org/pticlic/BaseScore.java b/code/PtiClic/src/org/pticlic/BaseScore.java
@@ -1,5 +1,6 @@
package org.pticlic;
+import org.pticlic.R.string;
import org.pticlic.exception.PtiClicException;
import org.pticlic.model.Constant;
import org.pticlic.model.DownloadedBaseGame;
@@ -85,6 +86,7 @@ public class BaseScore extends Activity implements OnClickListener{
setContentView(R.layout.score);
this.networkStuff();
+ this.networkStuff();
// TODO : Attention, le cast en (BaseGame) n'est pas sûr !
DownloadedBaseGame bg = (DownloadedBaseGame)gamePlayed.getGame();
@@ -95,33 +97,34 @@ public class BaseScore extends Activity implements OnClickListener{
((TextView)findViewById(R.id.scoreRel4)).setText(bg.getCatString(4));
String res;
+ String noAnswers = getString(string.score_no_answers);
res = "";
for (int i : gamePlayed.getRelation1()) {
res += bg.getWordInCloud(i).getName();
res += " (" + String.valueOf(sr.getScoreOfWord(i)) + "), ";
}
- ((TextView)findViewById(R.id.scoreWords1)).setText(res);
+ ((TextView)findViewById(R.id.scoreWords1)).setText(res.length() < 1 ? noAnswers : res);
- res = "";
+ res = noAnswers;
for (int i : gamePlayed.getRelation2()) {
res += bg.getWordInCloud(i).getName();
res += " (" + String.valueOf(sr.getScoreOfWord(i)) + "), ";
}
- ((TextView)findViewById(R.id.scoreWords2)).setText(res);
+ ((TextView)findViewById(R.id.scoreWords2)).setText(res.length() < 1 ? noAnswers : res);
- res = "";
+ res = noAnswers;
for (int i : gamePlayed.getRelation3()) {
res += bg.getWordInCloud(i).getName();
res += " (" + String.valueOf(sr.getScoreOfWord(i)) + "), ";
}
- ((TextView)findViewById(R.id.scoreWords3)).setText(res);
+ ((TextView)findViewById(R.id.scoreWords3)).setText(res.length() < 1 ? noAnswers : res);
- res = "";
+ res = noAnswers;
for (int i : gamePlayed.getRelation4()) {
res += bg.getWordInCloud(i).getName();
res += " (" + String.valueOf(sr.getScoreOfWord(i)) + "), ";
}
- ((TextView)findViewById(R.id.scoreWords4)).setText(res);
+ ((TextView)findViewById(R.id.scoreWords4)).setText(res.length() < 1 ? noAnswers : res);
((Button)findViewById(R.id.saw)).setOnClickListener(this);
}
diff --git a/code/PtiClic/src/org/pticlic/model/Network.java b/code/PtiClic/src/org/pticlic/model/Network.java
@@ -32,19 +32,29 @@ public class Network {
private int scoreTotal;
private int[] scores;
private String newGame;
+ private boolean alreadyPlayed;
+
public ScoreResponse() {}
+
public int[] getScores() {
return scores;
}
+
public int getScoreOfWord(int i) {
return scores[i];
}
+
public int getScoreTotal() {
return scoreTotal;
}
+
public String getNewGame() {
return newGame;
}
+
+ public boolean getAlreadyPlayed() {
+ return alreadyPlayed;
+ }
}
public static class Check implements Serializable {
@@ -300,7 +310,8 @@ public class Network {
+ "&passwd=" + this.passwd
+ "&pgid=" + game.getGame().getPgid()
+ "&gid=" + game.getGame().getGid()
- + "&mode="+mode.value();
+ + "&mode="+mode.value()
+ + "&nb="+((DownloadedBaseGame)(game.getGame())).getNbWord();
// TODO : faut gere le mode
for (Integer i : game.getRelation1()) {
diff --git a/code/PtiClic/src/org/pticlic/model/TotalScore.java b/code/PtiClic/src/org/pticlic/model/TotalScore.java
@@ -1,45 +0,0 @@
-package org.pticlic.model;
-
-/**
- *
- * @author John CHARRON
- *
- */
-
-public class TotalScore {
-
- private TotalScore scoreTotal;
- private WordScore scores;
-
- public TotalScore() {
- }
-
- public TotalScore(TotalScore scoreTotal, WordScore wordscores) {
- this.scoreTotal = scoreTotal;
- this.scores = wordscores;
- }
-
- public TotalScore getScoreTotal() {
- return scoreTotal;
- }
-
- public void setScoreTotal(TotalScore scoreTotal) {
- this.scoreTotal = scoreTotal;
- }
-
- public WordScore getWordscores() {
- return scores;
- }
-
- public void setWordscores(WordScore wordscores) {
- this.scores = wordscores;
- }
-
- @Override
- public String toString() {
- return "TotalScore [scoreTotal=" + scoreTotal + ", wordscores="
- + scores + "]";
- }
-
-
-}
-\ No newline at end of file
diff --git a/code/PtiClic/src/org/pticlic/model/WordScore.java b/code/PtiClic/src/org/pticlic/model/WordScore.java
@@ -1,62 +0,0 @@
-package org.pticlic.model;
-
-/**
- *
- * @author John CHARRON
- *
- */
-
-public class WordScore {
-
- private int idmot;
- private double score;
- private double probaR1;
- private double probaR2;
-
- public WordScore() {}
-
- public WordScore(int idmot, double score, double probaR1, double probaR2) {
- this.idmot = idmot;
- this.score = score;
- this.probaR1 = probaR1;
- this.probaR2 = probaR2;
- }
-
- public int getIdmot() {
- return idmot;
- }
-
- public void setIdmot(int idmot) {
- this.idmot = idmot;
- }
-
- public double getScore() {
- return score;
- }
-
- public void setScore(double score) {
- this.score = score;
- }
-
- public double getProbaR1() {
- return probaR1;
- }
-
- public void setProbaR1(double probaR1) {
- this.probaR1 = probaR1;
- }
-
- public double getProbaR2() {
- return probaR2;
- }
-
- public void setProbaR2(double probaR2) {
- this.probaR2 = probaR2;
- }
-
- @Override
- public String toString() {
- return "WordScore [idmot=" + idmot + ", score=" + score + ", probaR1="
- + probaR1 + ", probaR2=" + probaR2 + "]";
- }
-}
diff --git a/code/serveur/php/pticlic.php b/code/serveur/php/pticlic.php
@@ -585,7 +585,7 @@ function setGame($user, $pgid, $gid, $answers)
function getGameScores($user, $pgid, $gid) {
$db = getDB();
$timestamp = $db->querySingle("SELECT timestamp FROM played_game WHERE pgid = $pgid and $gid = $gid and login = '$user';");
- if (timestamp == -1) {
+ if ($timestamp == -1) {
throw new Exception("Cette partie n'a jamais été jouée.", 4); // TODO : code d'erreur en doublon avec celui ci-dessous.
} else if ($timestamp == null) {
throw new Exception("Cette partie n'est associée à votre nom d'utilisateur.", 4);