152 lines
5.5 KiB
Lua
152 lines
5.5 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 ____custom_game_events = require("custom_game_events")
|
|
local ensurePlayerCardSystem = ____custom_game_events.ensurePlayerCardSystem
|
|
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_value_resolver = require("cards.card_value_resolver")
|
|
local getCardValueByLevel = ____card_value_resolver.getCardValueByLevel
|
|
local CARD_ID = 51
|
|
function ____exports.getCard51MorningGoldCap(self, hero, explicitLevel)
|
|
local baseCap = math.max(
|
|
0,
|
|
math.floor(getCardValueByLevel(
|
|
nil,
|
|
CARD_ID,
|
|
hero,
|
|
"morning_gold_cap",
|
|
400,
|
|
explicitLevel
|
|
))
|
|
)
|
|
if not hero or not IsValidEntity(hero) or not hero:IsRealHero() then
|
|
return baseCap
|
|
end
|
|
local playerId = hero:GetPlayerOwnerID()
|
|
if playerId == nil or playerId == nil or playerId < 0 then
|
|
return baseCap
|
|
end
|
|
local cardSystem = ensurePlayerCardSystem(nil, playerId)
|
|
local copies = math.max(
|
|
1,
|
|
cardSystem and cardSystem:GetActiveCardCopies(CARD_ID) or 1
|
|
)
|
|
return baseCap * copies
|
|
end
|
|
function ____exports.getCard51MorningGoldEarned(self, playerId)
|
|
local cardSystem = ensurePlayerCardSystem(nil, playerId)
|
|
if not cardSystem then
|
|
return 0
|
|
end
|
|
return cardSystem:GetCard51MorningGoldEarned()
|
|
end
|
|
function ____exports.getCard51MorningGoldRemaining(self, hero, playerId)
|
|
local cap = ____exports.getCard51MorningGoldCap(nil, hero)
|
|
return math.max(
|
|
0,
|
|
cap - ____exports.getCard51MorningGoldEarned(nil, playerId)
|
|
)
|
|
end
|
|
--- Рассвет: сброс дневного лимита золота от Midas Chestplate.
|
|
function ____exports.notifyCard51MorningStarted(self, _morningSequence)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
do
|
|
local i = 0
|
|
while i < DOTA_MAX_PLAYERS do
|
|
do
|
|
local pid = i
|
|
local cardSystem = ensurePlayerCardSystem(nil, pid)
|
|
if not cardSystem then
|
|
goto __continue10
|
|
end
|
|
cardSystem:ResetCard51MorningGold()
|
|
end
|
|
::__continue10::
|
|
i = i + 1
|
|
end
|
|
end
|
|
end
|
|
____exports.card_51 = __TS__Class()
|
|
local card_51 = ____exports.card_51
|
|
card_51.name = "card_51"
|
|
card_51.____file_path = "scripts/vscripts/cards/examples/card_51.lua"
|
|
__TS__ClassExtends(card_51, CardBase)
|
|
function card_51.prototype.GetModifierName(self)
|
|
return "modifier_card_51"
|
|
end
|
|
card_51 = __TS__Decorate(card_51, card_51, {RegisterCard}, {kind = "class", name = "card_51"})
|
|
____exports.card_51 = card_51
|
|
____exports.modifier_card_51 = __TS__Class()
|
|
local modifier_card_51 = ____exports.modifier_card_51
|
|
modifier_card_51.name = "modifier_card_51"
|
|
modifier_card_51.____file_path = "scripts/vscripts/cards/examples/card_51.lua"
|
|
__TS__ClassExtends(modifier_card_51, CardBaseModifier)
|
|
function modifier_card_51.prototype.____constructor(self, ...)
|
|
CardBaseModifier.prototype.____constructor(self, ...)
|
|
self.totalDamageTaken = 0
|
|
end
|
|
function modifier_card_51.prototype.getValue(self, key, fallback)
|
|
return self:getCardValue(key, fallback, CARD_ID)
|
|
end
|
|
function modifier_card_51.prototype.DeclareFunctions(self)
|
|
return {MODIFIER_PROPERTY_INCOMING_DAMAGE_PERCENTAGE, MODIFIER_EVENT_ON_TAKEDAMAGE, MODIFIER_PROPERTY_TOOLTIP}
|
|
end
|
|
function modifier_card_51.prototype.GetModifierIncomingDamage_Percentage(self)
|
|
local basePct = self:getScaledCardValue("incoming_damage_base_pct", 25)
|
|
local per100 = self:getValue("incoming_damage_per_100_taken", 0.1) * self:getCardCopies()
|
|
local steps = math.floor(self.totalDamageTaken / 100)
|
|
return basePct + steps * per100
|
|
end
|
|
function modifier_card_51.prototype.OnTakeDamage(self, event)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
local parent = self:GetParent()
|
|
if not parent or not IsValidEntity(parent) or not parent:IsAlive() or not parent:IsRealHero() then
|
|
return
|
|
end
|
|
if event.unit ~= parent then
|
|
return
|
|
end
|
|
local damageTaken = event.damage
|
|
if damageTaken <= 0 then
|
|
return
|
|
end
|
|
self.totalDamageTaken = self.totalDamageTaken + damageTaken
|
|
local pid = parent:GetPlayerOwnerID()
|
|
if pid == nil or pid == nil or pid < 0 then
|
|
return
|
|
end
|
|
local cardSystem = ensurePlayerCardSystem(nil, pid)
|
|
if not cardSystem then
|
|
return
|
|
end
|
|
local goldPct = self:getScaledCardValue("gold_from_damage_taken_pct", 11)
|
|
local goldGain = math.floor(damageTaken * goldPct / 100)
|
|
cardSystem:TryGrantCard51GoldFromDamage(parent, goldGain)
|
|
end
|
|
function modifier_card_51.prototype.OnTooltip(self)
|
|
return math.floor(self:GetModifierIncomingDamage_Percentage() + 0.0001)
|
|
end
|
|
function modifier_card_51.prototype.GetTexture(self)
|
|
return "item_hand_of_midas"
|
|
end
|
|
modifier_card_51 = __TS__Decorate(
|
|
modifier_card_51,
|
|
modifier_card_51,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_card_51"}
|
|
)
|
|
____exports.modifier_card_51 = modifier_card_51
|
|
return ____exports
|