public static String parseBattleModelInfo(BattleInfo battle, boolean spectatorMode) {…
- User
public static String parseBattleModelInfo(BattleInfo battle, boolean spectatorMode) { JSONObject json = new JSONObject(); json.put("resources"); json.put("kick_period_ms", 10000); json.put("map_id", battle.map.id.replace(".xml", "")); json.put("invisible_time", 3500); json.put("skybox_id", battle.map.skyboxId); json.put("spectator", spectatorMode); json.put("sound_id", battle.map.mapTheme.getAmbientSoundId()); json.put("game_mode", battle.map.mapTheme.getGameModeId()); return json.toJSONString(); } как к этому resources добавить это ["smoky_m0","wasp_m0","green_m0"]
- Assistant
Чтобы добавить массив ресурсов к полю "resources", вы можете использовать метод
putс ключом "resources" и значением в виде массива строк:public static String parseBattleModelInfo(BattleInfo battle, boolean spectatorMode) { JSONObject json = new JSONObject(); json.put("resources", new String[]{"smoky_m0", "wasp_m0", "green_m0"}); json.put("kick_period_ms", 10000); json.put("map_id", battle.map.id.replace(".xml", "")); json.put("invisible_time", 3500); json.put("skybox_id", battle.map.skyboxId); json.put("spectator", spectatorMode); json.put("sound_id", battle.map.mapTheme.getAmbientSoundId()); json.put("game_mode", battle.map.mapTheme.getGameModeId()); return json.toJSONString(); }Это обновит JSON-объект и добавит поле "resources" со значением
["smoky_m0","wasp_m0","green_m0"]. - User
public static String parseBattleModelInfo(BattleInfo battle, boolean spectatorMode, User garage) { JSONObject json = new JSONObject(); json.put("resources", {"turret_id", "hull_id", "colormap_id"}); json.put("kick_period_ms", 10000); json.put("map_id", battle.map.id.replace(".xml", "")); json.put("invisible_time", 3500); json.put("skybox_id", battle.map.skyboxId); json.put("spectator", spectatorMode); json.put("sound_id", battle.map.mapTheme.getAmbientSoundId()); json.put("game_mode", battle.map.mapTheme.getGameModeId()); return json.toJSONString(); } как в resources вызвать гыук
- Assistant
To add the values from the
garageobject to the "resources" field, you can access the properties using thegetmethod and store them in an array. Here's an example:public static String parseBattleModelInfo(BattleInfo battle, boolean spectatorMode, User garage) { JSONObject json = new JSONObject(); json.put("resources", new String[]{garage.getTurretId(), garage.getHullId(), garage.getColormapId()}); json.put("kick_period_ms", 10000); json.put("map_id", battle.map.id.replace(".xml", "")); json.put("invisible_time", 3500); json.put("skybox_id", battle.map.skyboxId); json.put("spectator", spectatorMode); json.put("sound_id", battle.map.mapTheme.getAmbientSoundId()); json.put("game_mode", battle.map.mapTheme.getGameModeId()); return json.toJSONString(); }This assumes that the
Userclass has getters (getTurretId(),getHullId(),getColormapId()) to access the respective properties. Replace them with the actual getters from yourUserclass.