commit ed100a21db164ee762425a5ec6e6748d21f682e1
parent 664035a4bf8dd6df09039b990e58aa08a4ae013a
Author: Georges Dupéron <jahvascriptmaniac+github@free.fr>
Date: Wed, 16 Mar 2011 13:16:54 +0100
Affichage des mots dans le score (non testé).
Diffstat:
4 files changed, 51 insertions(+), 11 deletions(-)
diff --git a/code/PtiClic/src/org/pticlic/BaseScore.java b/code/PtiClic/src/org/pticlic/BaseScore.java
@@ -1,7 +1,9 @@
package org.pticlic;
import org.pticlic.exception.PtiClicException;
+import org.pticlic.games.BaseGame;
import org.pticlic.model.Constant;
+import org.pticlic.model.DownloadedBaseGame;
import org.pticlic.model.Match;
import org.pticlic.model.Network;
import org.pticlic.model.Network.Mode;
@@ -85,15 +87,44 @@ public class BaseScore extends Activity implements OnClickListener{
this.networkStuff();
- ((TextView)findViewById(R.id.total)).setText("42");
// TODO : Attention, le cast en (BaseGame) n'est pas sûr !
- ((TextView)findViewById(R.id.scoreRel1)).setText("Foo1");
- ((TextView)findViewById(R.id.scoreRel2)).setText("Foo2");
- ((TextView)findViewById(R.id.scoreRel3)).setText("Foo3");
- ((TextView)findViewById(R.id.scoreRel4)).setText("Foo4");
+ DownloadedBaseGame bg = (DownloadedBaseGame)gamePlayed.getGame();
+ ((TextView)findViewById(R.id.total)).setText(String.valueOf(sr.getScoreTotal()));
+ ((TextView)findViewById(R.id.scoreRel1)).setText(bg.getCatString(1));
+ ((TextView)findViewById(R.id.scoreRel2)).setText(bg.getCatString(2));
+ ((TextView)findViewById(R.id.scoreRel3)).setText(bg.getCatString(3));
+ ((TextView)findViewById(R.id.scoreRel4)).setText(bg.getCatString(4));
+
+ String res;
+ res = "";
+ for (int i : gamePlayed.getRelation1()) {
+ res += bg.getWordInCloud(i).getName();
+ res += " (" + String.valueOf(sr.getScoreOfWord(i)) + "), ";
+ }
+ ((TextView)findViewById(R.id.scoreWords1)).setText(res);
+
+ res = "";
+ for (int i : gamePlayed.getRelation2()) {
+ res += bg.getWordInCloud(i).getName();
+ res += " (" + String.valueOf(sr.getScoreOfWord(i)) + "), ";
+ }
+ ((TextView)findViewById(R.id.scoreWords2)).setText(res);
+
+ res = "";
+ for (int i : gamePlayed.getRelation3()) {
+ res += bg.getWordInCloud(i).getName();
+ res += " (" + String.valueOf(sr.getScoreOfWord(i)) + "), ";
+ }
+ ((TextView)findViewById(R.id.scoreWords3)).setText(res);
+
+ res = "";
+ for (int i : gamePlayed.getRelation4()) {
+ res += bg.getWordInCloud(i).getName();
+ res += " (" + String.valueOf(sr.getScoreOfWord(i)) + "), ";
+ }
+ ((TextView)findViewById(R.id.scoreWords4)).setText(res);
((Button)findViewById(R.id.saw)).setOnClickListener(this);
-
}
@Override
diff --git a/code/PtiClic/src/org/pticlic/model/DownloadedBaseGame.java b/code/PtiClic/src/org/pticlic/model/DownloadedBaseGame.java
@@ -79,7 +79,9 @@ public class DownloadedBaseGame extends DownloadedGame {
}
public String getCatString(int numCat) {
- return Relation.getInstance().getRelationName(this.getCat(numCat));
+ return String.format(
+ Relation.getInstance().getRelationName(this.getCat(numCat)),
+ center.getName());
}
public int getCat1() {
diff --git a/code/PtiClic/src/org/pticlic/model/Network.java b/code/PtiClic/src/org/pticlic/model/Network.java
@@ -29,11 +29,18 @@ import com.google.gson.stream.JsonReader;
public class Network {
public static class ScoreResponse {
- private int score;
+ private int scoreTotal;
+ private int[] scores;
private String newGame;
public ScoreResponse() {}
- public int getScore() {
- return score;
+ public int[] getScores() {
+ return scores;
+ }
+ public int getScoreOfWord(int i) {
+ return scores[i];
+ }
+ public int getScoreTotal() {
+ return scoreTotal;
}
public String getNewGame() {
return newGame;
diff --git a/code/serveur/php/pticlic.php b/code/serveur/php/pticlic.php
@@ -547,7 +547,7 @@ function setGame($user, $pgid, $gid, $answers)
while ($row = $res->fetchArray())
{
$num = intval($row['num']);
- $nbScores = max($nbScores, $num);
+ $nbScores++;
if (!isset($answers[$num])) {
throw new Exception("Cette requête \"Set partie\" ne donne pas de réponse (une relation) pour le mot numéro $num de la partie.", 5);
}