98 lines
4.0 KiB
Lua
98 lines
4.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 ____custom_game_events = require("custom_game_events")
|
|
local ensurePlayerCardSystem = ____custom_game_events.ensurePlayerCardSystem
|
|
local sendZiMorningCrystalsCard = ____custom_game_events.sendZiMorningCrystalsCard
|
|
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 ____crystal_currency = require("crystal_currency")
|
|
local GetCrystalCurrency = ____crystal_currency.GetCrystalCurrency
|
|
local ____card_value_resolver = require("cards.card_value_resolver")
|
|
local getCardValueByLevel = ____card_value_resolver.getCardValueByLevel
|
|
local CARD_ID = 38
|
|
____exports.card_38 = __TS__Class()
|
|
local card_38 = ____exports.card_38
|
|
card_38.name = "card_38"
|
|
card_38.____file_path = "scripts/vscripts/cards/examples/card_38.lua"
|
|
__TS__ClassExtends(card_38, CardBase)
|
|
function card_38.prototype.GetModifierName(self)
|
|
return "modifier_card_38"
|
|
end
|
|
card_38 = __TS__Decorate(card_38, card_38, {RegisterCard}, {kind = "class", name = "card_38"})
|
|
____exports.card_38 = card_38
|
|
____exports.modifier_card_38 = __TS__Class()
|
|
local modifier_card_38 = ____exports.modifier_card_38
|
|
modifier_card_38.name = "modifier_card_38"
|
|
modifier_card_38.____file_path = "scripts/vscripts/cards/examples/card_38.lua"
|
|
__TS__ClassExtends(modifier_card_38, CardBaseModifier)
|
|
modifier_card_38 = __TS__Decorate(
|
|
modifier_card_38,
|
|
modifier_card_38,
|
|
{registerModifier(nil)},
|
|
{kind = "class", name = "modifier_card_38"}
|
|
)
|
|
____exports.modifier_card_38 = modifier_card_38
|
|
local lastMorningSeqCard38ByPlayer = {}
|
|
function ____exports.notifyCard38MorningStarted(self, currentNight, morningSequence)
|
|
if not IsServer() then
|
|
return
|
|
end
|
|
local nightIndex = math.max(1, currentNight)
|
|
do
|
|
local i = 0
|
|
while i < DOTA_MAX_PLAYERS do
|
|
do
|
|
local pid = i
|
|
local player = PlayerResource:GetPlayer(pid)
|
|
if not player then
|
|
goto __continue5
|
|
end
|
|
local cardSystem = ensurePlayerCardSystem(nil, pid)
|
|
if not cardSystem then
|
|
goto __continue5
|
|
end
|
|
local copies = cardSystem:GetActiveCardCopies(CARD_ID)
|
|
if copies <= 0 then
|
|
goto __continue5
|
|
end
|
|
local hero = player:GetAssignedHero()
|
|
if not hero or not IsValidEntity(hero) or not hero:IsRealHero() then
|
|
goto __continue5
|
|
end
|
|
local mult = math.max(
|
|
1,
|
|
getCardValueByLevel(
|
|
nil,
|
|
CARD_ID,
|
|
hero,
|
|
"multiplier",
|
|
2
|
|
)
|
|
)
|
|
local prevSeq = lastMorningSeqCard38ByPlayer[pid] or 0
|
|
if morningSequence <= prevSeq then
|
|
goto __continue5
|
|
end
|
|
local crystals = GetCrystalCurrency(nil):getCrystals(pid)
|
|
local bonus = math.floor(crystals * (mult - 1) * copies)
|
|
if bonus > 0 then
|
|
GetCrystalCurrency(nil):addCrystals(pid, bonus)
|
|
sendZiMorningCrystalsCard(nil, pid, {morningSequence = morningSequence, nightIndex = nightIndex, crystalBonus = bonus})
|
|
end
|
|
lastMorningSeqCard38ByPlayer[pid] = morningSequence
|
|
end
|
|
::__continue5::
|
|
i = i + 1
|
|
end
|
|
end
|
|
end
|
|
return ____exports
|