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

94 lines
3.6 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 ShowCardSelectionExactOptionsToPlayer = ____CardSystem.ShowCardSelectionExactOptionsToPlayer
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 ____card_catalog = require("card_catalog")
local SMALL_MANA_SURGE_CARD_ID = ____card_catalog.SMALL_MANA_SURGE_CARD_ID
local CARD_ID = 33
local SMALL_MANA_SURGE_SOURCE = "card_33_small_mana_surge"
____exports.card_33 = __TS__Class()
local card_33 = ____exports.card_33
card_33.name = "card_33"
card_33.____file_path = "scripts/vscripts/cards/examples/card_33.lua"
__TS__ClassExtends(card_33, CardBase)
function card_33.prototype.OnCreated(self)
if not IsServer() then
return
end
local hero = self:GetHero()
if not hero or not IsValidEntity(hero) or not hero:IsRealHero() then
return
end
local playerId = hero:GetPlayerOwnerID()
if playerId == nil or playerId == nil or playerId < 0 then
return
end
local player = PlayerResource:GetPlayer(playerId)
local ____opt_0 = player and player.cardSystem
local level = ____opt_0 and ____opt_0:GetCardLevel(CARD_ID) or 1
if level >= 3 then
ShowCardSelectionExactOptionsToPlayer(nil, playerId, {SMALL_MANA_SURGE_CARD_ID}, SMALL_MANA_SURGE_SOURCE)
end
end
function card_33.prototype.GetModifierName(self)
return "modifier_card_33"
end
card_33 = __TS__Decorate(card_33, card_33, {RegisterCard}, {kind = "class", name = "card_33"})
____exports.card_33 = card_33
____exports.modifier_card_33 = __TS__Class()
local modifier_card_33 = ____exports.modifier_card_33
modifier_card_33.name = "modifier_card_33"
modifier_card_33.____file_path = "scripts/vscripts/cards/examples/card_33.lua"
__TS__ClassExtends(modifier_card_33, CardBaseModifier)
function modifier_card_33.prototype.____constructor(self, ...)
CardBaseModifier.prototype.____constructor(self, ...)
self.manaBonusSnapshot = 0
end
function modifier_card_33.prototype.getValue(self, key, fallback)
return self:getCardValue(key, fallback, CARD_ID)
end
function modifier_card_33.prototype.addManaSnapshotBonus(self)
local hero = self:GetParent()
if not hero or not IsValidEntity(hero) then
return
end
local manaIncreasePct = self:getValue("mana_increase_pct", 25)
local manaBonus = math.floor(hero:GetMaxMana() * (manaIncreasePct / 100))
self.manaBonusSnapshot = self.manaBonusSnapshot + math.max(0, manaBonus)
end
function modifier_card_33.prototype.OnCustomCreated(self, _params)
if not IsServer() then
return
end
self:addManaSnapshotBonus()
end
function modifier_card_33.prototype.OnCustomRefresh(self, _params)
if not IsServer() then
return
end
self:addManaSnapshotBonus()
end
function modifier_card_33.prototype.DeclareFunctions(self)
return {MODIFIER_PROPERTY_MANA_BONUS, MODIFIER_PROPERTY_TOOLTIP}
end
function modifier_card_33.prototype.GetModifierManaBonus(self)
return self.manaBonusSnapshot
end
modifier_card_33 = __TS__Decorate(
modifier_card_33,
modifier_card_33,
{registerModifier(nil)},
{kind = "class", name = "modifier_card_33"}
)
____exports.modifier_card_33 = modifier_card_33
return ____exports