diff --git a/schema/getLeaderboard.json b/schema/getLeaderboard.json index e689d24..b046c42 100644 --- a/schema/getLeaderboard.json +++ b/schema/getLeaderboard.json @@ -9,11 +9,12 @@ "properties": { "components": { "type": "ref", - "ref": "dev.tsunagite.game#scoreComponentMap" + "ref": "dev.tsunagite.game#scoreComponentMap", + "description": "The components used in the game's scores. Only present when listComponents is true." }, "componentOrder": { "type": "array", - "description": "The order in which components should be displayed in a leaderboard table.", + "description": "The order in which components should be displayed in a leaderboard table. Only present when listComponents is true.", "items": { "type": "string", "format": "record-key" @@ -72,10 +73,16 @@ } }, "mode": { - "type": "string" + "type": "string", + "description": "The game mode to display a leaderboard for. Must be a value from the game's modes." }, "inputMethod": { - "type": "string" + "type": "string", + "description": "The input method to display a leaderboard for. Must be a value from the game's input methods." + }, + "listComponents": { + "type": "boolean", + "description": "Whether to include the game's score components and order in the response." } }, "required": ["chart"] diff --git a/scripts/getLeaderboard.lua b/scripts/getLeaderboard.lua index 20bbdf9..23b3fea 100644 --- a/scripts/getLeaderboard.lua +++ b/scripts/getLeaderboard.lua @@ -15,7 +15,7 @@ function handle() local tableName = getTableName(chart.game) local componentOrder = game.componentOrder - if not componentOrder then + if not componentOrder and params.listComponents then componentOrder = toarray({}) local i = 0 for k, _ in game.scoreComponents do @@ -81,7 +81,11 @@ function handle() entry["score"] = db.get(row.uri) table.insert(leaderboard, entry) end - local result = {["scores"] = leaderboard, ["components"] = game.scoreComponents, ["componentOrder"] = componentOrder} + local result = {["scores"] = leaderboard} + if params.listComponents then + result["components"] = game.scoreComponents + result["componentOrder"] = componentOrder + end return result end