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

136 lines
4.9 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 ____CardSystem = require("cards.CardSystem")
local CardBase = ____CardSystem.CardBase
local RegisterCard = ____CardSystem.RegisterCard
local ____CardBaseModifier = require("cards.CardBaseModifier")
local CardBaseModifier = ____CardBaseModifier.CardBaseModifier
local ____dota_ts_adapter = require("lib.dota_ts_adapter")
local registerModifier = ____dota_ts_adapter.registerModifier
local ____modifier_card_cursed = require("cards.modifier_card_cursed")
local addCursedStack = ____modifier_card_cursed.addCursedStack
local getCursedStackCount = ____modifier_card_cursed.getCursedStackCount
local removeCursedStack = ____modifier_card_cursed.removeCursedStack
local CARD_ID = 54
____exports.card_54 = __TS__Class()
local card_54 = ____exports.card_54
card_54.name = "card_54"
card_54.____file_path = "scripts/vscripts/cards/examples/card_54.lua"
__TS__ClassExtends(card_54, CardBase)
function card_54.prototype.GetModifierName(self)
return "modifier_card_54"
end
card_54 = __TS__Decorate(card_54, card_54, {RegisterCard}, {kind = "class", name = "card_54"})
____exports.card_54 = card_54
____exports.modifier_card_54 = __TS__Class()
local modifier_card_54 = ____exports.modifier_card_54
modifier_card_54.name = "modifier_card_54"
modifier_card_54.____file_path = "scripts/vscripts/cards/examples/card_54.lua"
__TS__ClassExtends(modifier_card_54, CardBaseModifier)
function modifier_card_54.prototype.____constructor(self, ...)
CardBaseModifier.prototype.____constructor(self, ...)
self.cursedApplied = false
self.levelOnPickup = 1
end
function modifier_card_54.prototype.getValue(self, key, fallback)
return self:getCardValue(key, fallback, CARD_ID)
end
function modifier_card_54.prototype.OnCustomCreated(self, params)
if not IsServer() then
return
end
self:capturePickupLevel()
self:applyCursed()
end
function modifier_card_54.prototype.OnDestroy(self)
if not IsServer() then
return
end
local hero = self:GetParent()
if not hero or not IsValidEntity(hero) then
return
end
if not self.cursedApplied then
return
end
removeCursedStack(nil, hero)
self.cursedApplied = false
end
function modifier_card_54.prototype.DeclareFunctions(self)
return {MODIFIER_PROPERTY_STATS_STRENGTH_BONUS, MODIFIER_PROPERTY_STATS_AGILITY_BONUS, MODIFIER_PROPERTY_STATS_INTELLECT_BONUS, MODIFIER_PROPERTY_TOOLTIP}
end
function modifier_card_54.prototype.GetModifierBonusStats_Strength(self)
local hero = self:GetParent()
if not hero or not IsValidEntity(hero) then
return 0
end
local level = self:getLevelsAfterPickup(hero)
local curses = getCursedStackCount(nil, hero)
if level <= 0 or curses <= 0 then
return 0
end
local strengthPenaltyPerLevel = self:getValue("strength_penalty_per_level", 1)
return -level * strengthPenaltyPerLevel * curses * self:getCardCopies()
end
function modifier_card_54.prototype.GetModifierBonusStats_Agility(self)
local hero = self:GetParent()
if not hero or not IsValidEntity(hero) then
return 0
end
local level = self:getLevelsAfterPickup(hero)
local curses = getCursedStackCount(nil, hero)
if level <= 0 or curses <= 0 then
return 0
end
local agilityPenaltyPerLevel = self:getValue("agility_penalty_per_level", 1)
return -level * agilityPenaltyPerLevel * curses * self:getCardCopies()
end
function modifier_card_54.prototype.GetModifierBonusStats_Intellect(self)
local hero = self:GetParent()
if not hero or not IsValidEntity(hero) then
return 0
end
local level = self:getLevelsAfterPickup(hero)
local curses = getCursedStackCount(nil, hero)
if level <= 0 or curses <= 0 then
return 0
end
local intellectPerLevel = self:getValue("intellect_per_level", 2)
return level * intellectPerLevel * curses * self:getCardCopies()
end
function modifier_card_54.prototype.applyCursed(self)
if self.cursedApplied then
return
end
local hero = self:GetParent()
if not hero or not IsValidEntity(hero) or not hero:IsRealHero() then
return
end
addCursedStack(nil, hero)
self.cursedApplied = true
end
function modifier_card_54.prototype.getLevelsAfterPickup(self, hero)
return math.max(
0,
hero:GetLevel() - self.levelOnPickup
)
end
function modifier_card_54.prototype.capturePickupLevel(self)
local hero = self:GetParent()
if not hero or not IsValidEntity(hero) or not hero:IsRealHero() then
return
end
self.levelOnPickup = hero:GetLevel()
end
modifier_card_54 = __TS__Decorate(
modifier_card_54,
modifier_card_54,
{registerModifier(nil)},
{kind = "class", name = "modifier_card_54"}
)
____exports.modifier_card_54 = modifier_card_54
return ____exports