Skip to content

Commit

Permalink
Add GamesAPI methods
Browse files Browse the repository at this point in the history
  • Loading branch information
aglitchman committed Oct 7, 2024
1 parent a7ed2a7 commit dd51191
Show file tree
Hide file tree
Showing 8 changed files with 250 additions and 7,571 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ And it's also a good idea to upload a demo build of YaGames to your game's draft
| `ysdk.features.LoadingAPI?.ready()` | `yagames.features_loadingapi_ready()` |
| `ysdk.features.GameplayAPI?.start()` | `yagames.features_gameplayapi_start()` |
| `ysdk.features.GameplayAPI?.stop()` | `yagames.features_gameplayapi_stop()` |
| `ysdk.features.GamesAPI?.getAllGames()` | `yagames.features_gamesapi_get_all_games(callback)`<br>The callback result is a table `{ games = { ... }, developerURL = "string" }` |
| `ysdk.features.GamesAPI?.getGameByID(appID)` | `yagames.features_gamesapi_get_game_by_id(app_id, callback)`<br>The callback result is a table `{ isAvailable = true/false, game = { appID = "string", title = "string", url = "string", coverURL = "string", iconURL = "string" } }` |
| **Feedback** [(docs)](https://yandex.ru/dev/games/doc/en/sdk/sdk-review) | |
| `ysdk.feedback.canReview()` | `yagames.feedback_can_review(callback)`<br>The callback result is a table `{ value = true/false, reason = "string" }` |
| `ysdk.feedback.requestReview()` | `yagames.feedback_request_review(callback)`<br>The callback result is a table `{ feedbackSent = true/false }` |
Expand Down
35 changes: 35 additions & 0 deletions example/ysdkdebug/pg_games_api.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
local druid = require("druid.druid")
local druid_style = require("example.ysdkdebug.druid_style")
local table_util = require("example.ysdkdebug.table_util")

local yagames = require("yagames.yagames")

local log_print = require("example.ysdkdebug.log_print")
local print = log_print.print

local M = {}

local game_id = 0

function M.get_all_games_handler(self)
yagames.features_gamesapi_get_all_games(function(self, err, result)
print("yagames.features_gamesapi_get_all_games:", err or table_util.tostring(result))
for _, game in ipairs(result.games) do
game_id = tonumber(game.appID)
break
end
end)
end

function M.get_game_by_id_handler(self)
yagames.features_gamesapi_get_game_by_id(game_id,function(self, err, result)
print("yagames.features_gamesapi_get_game_by_id(" .. tostring(game_id) .. "):", err or table_util.tostring(result))
end)
end

function M.init(self)
druid_style.make_button(self, "button_games_api_get_all_games", M.get_all_games_handler)
druid_style.make_button(self, "button_games_api_get_game_by_id", M.get_game_by_id_handler)
end

return M
Loading

0 comments on commit dd51191

Please sign in to comment.