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

127 lines
4.5 KiB
Lua

local ____lualib = require("lualib_bundle")
local __TS__Class = ____lualib.__TS__Class
local __TS__ClassExtends = ____lualib.__TS__ClassExtends
local __TS__Decorate = ____lualib.__TS__Decorate
local ____exports = {}
local ____card_catalog = require("card_catalog")
local FROSTMOURNE_SHARD_CARD_IDS = ____card_catalog.FROSTMOURNE_SHARD_CARD_IDS
local ____dota_ts_adapter = require("lib.dota_ts_adapter")
local BaseModifier = ____dota_ts_adapter.BaseModifier
local registerModifier = ____dota_ts_adapter.registerModifier
____exports.CURSED_MODIFIER_NAME = "modifier_card_cursed"
--- Карта 80: пакт выполнен — проклятие не усиливает входящий урон.
____exports.CURSED_PACT_COMPLETE_MODIFIER = "modifier_card_80_pact_complete"
--- ID карт для «Трёх долгов» (карта 68): проклятые карты и осколки Фростморна (81–83), если они в пуле колоды.
-- Синхронизируй при добавлении новых проклятых карт.
____exports.CURSED_POOL_CARD_IDS = {
7,
8,
9,
17,
30,
31,
52,
54,
68,
69,
unpack(FROSTMOURNE_SHARD_CARD_IDS)
}
function ____exports.isCursedPoolCardId(self, cardId)
for ____, id in ipairs(____exports.CURSED_POOL_CARD_IDS) do
if id == cardId then
return true
end
end
return false
end
--- Положительный % к входящему урону за один стак проклятия (суммируется со стаками).
local INCOMING_DAMAGE_PCT_PER_CURSE_STACK = 25
____exports.modifier_card_cursed = __TS__Class()
local modifier_card_cursed = ____exports.modifier_card_cursed
modifier_card_cursed.name = "modifier_card_cursed"
modifier_card_cursed.____file_path = "scripts/vscripts/cards/modifier_card_cursed.lua"
__TS__ClassExtends(modifier_card_cursed, BaseModifier)
function modifier_card_cursed.prototype.DeclareFunctions(self)
return {MODIFIER_PROPERTY_TOOLTIP, MODIFIER_PROPERTY_INCOMING_DAMAGE_PERCENTAGE}
end
function modifier_card_cursed.prototype.GetModifierIncomingDamage_Percentage(self)
if not IsServer() then
return 0
end
local parent = self:GetParent()
if parent and IsValidEntity(parent) and parent:HasModifier(____exports.CURSED_PACT_COMPLETE_MODIFIER) then
return 0
end
return self:GetStackCount() * INCOMING_DAMAGE_PCT_PER_CURSE_STACK
end
function modifier_card_cursed.prototype.GetTooltip(self)
return "dota_tooltip_modifier_modifier_card_cursed_Description"
end
function modifier_card_cursed.prototype.OnTooltip(self)
return self:GetStackCount()
end
function modifier_card_cursed.prototype.IsHidden(self)
return false
end
function modifier_card_cursed.prototype.IsDebuff(self)
return false
end
function modifier_card_cursed.prototype.IsPurgable(self)
return false
end
function modifier_card_cursed.prototype.RemoveOnDeath(self)
return false
end
function modifier_card_cursed.prototype.GetTexture(self)
return "doom_bringer_doom"
end
modifier_card_cursed = __TS__Decorate(
modifier_card_cursed,
modifier_card_cursed,
{registerModifier(nil)},
{kind = "class", name = "modifier_card_cursed"}
)
____exports.modifier_card_cursed = modifier_card_cursed
function ____exports.addCursedStack(self, hero)
if not IsServer() or not hero or not IsValidEntity(hero) then
return
end
local modifier = hero:FindModifierByName(____exports.CURSED_MODIFIER_NAME)
if not modifier then
modifier = hero:AddNewModifier(
hero,
getModifierSourceAbility(nil, hero),
____exports.CURSED_MODIFIER_NAME,
{}
)
end
if not modifier then
return
end
modifier:SetStackCount(modifier:GetStackCount() + 1)
hero:CalculateStatBonus(true)
end
function ____exports.removeCursedStack(self, hero)
if not IsServer() or not hero or not IsValidEntity(hero) then
return
end
local modifier = hero:FindModifierByName(____exports.CURSED_MODIFIER_NAME)
if not modifier then
return
end
local nextCount = modifier:GetStackCount() - 1
if nextCount <= 0 then
modifier:Destroy()
return
end
modifier:SetStackCount(nextCount)
end
function ____exports.getCursedStackCount(self, hero)
if not hero or not IsValidEntity(hero) then
return 0
end
local modifier = hero:FindModifierByName(____exports.CURSED_MODIFIER_NAME)
return modifier and modifier:GetStackCount() or 0
end
return ____exports