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

63 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 CARD_ID = 39
____exports.card_39 = __TS__Class()
local card_39 = ____exports.card_39
card_39.name = "card_39"
card_39.____file_path = "scripts/vscripts/cards/examples/card_39.lua"
__TS__ClassExtends(card_39, CardBase)
function card_39.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 goldPerCrystal = math.max(
1,
math.floor(self:getValue("gold_per_crystal", 150))
)
local currency = GetCrystalCurrency(nil)
local crystals = currency:getCrystals(playerId)
if crystals <= 0 then
return
end
local gold = crystals * goldPerCrystal
currency:setCrystals(playerId, 0)
hero:ModifyGold(gold, true, 0)
print((((((("[CARD_39] player=" .. tostring(playerId)) .. ", crystals=") .. tostring(crystals)) .. ", gold=") .. tostring(gold)) .. ", rate=") .. tostring(goldPerCrystal))
end
function card_39.prototype.GetModifierName(self)
return nil
end
function card_39.prototype.IsHidden(self)
return true
end
function card_39.prototype.getValue(self, key, fallback)
return getCardValueByLevel(
nil,
CARD_ID,
self:GetHero(),
key,
fallback
)
end
card_39 = __TS__Decorate(card_39, card_39, {RegisterCard}, {kind = "class", name = "card_39"})
____exports.card_39 = card_39
return ____exports