Welcome to the Umamusume Wiki! If you want to contribute, please read the guidelines.
Module:Game/Supports/Data/Events
Documentation for this module may be created at Module:Game/Supports/Data/Events/doc
--[[
!! THIS PAGE IS MANAGED BY GITLAB !!
ANY EDITS TO PAGE CONTENT WILL BE OVERWRITTEN
TO MAKE CHANGES, PLEASE SUBMIT A MERGE REQUEST AT https://gitlab.com/umamusume-wiki/lua-modules
]]
local Events = {}
local Game = require("Module:Game")
local Data = require("Module:Game/TrainingEvents/Data")
---Get a list of events for the given support card and character IDs
---@param supportIds string[] list of support card ids
---@param charaIds string[] list of character ids
---@return [TrainingEventData[][], TrainingEventData[][]] cardEvents list of events by [support id, character id]
function Events.getSupportCardEvents(supportIds, charaIds)
local supportIdsInsert = table.concat(supportIds, ',')
local charaIdsInsert = table.concat(charaIds, ',')
local single_mode_story_datas = Game.queryMaster {
from = "single_mode_story_data",
where = string.format("(support_card_id IN (%s) OR support_chara_id IN (%s)) AND gallery_flag = 2", supportIdsInsert, charaIdsInsert)
}
local eventIds = {}
for _, single_mode_story_data in ipairs(single_mode_story_datas) do
table.insert(eventIds, single_mode_story_data.id)
end
local trainingEventMap = Data.getTrainingEvents(eventIds)
local supportEventList = {}
local charaEventList = {}
for _, single_mode_story_data in ipairs(single_mode_story_datas) do
local mapped = trainingEventMap[single_mode_story_data.id]
if mapped ~= nil then
if tonumber(single_mode_story_data.support_card_id) > 0 then
local key = single_mode_story_data.support_card_id
if not supportEventList[key] then supportEventList[key] = {} end
table.insert(supportEventList[key], mapped)
end
if tonumber(single_mode_story_data.support_chara_id) > 0 then
local key = single_mode_story_data.support_chara_id
if not charaEventList[key] then charaEventList[key] = {} end
table.insert(charaEventList[key], mapped)
end
end
end
return { supportEventList, charaEventList }
end
return Events