From 26eba47168be6899f3fccabe02bc3263c325c6cc Mon Sep 17 00:00:00 2001 From: NoxArt Date: Tue, 19 Nov 2013 18:18:38 +0100 Subject: [PATCH] Fixed sendWords, added round argument, commented sendEvaluations (will focus on auto now) --- src/cz/fit/tam/model/Game.java | 6 ++++-- src/cz/fit/tam/model/GameClient.java | 22 ++++++++++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/cz/fit/tam/model/Game.java b/src/cz/fit/tam/model/Game.java index f5f16e0..e04a45f 100644 --- a/src/cz/fit/tam/model/Game.java +++ b/src/cz/fit/tam/model/Game.java @@ -122,7 +122,7 @@ public void leave() { stopped = true; } - public void sendWords(String[] words) { + public void sendWords(Integer round, String[] words) { if (isConnected()) { throw new IllegalStateException(); } @@ -131,9 +131,10 @@ public void sendWords(String[] words) { throw new GameIsStoppedException(); } - client.sendWords(words); + client.sendWords(round, words); } + /* public void sendEvaluations(Map evaluations) { if (isConnected()) { throw new IllegalStateException(); @@ -145,5 +146,6 @@ public void sendEvaluations(Map evaluations) { client.sendEvaluation(evaluations); } + */ } diff --git a/src/cz/fit/tam/model/GameClient.java b/src/cz/fit/tam/model/GameClient.java index eb71014..aaa1d81 100644 --- a/src/cz/fit/tam/model/GameClient.java +++ b/src/cz/fit/tam/model/GameClient.java @@ -168,13 +168,18 @@ public void leave(Integer gameId) { } } - public void sendWords(String[] words) { + public void sendWords(Integer round, String[] words) { Map arguments = new HashMap(); arguments.put("command", GameClient.COMMAND_POST_MESSAGE); arguments.put("game_id", gameId.toString()); - arguments.put("token", player.getToken().getValue()); - arguments.put("action", GameClient.ACTION_SEND_WORDS); - arguments.put("words", combine(words)); + arguments.put("token", player.getToken().getValue()); + + Map data = new HashMap(); + data.put("action", GameClient.ACTION_SEND_WORDS); + data.put("round", round.toString()); + data.put("words", combine(words)); + + arguments.put("data", (new JSONObject(data)).toString()); try { messaging.sendMessage(arguments); @@ -186,13 +191,17 @@ public void sendWords(String[] words) { } } + /* public void sendEvaluation(Map evaluations) { Map arguments = new HashMap(); arguments.put("command", GameClient.COMMAND_POST_MESSAGE); arguments.put("game_id", gameId.toString()); arguments.put("token", player.getToken().getValue()); - arguments.put("action", GameClient.ACTION_SEND_EVALUATION); - arguments.put("evaluations", combine(evaluations)); + + Map data = new HashMap(); + data.put("action", GameClient.ACTION_SEND_EVALUATION); + data.put("evaluations", combine(evaluations)); + try { messaging.sendMessage(arguments); @@ -203,6 +212,7 @@ public void sendEvaluation(Map evaluations) { throw new CommandFailedException(ex); } } + */ public List getGames() { return getGames(null);