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

64 lines
2.3 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 = 40
____exports.card_40 = __TS__Class()
local card_40 = ____exports.card_40
card_40.name = "card_40"
card_40.____file_path = "scripts/vscripts/cards/examples/card_40.lua"
__TS__ClassExtends(card_40, CardBase)
function card_40.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 currentGold = PlayerResource:GetGold(playerId)
local crystalsToAdd = math.floor(currentGold / goldPerCrystal)
if crystalsToAdd <= 0 then
return
end
local goldToRemove = crystalsToAdd * goldPerCrystal
local currency = GetCrystalCurrency(nil)
hero:ModifyGold(-goldToRemove, true, 0)
currency:addCrystals(playerId, crystalsToAdd)
print((((((((("[CARD_40] player=" .. tostring(playerId)) .. ", gold_in=") .. tostring(currentGold)) .. ", gold_out=") .. tostring(goldToRemove)) .. ", crystals=") .. tostring(crystalsToAdd)) .. ", rate=") .. tostring(goldPerCrystal))
end
function card_40.prototype.GetModifierName(self)
return nil
end
function card_40.prototype.IsHidden(self)
return true
end
function card_40.prototype.getValue(self, key, fallback)
return getCardValueByLevel(
nil,
CARD_ID,
self:GetHero(),
key,
fallback
)
end
card_40 = __TS__Decorate(card_40, card_40, {RegisterCard}, {kind = "class", name = "card_40"})
____exports.card_40 = card_40
return ____exports