141 lines
5.0 KiB
Lua
141 lines
5.0 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 CARD_ID = 78
|
|
local STACK_MODIFIER = "modifier_card_78_mana_stack"
|
|
____exports.card_78 = __TS__Class()
|
|
local card_78 = ____exports.card_78
|
|
card_78.name = "card_78"
|
|
card_78.____file_path = "scripts/vscripts/cards/examples/card_78.lua"
|
|
__TS__ClassExtends(card_78, CardBase)
|
|
function card_78.prototype.GetModifierName(self)
|
|
return "modifier_card_78"
|
|
end
|
|
card_78 = __TS__Decorate(card_78, card_78, {RegisterCard}, {kind = "class", name = "card_78"})
|
|
____exports.card_78 = card_78
|
|
____exports.modifier_card_78 = __TS__Class()
|
|
local modifier_card_78 = ____exports.modifier_card_78
|
|
modifier_card_78.name = "modifier_card_78"
|
|
modifier_card_78.____file_path = "scripts/vscripts/cards/examples/card_78.lua"
|
|
__TS__ClassExtends(modifier_card_78, CardBaseModifier)
|
|
function modifier_card_78.prototype.getValue(self, key, fallback)
|
|
return self:getCardValue(key, fallback, CARD_ID)
|
|
end
|
|
function modifier_card_78.prototype.DeclareFunctions(self)
|
|
return {MODIFIER_EVENT_ON_ABILITY_FULLY_CAST, MODIFIER_PROPERTY_TOOLTIP}
|
|
end
|
|
function modifier_card_78.prototype.OnAbilityFullyCast(self, event)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
local hero = self:GetParent()
|
|
if not hero or not IsValidEntity(hero) or not hero:IsAlive() or not hero:IsRealHero() then
|
|
return
|
|
end
|
|
if event.unit ~= hero then
|
|
return
|
|
end
|
|
local ability = event.ability
|
|
if not ability or ability:IsNull() then
|
|
return
|
|
end
|
|
if ability:IsItem() or ability:IsToggle() then
|
|
return
|
|
end
|
|
local duration = math.max(
|
|
0.1,
|
|
self:getValue("stack_duration_sec", 10)
|
|
)
|
|
hero:AddNewModifier(
|
|
hero,
|
|
getModifierSourceAbility(nil, hero),
|
|
STACK_MODIFIER,
|
|
{duration = duration}
|
|
)
|
|
end
|
|
modifier_card_78 = __TS__Decorate(
|
|
modifier_card_78,
|
|
modifier_card_78,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_card_78"}
|
|
)
|
|
____exports.modifier_card_78 = modifier_card_78
|
|
____exports.modifier_card_78_mana_stack = __TS__Class()
|
|
local modifier_card_78_mana_stack = ____exports.modifier_card_78_mana_stack
|
|
modifier_card_78_mana_stack.name = "modifier_card_78_mana_stack"
|
|
modifier_card_78_mana_stack.____file_path = "scripts/vscripts/cards/examples/card_78.lua"
|
|
__TS__ClassExtends(modifier_card_78_mana_stack, CardBaseModifier)
|
|
function modifier_card_78_mana_stack.prototype.____constructor(self, ...)
|
|
CardBaseModifier.prototype.____constructor(self, ...)
|
|
self.manaBonusFlat = 0
|
|
end
|
|
function modifier_card_78_mana_stack.prototype.getCardCopiesFromOwner(self)
|
|
local owner = self:GetCaster()
|
|
if not owner or not IsValidEntity(owner) then
|
|
return 1
|
|
end
|
|
local cardMod = owner:FindModifierByName("modifier_card_78")
|
|
return math.max(
|
|
1,
|
|
math.floor(cardMod and cardMod:GetStackCount() or 0)
|
|
)
|
|
end
|
|
function modifier_card_78_mana_stack.prototype.getValue(self, key, fallback)
|
|
return self:getCardValue(key, fallback, CARD_ID) * self:getCardCopiesFromOwner()
|
|
end
|
|
function modifier_card_78_mana_stack.prototype.IsHidden(self)
|
|
return false
|
|
end
|
|
function modifier_card_78_mana_stack.prototype.IsDebuff(self)
|
|
return false
|
|
end
|
|
function modifier_card_78_mana_stack.prototype.IsPurgable(self)
|
|
return true
|
|
end
|
|
function modifier_card_78_mana_stack.prototype.GetAttributes(self)
|
|
return MODIFIER_ATTRIBUTE_MULTIPLE
|
|
end
|
|
function modifier_card_78_mana_stack.prototype.OnCustomCreated(self, _params)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
local hero = self:GetParent()
|
|
if not hero or not IsValidEntity(hero) then
|
|
return
|
|
end
|
|
local pct = self:getValue("max_mana_pct_per_stack", 0.5)
|
|
self.manaBonusFlat = math.max(
|
|
0,
|
|
math.floor(hero:GetMaxMana() * (pct / 100))
|
|
)
|
|
end
|
|
function modifier_card_78_mana_stack.prototype.DeclareFunctions(self)
|
|
return {MODIFIER_PROPERTY_MANA_BONUS, MODIFIER_PROPERTY_TOOLTIP}
|
|
end
|
|
function modifier_card_78_mana_stack.prototype.GetModifierManaBonus(self)
|
|
return self.manaBonusFlat
|
|
end
|
|
function modifier_card_78_mana_stack.prototype.OnTooltip(self)
|
|
return self:getValue("max_mana_pct_per_stack", 0.5)
|
|
end
|
|
function modifier_card_78_mana_stack.prototype.GetTexture(self)
|
|
return "cards/card_" .. tostring(CARD_ID)
|
|
end
|
|
modifier_card_78_mana_stack = __TS__Decorate(
|
|
modifier_card_78_mana_stack,
|
|
modifier_card_78_mana_stack,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_card_78_mana_stack"}
|
|
)
|
|
____exports.modifier_card_78_mana_stack = modifier_card_78_mana_stack
|
|
return ____exports
|