-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7b6a03b
commit 2ad3062
Showing
8 changed files
with
219 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
local gamepush = require("gamepush.gamepush") | ||
local utils = require("example.utils") | ||
|
||
local event_tag = "my_event" | ||
|
||
local function join() | ||
gamepush.events.join({ tag = event_tag }, function(result) | ||
utils.to_log("Join event:", result) | ||
end) | ||
end | ||
|
||
local function list() | ||
utils.to_log("List events:", gamepush.events.list()) | ||
end | ||
|
||
local function active_list() | ||
utils.to_log("Active list events:", gamepush.events.active_list()) | ||
end | ||
|
||
local function get_event() | ||
utils.to_log("Get event:", gamepush.events.get_event(event_tag)) | ||
end | ||
|
||
local function has() | ||
utils.to_log("Event has:", gamepush.events.has(event_tag)) | ||
end | ||
|
||
local function is_joined() | ||
utils.to_log("Is joined:", gamepush.events.is_joined(event_tag)) | ||
end | ||
|
||
local M = { | ||
{ name = "Join", callback = join }, | ||
{ name = "List", callback = list }, | ||
{ name = "Active list", callback = active_list }, | ||
{ name = "Get event", callback = get_event }, | ||
{ name = "Has", callback = has }, | ||
{ name = "Is joined", callback = is_joined }, | ||
} | ||
|
||
gamepush.events.callbacks.join = function(reward) | ||
utils.to_console("Join event:", reward) | ||
end | ||
gamepush.events.callbacks.error_join = function(error) | ||
utils.to_console("Join event error:", error) | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
local M = {} | ||
local core = require("gamepush.core.core") | ||
local helpers = require("gamepush.core.helpers") | ||
local callbacks = require("gamepush.core.callbacks") | ||
|
||
---Принять участие в событии | ||
---@param parameters table параметры | ||
---@param callback function функция обратного вызова по результату принятия участия в событии: callback(result) | ||
function M.join(parameters, callback) | ||
helpers.check_table_required(parameters) | ||
helpers.check_callback(callback) | ||
core.call_api("events.join", { parameters }, callback) | ||
end | ||
|
||
---Список событий | ||
---@return table результат | ||
function M.list() | ||
return core.call_api("events.list") | ||
end | ||
|
||
---Список активных событий игрока | ||
---@return table результат | ||
function M.active_list() | ||
return core.call_api("events.activeList") | ||
end | ||
|
||
---Получение информации о событии | ||
---@param id_or_tag string|number тег или идентификатор события | ||
---@return table результат | ||
function M.get_event(id_or_tag) | ||
helpers.check_string_or_number(id_or_tag, "id_or_tag") | ||
return core.call_api("events.getEvent", id_or_tag) | ||
end | ||
|
||
---Событие активно | ||
---@param id_or_tag string|number тег или идентификатор награды | ||
---@return boolean результат | ||
function M.has(id_or_tag) | ||
helpers.check_string_or_number(id_or_tag, "id_or_tag") | ||
return core.call_api("events.has", id_or_tag) == true | ||
end | ||
|
||
---Игрок участвует в событии | ||
---@param id_or_tag string|number тег или идентификатор награды | ||
---@return boolean результат | ||
function M.is_joined(id_or_tag) | ||
helpers.check_string_or_number(id_or_tag, "id_or_tag") | ||
return core.call_api("events.isJoined", id_or_tag) == true | ||
end | ||
|
||
M.callbacks = callbacks.events | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters