Files
Dota-Zombie-Invasion/scripts/vscripts/contracts/contract_generator.lua
T
2026-05-29 15:11:31 +07:00

35 lines
1.9 KiB
Lua

local ____lualib = require("lualib_bundle")
local __TS__NumberToFixed = ____lualib.__TS__NumberToFixed
local ____exports = {}
local function isoLikeTimestamp(self)
local ms = math.floor(GameRules:GetGameTime() * 1000)
return (("game_" .. tostring(ms)) .. "_") .. tostring(RandomInt(10000, 99999))
end
local function buildModifiersForTier(self, tier)
local mult = 1 + tier * 0.08
return {{modifier_id = "contract_strain", title = "Напряжение", description = "Дополнительный множатель сложности от контракта.", value = mult}}
end
--- Черновик до SaveDroppedContract; финальный id — с бэкенда.
function ____exports.generateContractDraft(self, ownerSteamId, tier, draftInstanceId)
local seed = (draftInstanceId .. "_") .. tostring(RandomInt(1, 2147483647))
local difficulty_multiplier = 1 + tier * 0.1
local name = tier <= 1 and "Пакт выжившего" or (tier == 2 and "Условие крови" or (tier == 3 and "Клятва бездны" or "Смертельный завет"))
local description = ((("Контракт " .. tostring(tier)) .. " тира. Дополнительно ×") .. __TS__NumberToFixed(difficulty_multiplier, 2)) .. " к масштабу врагов (поверх сложности)."
return {
contract_instance_id = draftInstanceId,
owner_steam_id = ownerSteamId,
tier = tier,
name = name,
description = description,
seed = seed,
difficulty_multiplier = difficulty_multiplier,
modifiers = buildModifiersForTier(nil, tier),
durability = 3,
is_broken = false,
source = "impossible_win_drop",
created_at = isoLikeTimestamp(nil),
application_conditions = "Активен только при подтверждённом контракте матча и сложности Impossible."
}
end
return ____exports