diff --git a/src/server/ClientGame.java b/src/server/ClientGame.java index fbaeeb3..05671ab 100644 --- a/src/server/ClientGame.java +++ b/src/server/ClientGame.java @@ -15,7 +15,6 @@ import org.json.JSONTokener; import card.Card; -import player.BasePlayer; public abstract class ClientGame extends BaseGame { @@ -34,10 +33,12 @@ volatile int ownId; // TODO lock? public ClientGame(){ + System.out.println("ctor"); preinit(); } protected void preinit(){ + System.out.println("Preinit"); port = 1337; hostName = "localhost"; isConnected = false; @@ -74,8 +75,8 @@ @Override protected void init() { + System.out.println("init"); super.init(); - createUI(); } @Override protected void createHistory() { @@ -88,6 +89,7 @@ } protected void loadOptions(){ + System.out.println("loadOptions"); try { JSONTokener tokener = new JSONTokener(options.toURI().toURL().openStream()); root = new JSONObject(tokener); @@ -122,8 +124,26 @@ send(msgType, c.toJson().toString()); } + protected void moveHint(boolean isValue, int value, int playerId){ + moveHint(isValue, value, playerId, false); + } + + protected void moveHint(boolean isValue, int value, int playerId, boolean isDry){ + byte msgType = isDry ? MOVE_HINT | MOVE_DRY : MOVE_HINT; + JSONObject msg = new JSONObject(); + if(isValue){ + msg.put("type", HINT_VALUE); + } + else { + msg.put("type", HINT_COLOR); + } + msg.put("value", value); + msg.put("player_id", playerId); + send(msgType, msg.toString()); + } + protected void moveHint(Card c){ - movePlaceCard(c, false); + moveHint(c, false); } protected void moveHint(Card c, boolean isDry) { @@ -132,6 +152,7 @@ } private void send(byte msgType, String msg) { + System.out.println("send " + msg); DataOutputStream os = null; try { os = new DataOutputStream(socket.getOutputStream()); @@ -215,18 +236,23 @@ ownId = jo.getInt("id"); break; case MOVE_UPDATE: + System.out.println("received update"); if(!initGameReceived){ + System.out.println("first update!"); // TODO move createXY() somewhere else? createDeck(); createTrash(); loadOptions(); loadFont(); - updateGame(jo); init(); + updateGame(jo); + createUI(); initGameReceived = true; break; } + System.out.println("Client updating game..."); updateGame(jo); + System.out.println("Client updating UI..."); updateUI(); break; }