207 lines
7.7 KiB
Lua
207 lines
7.7 KiB
Lua
local ____lualib = require("lualib_bundle")
|
|
local __TS__Number = ____lualib.__TS__Number
|
|
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 AddCardToPlayerPool = ____CardSystem.AddCardToPlayerPool
|
|
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 CURSED_PACT_COMPLETE_MODIFIER = ____modifier_card_cursed.CURSED_PACT_COMPLETE_MODIFIER
|
|
local getCursedStackCount = ____modifier_card_cursed.getCursedStackCount
|
|
local CARD_ID = 80
|
|
--- Осколки Фростморна, которые замешиваются в колоду (синхронизируй с описанием карты 80).
|
|
____exports.FROSTMOURNE_SHARD_CARD_IDS = {81, 82, 83}
|
|
--- Вся линия Фростморна — нельзя дублировать «Зеркалом судьбы» (57) и «Эхом выбора» (79).
|
|
____exports.FROSTMOURNE_MIRROR_PROTECTED_CARD_IDS = {
|
|
CARD_ID,
|
|
unpack(____exports.FROSTMOURNE_SHARD_CARD_IDS)
|
|
}
|
|
function ____exports.isFrostmourneMirrorProtectedCardId(self, cardId)
|
|
local id = math.floor(__TS__Number(cardId))
|
|
for ____, protectedId in ipairs(____exports.FROSTMOURNE_MIRROR_PROTECTED_CARD_IDS) do
|
|
if protectedId == id then
|
|
return true
|
|
end
|
|
end
|
|
return false
|
|
end
|
|
function ____exports.isFrostmourneShardCardId(self, cardId)
|
|
for ____, id in ipairs(____exports.FROSTMOURNE_SHARD_CARD_IDS) do
|
|
if id == cardId then
|
|
return true
|
|
end
|
|
end
|
|
return false
|
|
end
|
|
--- Вызывается из CardSystem при получении карты игроком.
|
|
function ____exports.notifyCard80PlayerTookCard(self, hero, cardId)
|
|
if not IsServer() or not hero or not IsValidEntity(hero) or not hero:IsRealHero() then
|
|
return
|
|
end
|
|
local tracker = hero:FindModifierByName("modifier_card_80")
|
|
if tracker ~= nil then
|
|
tracker:OnShardCardTaken(cardId)
|
|
end
|
|
end
|
|
____exports.card_80 = __TS__Class()
|
|
local card_80 = ____exports.card_80
|
|
card_80.name = "card_80"
|
|
card_80.____file_path = "scripts/vscripts/cards/examples/card_80.lua"
|
|
__TS__ClassExtends(card_80, CardBase)
|
|
function card_80.prototype.GetModifierName(self)
|
|
return "modifier_card_80"
|
|
end
|
|
card_80 = __TS__Decorate(card_80, card_80, {RegisterCard}, {kind = "class", name = "card_80"})
|
|
____exports.card_80 = card_80
|
|
____exports.modifier_card_80 = __TS__Class()
|
|
local modifier_card_80 = ____exports.modifier_card_80
|
|
modifier_card_80.name = "modifier_card_80"
|
|
modifier_card_80.____file_path = "scripts/vscripts/cards/examples/card_80.lua"
|
|
__TS__ClassExtends(modifier_card_80, CardBaseModifier)
|
|
function modifier_card_80.prototype.____constructor(self, ...)
|
|
CardBaseModifier.prototype.____constructor(self, ...)
|
|
self.takenShardIds = {}
|
|
self.shardsCollected = 0
|
|
end
|
|
function modifier_card_80.prototype.OnCustomCreated(self, _params)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
local hero = self:GetParent()
|
|
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
|
|
for ____, shardId in ipairs(____exports.FROSTMOURNE_SHARD_CARD_IDS) do
|
|
AddCardToPlayerPool(
|
|
nil,
|
|
playerId,
|
|
shardId,
|
|
1,
|
|
1,
|
|
"card_80_frostmourne_shards"
|
|
)
|
|
end
|
|
self.shardsCollected = 0
|
|
end
|
|
function modifier_card_80.prototype.OnShardCardTaken(self, cardId)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
if not ____exports.isFrostmourneShardCardId(nil, cardId) then
|
|
return
|
|
end
|
|
if self.takenShardIds[cardId] then
|
|
return
|
|
end
|
|
self.takenShardIds[cardId] = true
|
|
local takenCount = 0
|
|
for ____, id in ipairs(____exports.FROSTMOURNE_SHARD_CARD_IDS) do
|
|
if self.takenShardIds[id] then
|
|
takenCount = takenCount + 1
|
|
end
|
|
end
|
|
self.shardsCollected = takenCount
|
|
if takenCount < #____exports.FROSTMOURNE_SHARD_CARD_IDS then
|
|
return
|
|
end
|
|
local hero = self:GetParent()
|
|
if not hero or not IsValidEntity(hero) or hero:HasModifier(CURSED_PACT_COMPLETE_MODIFIER) then
|
|
return
|
|
end
|
|
hero:AddNewModifier(
|
|
hero,
|
|
getModifierSourceAbility(nil, hero),
|
|
CURSED_PACT_COMPLETE_MODIFIER,
|
|
{}
|
|
)
|
|
hero:CalculateStatBonus(true)
|
|
EmitSoundOn("Hero_Antimage.ManaBreak", hero)
|
|
end
|
|
function modifier_card_80.prototype.DeclareFunctions(self)
|
|
return {MODIFIER_PROPERTY_TOOLTIP}
|
|
end
|
|
function modifier_card_80.prototype.OnTooltip(self)
|
|
return self.shardsCollected
|
|
end
|
|
function modifier_card_80.prototype.IsHidden(self)
|
|
return false
|
|
end
|
|
function modifier_card_80.prototype.GetTexture(self)
|
|
return "cards/card_" .. tostring(CARD_ID)
|
|
end
|
|
modifier_card_80 = __TS__Decorate(
|
|
modifier_card_80,
|
|
modifier_card_80,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_card_80"}
|
|
)
|
|
____exports.modifier_card_80 = modifier_card_80
|
|
____exports.modifier_card_80_pact_complete = __TS__Class()
|
|
local modifier_card_80_pact_complete = ____exports.modifier_card_80_pact_complete
|
|
modifier_card_80_pact_complete.name = "modifier_card_80_pact_complete"
|
|
modifier_card_80_pact_complete.____file_path = "scripts/vscripts/cards/examples/card_80.lua"
|
|
__TS__ClassExtends(modifier_card_80_pact_complete, CardBaseModifier)
|
|
function modifier_card_80_pact_complete.prototype.getCardCopiesFromFrostmourne(self)
|
|
local hero = self:GetParent()
|
|
if not hero or not IsValidEntity(hero) then
|
|
return 1
|
|
end
|
|
local cardMod = hero:FindModifierByName("modifier_card_80")
|
|
return math.max(
|
|
1,
|
|
math.floor(cardMod and cardMod:GetStackCount() or 0)
|
|
)
|
|
end
|
|
function modifier_card_80_pact_complete.prototype.getValue(self, key, fallback)
|
|
return self:getCardValue(key, fallback, CARD_ID) * self:getCardCopiesFromFrostmourne()
|
|
end
|
|
function modifier_card_80_pact_complete.prototype.IsHidden(self)
|
|
return false
|
|
end
|
|
function modifier_card_80_pact_complete.prototype.IsDebuff(self)
|
|
return false
|
|
end
|
|
function modifier_card_80_pact_complete.prototype.IsPurgable(self)
|
|
return false
|
|
end
|
|
function modifier_card_80_pact_complete.prototype.DeclareFunctions(self)
|
|
return {MODIFIER_PROPERTY_DAMAGEOUTGOING_PERCENTAGE, MODIFIER_PROPERTY_TOOLTIP}
|
|
end
|
|
function modifier_card_80_pact_complete.prototype.GetModifierDamageOutgoing_Percentage(self)
|
|
local hero = self:GetParent()
|
|
if not hero or not IsValidEntity(hero) or not hero:IsRealHero() then
|
|
return 0
|
|
end
|
|
local pctPerStack = self:getValue("outgoing_damage_per_curse_stack_pct", 5)
|
|
return getCursedStackCount(nil, hero) * pctPerStack
|
|
end
|
|
function modifier_card_80_pact_complete.prototype.OnTooltip(self)
|
|
local hero = self:GetParent()
|
|
if not hero or not IsValidEntity(hero) then
|
|
return 0
|
|
end
|
|
return getCursedStackCount(nil, hero)
|
|
end
|
|
function modifier_card_80_pact_complete.prototype.GetTexture(self)
|
|
return "cards/card_" .. tostring(CARD_ID)
|
|
end
|
|
modifier_card_80_pact_complete = __TS__Decorate(
|
|
modifier_card_80_pact_complete,
|
|
modifier_card_80_pact_complete,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_card_80_pact_complete"}
|
|
)
|
|
____exports.modifier_card_80_pact_complete = modifier_card_80_pact_complete
|
|
return ____exports
|