From ed100a21db164ee762425a5ec6e6748d21f682e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Wed, 16 Mar 2011 13:16:54 +0100 Subject: [PATCH] =?UTF-8?q?Affichage=20des=20mots=20dans=20le=20score=20(n?= =?UTF-8?q?on=20test=C3=A9).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/PtiClic/src/org/pticlic/BaseScore.java | 43 ++++++++++++++++--- .../org/pticlic/model/DownloadedBaseGame.java | 4 +- .../src/org/pticlic/model/Network.java | 13 ++++-- code/serveur/php/pticlic.php | 2 +- 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 index 53a4f2a..991430e 100644 --- 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 index 981ae0c..9c3b048 100644 --- 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 index 0ddf9e3..7778671 100644 --- 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 index 9135c08..d55be19 100644 --- 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); }