Skip to content

Commit 1af9561

Browse files
add teams names as arguments
1 parent a50a3a2 commit 1af9561

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

src/main/java/ir/sharif/aichallenge/server/common/network/JsonSocket.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ public JsonObject get() throws IOException {
141141
* @see com.google.gson.Gson#fromJson(String, Class)
142142
* @see #get
143143
*/
144+
public int id;
145+
144146
public <T> T get(Class<T> classOfInput) throws IOException {
145147
int length = 1000, total = 0, current;
146148
byte buffer[] = new byte[length];
@@ -163,7 +165,7 @@ public <T> T get(Class<T> classOfInput) throws IOException {
163165
}
164166
String json = new String(buffer, 0, total, ENCODING);
165167
if (GameHandler.showGameLog)
166-
Log.i(TAG, "Message received: " + json);
168+
Log.i(TAG, "Message received from " + id + ": " + json);
167169
T result = null;
168170
try {
169171
result = Json.GSON.fromJson(json, classOfInput);

src/main/java/ir/sharif/aichallenge/server/engine/config/Configs.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ private static void handleArg(String arg) {
8585
GameHandler.runManually = true;
8686
} else if (split[0].equals("--read-map")) {
8787
MAP_PATH = split[1];
88+
} else if (split[0].equals("--first-team-name")) {
89+
FIRST_TEAM_NAME = split[1];
90+
} else if (split[0].equals("--second-team-name")) {
91+
SECOND_TEAM_NAME = split[1];
8892
}
8993
}
9094

src/main/java/ir/sharif/aichallenge/server/engine/network/ClientHandler.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ private void receive() throws IOException, InterruptedException {
301301
lastReceivedMessage = null;
302302
if (receiveTerminateFlag)
303303
return;
304+
client.id = getId();
304305
lastReceivedMessage = client.get(ClientMessage.class);
305306
synchronized (messageNotifier) {
306307
messageNotifier.notifyAll();

0 commit comments

Comments
 (0)