Files
Dota-Zombie-Invasion/scripts/vscripts/cards/examples/card_30.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 = 30
____exports.card_30 = __TS__Class()
local card_30 = ____exports.card_30
card_30.name = "card_30"
card_30.____file_path = "scripts/vscripts/cards/examples/card_30.lua"
__TS__ClassExtends(card_30, CardBase)
function card_30.prototype.GetModifierName(self)
return "modifier_card_30"
end
card_30 = __TS__Decorate(card_30, card_30, {RegisterCard}, {kind = "class", name = "card_30"})
____exports.card_30 = card_30
____exports.modifier_card_30 = __TS__Class()
local modifier_card_30 = ____exports.modifier_card_30
modifier_card_30.name = "modifier_card_30"
modifier_card_30.____file_path = "scripts/vscripts/cards/examples/card_30.lua"
__TS__ClassExtends(modifier_card_30, CardBaseModifier)
function modifier_card_30.prototype.____constructor(self, ...)
CardBaseModifier.prototype.____constructor(self, ...)
self.cursedApplied = false
self.levelOnPickup = 1
end
function modifier_card_30.prototype.getValue(self, key, fallback)
return self:getCardValue(key, fallback, CARD_ID)
end
function modifier_card_30.prototype.OnCustomCreated(self, params)
if not IsServer() then
return
end
self:capturePickupLevel()
self:applyCursed()
end
function modifier_card_30.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_30.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_30.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 strengthPerLevel = self:getValue("strength_per_level", 2)
return level * strengthPerLevel * curses * self:getCardCopies()
end
function modifier_card_30.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_30.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 intellectPenaltyPerLevel = self:getValue("intellect_penalty_per_level", 1)
return -level * intellectPenaltyPerLevel * curses * self:getCardCopies()
end
function modifier_card_30.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_30.prototype.getLevelsAfterPickup(self, hero)
return math.max(
0,
hero:GetLevel() - self.levelOnPickup
)
end
function modifier_card_30.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_30 = __TS__Decorate(
modifier_card_30,
modifier_card_30,
{registerModifier(nil)},
{kind = "class", name = "modifier_card_30"}
)
____exports.modifier_card_30 = modifier_card_30
return ____exports