From fb3888697fc07dd0ae64fb40d0343b516526760c Mon Sep 17 00:00:00 2001 From: chenxi Date: Wed, 12 Apr 2023 11:56:45 +0800 Subject: [PATCH] =?UTF-8?q?gm=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/common/time.lua | 6 +++++- lua/app/module/gm/gm_const.lua | 7 +++++++ lua/app/server/data/server_hero_data.lua | 2 -- lua/app/server/server_data_manager.lua | 20 ++++++++++++++++++++ 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/lua/app/common/time.lua b/lua/app/common/time.lua index d92a3802..5a023650 100644 --- a/lua/app/common/time.lua +++ b/lua/app/common/time.lua @@ -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() diff --git a/lua/app/module/gm/gm_const.lua b/lua/app/module/gm/gm_const.lua index dca5e347..14ee32b4 100644 --- a/lua/app/module/gm/gm_const.lua +++ b/lua/app/module/gm/gm_const.lua @@ -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 \ No newline at end of file diff --git a/lua/app/server/data/server_hero_data.lua b/lua/app/server/data/server_hero_data.lua index ab866e3c..52219148 100644 --- a/lua/app/server/data/server_hero_data.lua +++ b/lua/app/server/data/server_hero_data.lua @@ -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 diff --git a/lua/app/server/server_data_manager.lua b/lua/app/server/server_data_manager.lua index 5475c38f..39595396 100644 --- a/lua/app/server/server_data_manager.lua +++ b/lua/app/server/server_data_manager.lua @@ -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()