Files
Dota-Zombie-Invasion/scripts/vscripts/cards/examples/card_37.lua
T
2026-05-29 15:11:31 +07:00

65 lines
2.2 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 ____card_value_resolver = require("cards.card_value_resolver")
local getCardValueByLevel = ____card_value_resolver.getCardValueByLevel
local ____crystal_currency = require("crystal_currency")
local GetCrystalCurrency = ____crystal_currency.GetCrystalCurrency
local ____WaveManager = require("WaveManager")
local WaveManager = ____WaveManager.WaveManager
local CARD_ID = 37
____exports.card_37 = __TS__Class()
local card_37 = ____exports.card_37
card_37.name = "card_37"
card_37.____file_path = "scripts/vscripts/cards/examples/card_37.lua"
__TS__ClassExtends(card_37, CardBase)
function card_37.prototype.OnCreated(self)
if not IsServer() then
return
end
local hero = self:GetHero()
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
local baseCrystals = self:getValue("base_crystals", 15)
local crystalsPerNight = self:getValue("crystals_per_night", 5)
local currentNight = math.max(
0,
WaveManager:getInstance():GetCurrentNight()
)
local crystalsReward = math.max(
0,
math.floor(baseCrystals + crystalsPerNight * currentNight)
)
if crystalsReward > 0 then
GetCrystalCurrency(nil):addCrystals(playerId, crystalsReward)
end
end
function card_37.prototype.GetModifierName(self)
return nil
end
function card_37.prototype.IsHidden(self)
return true
end
function card_37.prototype.getValue(self, key, fallback)
return getCardValueByLevel(
nil,
CARD_ID,
self:GetHero(),
key,
fallback
)
end
card_37 = __TS__Decorate(card_37, card_37, {RegisterCard}, {kind = "class", name = "card_37"})
____exports.card_37 = card_37
return ____exports