This commit is contained in:
xiekaidong 2023-04-12 15:16:33 +08:00
commit de7643a18f
4 changed files with 32 additions and 3 deletions

View File

@ -129,7 +129,11 @@ function Time:setServerTimeZone(timeZone)
end
function Time:getClientTimeZone()
return os.difftime(os.time(), os.time(os.date("!*t", os.time())))/SECONDS_PRE_HOUR
local now = os.time()
local utcdate = os.date("!*t", now)
local localdate = os.date("*t", now)
localdate.isdst = false
return os.difftime(os.time(localdate), os.time(utcdate))
end
function Time:getTimeZoneOffset()

View File

@ -30,6 +30,13 @@ Example: del_item]],
Example: clear_item]],
type = "clear_item"
},
{
title = "添加英雄",
desc = [[ type:add_hero
arg1:id
Example: add_hero 1]],
type = "add_hero"
},
}
return GMConst

View File

@ -1,8 +1,6 @@
local ServerHeroData = class("ServerHeroData", ServerBaseData)
function ServerHeroData:init(data)
Logger.logHighlight("ServerHeroData")
Logger.printTable(data)
self.data.heroes = data and data.heroes or {}
end

View File

@ -117,6 +117,26 @@ function ServerDataManager:dealGM(params, callback)
for k, v in pairs(items) do
v.count = 0
end
elseif args[1] == "add_hero" then
local id = tonumber(args[2])
if not id then
return
end
local hero = ServerGameData.HeroData:getHeroByCfgId(id)
if hero == nil or hero.lv <= 0 then
local heroCfg = ConfigManager:getConfig("hero")
local heroLvCfg = ConfigManager:getConfig("hero_level")
local heroInfo = heroCfg[id]
if heroInfo then
local costKey = "cost_" .. heroInfo.qlt
for k, v in ipairs(heroLvCfg) do
if v[costKey] then -- 第一个有值的就是解锁所需的数量
ServerGameData.HeroData:addHero(id, k)
break
end
end
end
end
end
ServerGameData:saveData()