110 lines
4.1 KiB
Lua
110 lines
4.1 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_slag = require("cards.card_slag")
|
|
local SLAG_CARD_ID = ____card_slag.SLAG_CARD_ID
|
|
local CARD_ID = 87
|
|
____exports.card_87 = __TS__Class()
|
|
local card_87 = ____exports.card_87
|
|
card_87.name = "card_87"
|
|
card_87.____file_path = "scripts/vscripts/cards/examples/card_87.lua"
|
|
__TS__ClassExtends(card_87, CardBase)
|
|
function card_87.prototype.GetModifierName(self)
|
|
return "modifier_card_87"
|
|
end
|
|
card_87 = __TS__Decorate(card_87, card_87, {RegisterCard}, {kind = "class", name = "card_87"})
|
|
____exports.card_87 = card_87
|
|
____exports.modifier_card_87 = __TS__Class()
|
|
local modifier_card_87 = ____exports.modifier_card_87
|
|
modifier_card_87.name = "modifier_card_87"
|
|
modifier_card_87.____file_path = "scripts/vscripts/cards/examples/card_87.lua"
|
|
__TS__ClassExtends(modifier_card_87, CardBaseModifier)
|
|
function modifier_card_87.prototype.____constructor(self, ...)
|
|
CardBaseModifier.prototype.____constructor(self, ...)
|
|
self.cachedSlagCount = -1
|
|
self.cachedPct = 0
|
|
end
|
|
function modifier_card_87.prototype.OnCustomCreated(self, _params)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
self:refreshFromPool(true)
|
|
self:StartIntervalThink(0.25)
|
|
end
|
|
function modifier_card_87.prototype.OnCustomRefresh(self, _params)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
self:refreshFromPool(true)
|
|
end
|
|
function modifier_card_87.prototype.OnIntervalThink(self)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
self:refreshFromPool(false)
|
|
end
|
|
function modifier_card_87.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_87.prototype.OnTooltip(self)
|
|
return self.cachedPct * self:getCardCopies()
|
|
end
|
|
function modifier_card_87.prototype.GetModifierBonusStats_Strength(self)
|
|
local hero = self:GetParent()
|
|
if not hero or not IsValidEntity(hero) then
|
|
return 0
|
|
end
|
|
return (hero:GetStrength() or 0) * (self.cachedPct * self:getCardCopies() / 100)
|
|
end
|
|
function modifier_card_87.prototype.GetModifierBonusStats_Agility(self)
|
|
local hero = self:GetParent()
|
|
if not hero or not IsValidEntity(hero) then
|
|
return 0
|
|
end
|
|
return (hero:GetAgility() or 0) * (self.cachedPct * self:getCardCopies() / 100)
|
|
end
|
|
function modifier_card_87.prototype.GetModifierBonusStats_Intellect(self)
|
|
local hero = self:GetParent()
|
|
if not hero or not IsValidEntity(hero) then
|
|
return 0
|
|
end
|
|
return (hero:GetIntellect(true) or 0) * (self.cachedPct * self:getCardCopies() / 100)
|
|
end
|
|
function modifier_card_87.prototype.refreshFromPool(self, force)
|
|
local hero = self:GetParent()
|
|
if not hero or not IsValidEntity(hero) or not hero:IsRealHero() then
|
|
return
|
|
end
|
|
local ____opt_0 = hero:GetPlayerOwner()
|
|
local cardSystem = ____opt_0 and ____opt_0.cardSystem
|
|
if not cardSystem then
|
|
return
|
|
end
|
|
local slagCount = cardSystem:GetPoolCardWeightSum(SLAG_CARD_ID)
|
|
if not force and slagCount == self.cachedSlagCount then
|
|
return
|
|
end
|
|
self.cachedSlagCount = slagCount
|
|
local pctPerSlag = self:getCardValue("attr_pct_per_slag", 2.5, CARD_ID)
|
|
self.cachedPct = slagCount * pctPerSlag
|
|
self:SendBuffRefreshToClients()
|
|
hero:CalculateStatBonus(true)
|
|
end
|
|
modifier_card_87 = __TS__Decorate(
|
|
modifier_card_87,
|
|
modifier_card_87,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_card_87"}
|
|
)
|
|
____exports.modifier_card_87 = modifier_card_87
|
|
return ____exports
|