Skip to content

Commit 51dd2cf

Browse files
shift values moved from map.config to map.json
1 parent e0d3df6 commit 51dd2cf

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

map.config

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ WORKER_MAX_CARRYING_RESOURCE_AMOUNT = 10;
2020
# SCORPION = Soldier, ANT = Worker :)
2121
INIT_SCORPIONS = 0
2222
INIT_ANTS = 4
23-
SHIFT_X = 0
24-
SHIFT_Y = 0
2523

2624
# server runtime configs
2725
READ_MAP_FROM_FILE = true

map.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"MAP_HEIGHT": 32,
33
"MAP_WIDTH": 32,
4+
"SHIFT_X": 0,
5+
"SHIFT_Y": 0,
46
"cells_type": [
57
{ "row": 0, "col": 0, "cell_type": 3, "rec1": 0, "rec2": 0 },
68
{ "row": 0, "col": 1, "cell_type": 3, "rec1": 0, "rec2": 0 },

src/main/java/ir/sharif/aichallenge/server/logic/config/ConfigReader.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,6 @@ public static void readConfigFile() {
5656
} catch (Exception ignored) {
5757
AntGenerator.PROCESS_TIMEOUT_SECONDS = 30;
5858
}
59-
try {
60-
ConstConfigs.SHIFT_X = Integer.parseInt(props.getProperty("SHIFT_X"));
61-
} catch (Exception ignore) {
62-
63-
}
64-
try {
65-
ConstConfigs.SHIFT_Y = Integer.parseInt(props.getProperty("SHIFT_Y"));
66-
} catch (Exception ignore) {
67-
68-
}
6959
} catch (Exception e) {
7060
e.printStackTrace();
7161
Log.e("ConfigReader", "error in config props");

src/main/java/ir/sharif/aichallenge/server/logic/utility/JsonUtility.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,22 @@
1717

1818
public class JsonUtility {
1919

20-
public static ExternalMap readMapFromFile(String fileName)
21-
throws IOException, ParseException {
20+
public static ExternalMap readMapFromFile(String fileName) throws IOException, ParseException {
2221

2322
JSONParser jsonParser = new JSONParser();
2423
try (FileReader reader = new FileReader(fileName)) {
2524
JSONObject map = (JSONObject) jsonParser.parse(reader);
2625
try {
2726
ConstConfigs.MAP_HEIGHT = ((Long) map.get("MAP_HEIGHT")).intValue();
2827
ConstConfigs.MAP_WIDTH = ((Long) map.get("MAP_WIDTH")).intValue();
28+
try {
29+
ConstConfigs.SHIFT_X = ((Long) map.get("SHIFT_X")).intValue();
30+
} catch (Exception ignore) {
31+
}
32+
try {
33+
ConstConfigs.SHIFT_Y = ((Long) map.get("SHIFT_Y")).intValue();
34+
} catch (Exception ignore) {
35+
}
2936
} catch (Exception e) {
3037
Log.e("JsonUtility", "MAP_HEIGHT or MAP_WIDTH is not available in map.json!");
3138
System.exit(-1);

0 commit comments

Comments
 (0)