79 lines
2.9 KiB
Lua
79 lines
2.9 KiB
Lua
local ____lualib = require("lualib_bundle")
|
|
local __TS__ObjectAssign = ____lualib.__TS__ObjectAssign
|
|
local __TS__ObjectEntries = ____lualib.__TS__ObjectEntries
|
|
local ____exports = {}
|
|
local ____card_catalog = require("card_catalog")
|
|
local ALL_CARD_CATALOG_DEFS = ____card_catalog.ALL_CARD_CATALOG_DEFS
|
|
local ____CardSystem = require("cards.CardSystem")
|
|
local CardQuality = ____CardSystem.CardQuality
|
|
local CardSystem = ____CardSystem.CardSystem
|
|
local function iconForId(self, id)
|
|
return ("file://{images}/custom_game/cards/card_" .. tostring(id)) .. ".png"
|
|
end
|
|
local function catalogRowToCardData(self, row)
|
|
return {
|
|
id = row.id,
|
|
name = ("card_" .. tostring(row.id)) .. "_name",
|
|
description = ("card_" .. tostring(row.id)) .. "_description",
|
|
quality = row.quality,
|
|
icon = iconForId(nil, row.id),
|
|
default = row.defaultCard,
|
|
inherent = row.inherent == true,
|
|
purchasable = row.purchasable ~= false,
|
|
obtainable = row.obtainable ~= false,
|
|
canupgrade = row.canupgrade ~= false,
|
|
disabled = row.obtainable == false and row.deck_builder_non_deckable ~= true,
|
|
values = row.values,
|
|
max_copies = row.max_copies,
|
|
deck_slots = row.deck_slots or 1,
|
|
deck_builder_non_deckable = row.deck_builder_non_deckable == true,
|
|
deck_builder_unlock_card_id = row.deck_builder_unlock_card_id,
|
|
template = row.template,
|
|
title = row.title,
|
|
body = row.body
|
|
}
|
|
end
|
|
____exports.CARD_DATABASE = {}
|
|
for ____, row in ipairs(ALL_CARD_CATALOG_DEFS) do
|
|
____exports.CARD_DATABASE[row.id] = catalogRowToCardData(nil, row)
|
|
end
|
|
____exports.CARD_DATABASE[404] = {
|
|
id = 404,
|
|
name = "card_404_name",
|
|
description = "card_404_description",
|
|
quality = CardQuality.COMMON,
|
|
values = {},
|
|
disabled = true,
|
|
inherent = false,
|
|
purchasable = false,
|
|
obtainable = false,
|
|
icon = "file://{images}/custom_game/cards/card_404.png"
|
|
}
|
|
____exports.CARD_DATABASE[86] = {
|
|
id = 86,
|
|
name = "card_86_name",
|
|
description = "card_86_description",
|
|
quality = CardQuality.COMMON,
|
|
values = {},
|
|
disabled = true,
|
|
inherent = false,
|
|
purchasable = false,
|
|
obtainable = false,
|
|
deck_builder_non_deckable = true,
|
|
icon = "file://{images}/custom_game/cards/card_86.png"
|
|
}
|
|
--- Инициализация базы данных карт
|
|
function ____exports.InitializeCardDatabase(self)
|
|
local result = {}
|
|
for ____, ____value in ipairs(__TS__ObjectEntries(____exports.CARD_DATABASE)) do
|
|
local idRaw = ____value[1]
|
|
local data = ____value[2]
|
|
local id = tonumber(idRaw)
|
|
local hasCustomCardClass = CardSystem.cardTypes["card_" .. tostring(id)] ~= nil
|
|
local disabledByMissingCustomClass = id ~= 404 and id ~= 86 and not hasCustomCardClass
|
|
result[id] = __TS__ObjectAssign({}, data, {disabled = data.disabled == true or disabledByMissingCustomClass})
|
|
end
|
|
CardSystem.cardData = result
|
|
end
|
|
return ____exports
|