From 8801943ae30c5850c27c4b40f8ed10b4f101fc7c Mon Sep 17 00:00:00 2001 From: xiekaidong Date: Fri, 5 May 2023 18:27:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=B8=80=E4=B8=8B=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=EF=BC=8C=E6=8E=A5=E5=85=A5=E8=81=94=E7=BD=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/common/data_manager.lua | 6 +- lua/app/game.lua | 3 - lua/app/global/global_const.lua | 1 - lua/app/global/global_func.lua | 7 - .../controller/battle_controller_stage.lua | 6 +- lua/app/module/chapter/chapter_manager.lua | 106 ++++--- .../module/formation/formation_manager.lua | 14 +- lua/app/module/hero/hero_manager.lua | 15 +- lua/app/module/login/login_manager.lua | 27 +- lua/app/module/tutorial/tutorial_manager.lua | 6 +- lua/app/net/net_manager.lua | 68 ++--- lua/app/server/data.meta | 8 - lua/app/server/data/server_bag_data.lua | 30 -- lua/app/server/data/server_bag_data.lua.meta | 10 - lua/app/server/data/server_base_data.lua | 82 ------ lua/app/server/data/server_base_data.lua.meta | 10 - lua/app/server/data/server_chapter_data.lua | 96 ------- .../server/data/server_chapter_data.lua.meta | 10 - lua/app/server/data/server_formation_data.lua | 29 -- .../data/server_formation_data.lua.meta | 10 - lua/app/server/data/server_hero_data.lua | 82 ------ lua/app/server/data/server_hero_data.lua.meta | 10 - lua/app/server/data/server_item_data.lua | 213 -------------- lua/app/server/data/server_item_data.lua.meta | 10 - lua/app/server/data/server_player_data.lua | 20 -- .../server/data/server_player_data.lua.meta | 10 - lua/app/server/data/server_tutorial_data.lua | 19 -- .../server/data/server_tutorial_data.lua.meta | 10 - lua/app/server/manager.meta | 8 - .../server/manager/server_chapter_manager.lua | 98 ------- .../manager/server_chapter_manager.lua.meta | 10 - .../manager/server_formation_manager.lua | 27 -- .../manager/server_formation_manager.lua.meta | 10 - .../server/manager/server_hero_manager.lua | 65 ----- .../manager/server_hero_manager.lua.meta | 10 - .../manager/server_tutorial_manager.lua | 24 -- .../manager/server_tutorial_manager.lua.meta | 10 - lua/app/server/server_data_const.lua | 19 -- lua/app/server/server_data_const.lua.meta | 10 - lua/app/server/server_data_manager.lua | 181 ------------ lua/app/server/server_data_manager.lua.meta | 10 - lua/app/server/server_game_data.lua | 272 ------------------ lua/app/server/server_game_data.lua.meta | 10 - lua/app/ui/gm/gm_tool_ui.lua | 12 +- lua/app/userdata/chapter/chapter_data.lua | 98 +++++-- 45 files changed, 190 insertions(+), 1602 deletions(-) delete mode 100644 lua/app/server/data.meta delete mode 100644 lua/app/server/data/server_bag_data.lua delete mode 100644 lua/app/server/data/server_bag_data.lua.meta delete mode 100644 lua/app/server/data/server_base_data.lua delete mode 100644 lua/app/server/data/server_base_data.lua.meta delete mode 100644 lua/app/server/data/server_chapter_data.lua delete mode 100644 lua/app/server/data/server_chapter_data.lua.meta delete mode 100644 lua/app/server/data/server_formation_data.lua delete mode 100644 lua/app/server/data/server_formation_data.lua.meta delete mode 100644 lua/app/server/data/server_hero_data.lua delete mode 100644 lua/app/server/data/server_hero_data.lua.meta delete mode 100644 lua/app/server/data/server_item_data.lua delete mode 100644 lua/app/server/data/server_item_data.lua.meta delete mode 100644 lua/app/server/data/server_player_data.lua delete mode 100644 lua/app/server/data/server_player_data.lua.meta delete mode 100644 lua/app/server/data/server_tutorial_data.lua delete mode 100644 lua/app/server/data/server_tutorial_data.lua.meta delete mode 100644 lua/app/server/manager.meta delete mode 100644 lua/app/server/manager/server_chapter_manager.lua delete mode 100644 lua/app/server/manager/server_chapter_manager.lua.meta delete mode 100644 lua/app/server/manager/server_formation_manager.lua delete mode 100644 lua/app/server/manager/server_formation_manager.lua.meta delete mode 100644 lua/app/server/manager/server_hero_manager.lua delete mode 100644 lua/app/server/manager/server_hero_manager.lua.meta delete mode 100644 lua/app/server/manager/server_tutorial_manager.lua delete mode 100644 lua/app/server/manager/server_tutorial_manager.lua.meta delete mode 100644 lua/app/server/server_data_const.lua delete mode 100644 lua/app/server/server_data_const.lua.meta delete mode 100644 lua/app/server/server_data_manager.lua delete mode 100644 lua/app/server/server_data_manager.lua.meta delete mode 100644 lua/app/server/server_game_data.lua delete mode 100644 lua/app/server/server_game_data.lua.meta diff --git a/lua/app/common/data_manager.lua b/lua/app/common/data_manager.lua index fc3d7c5c..97abb4f4 100644 --- a/lua/app/common/data_manager.lua +++ b/lua/app/common/data_manager.lua @@ -86,14 +86,18 @@ end function DataManager:initWithServerData(data) self:init() Time:setServerTimeZone(0) + Time:updateServerTime(data.now_ts) + Time:updateServerTimeToday(data.today_ts) + self.initWithServer = true if EDITOR_MODE then Logger.logHighlight("initWithServerData") Logger.printTable(data) end + self.todayFirstLogin = data.today_first_login self.PlayerData:init(data.PlayerData) - self.ChapterData:init(data.ChapterData) + self.ChapterData:init(data.chapter) self.HeroData:init(data.HeroData) self.BagData:init(data.BagData) self.FormationData:init(data.FormationData) diff --git a/lua/app/game.lua b/lua/app/game.lua index 43bd3754..4829b9b4 100644 --- a/lua/app/game.lua +++ b/lua/app/game.lua @@ -84,7 +84,6 @@ function Game:initOther() BF.exports.BaseModule = require "app/module/base_module" BF.exports.ModuleManager = require "app/common/module_manager" BF.exports.ServerBaseData = require "app/server/data/server_base_data" - BF.exports.ServerDataManager = require "app/server/server_data_manager" BF.exports.DataManager = require "app/common/data_manager" BF.exports.DOTweenManager = require "app/common/dotween_manager" BF.exports.FSMManager = require "app/common/state_machine_manager" @@ -96,7 +95,6 @@ function Game:initOther() CameraManager:init() WebRequestManager:init() I18N:init() - ServerDataManager:init() DataManager:init() DOTweenManager:init() ModuleManager:init() @@ -154,7 +152,6 @@ function Game:specialForIdea() BaseModule = BaseModule or require "app/module/base_module" ModuleManager = ModuleManager or require "app/common/module_manager" ServerBaseData = ServerBaseData or require "app/server/data/server_base_data" - ServerDataManager = ServerDataManager or require "app/server/server_data_manager" DataManager = DataManager or require "app/common/data_manager" DOTweenManager = DOTweenManager or require "app/common/dotween_manager" FSMManager = FSMManager or require "app/common/state_machine_manager" diff --git a/lua/app/global/global_const.lua b/lua/app/global/global_const.lua index 11bc6055..d1474758 100644 --- a/lua/app/global/global_const.lua +++ b/lua/app/global/global_const.lua @@ -1,7 +1,6 @@ local GConst = {} local CONST_PATHS = { - ServerDataConst = "app/server/server_data_const", StageConst = "app/module/stage/stage_const", ItemConst = "app/module/item/item_const", TaskConst = "app/module/task/task_const", diff --git a/lua/app/global/global_func.lua b/lua/app/global/global_func.lua index e3706260..015abe5b 100644 --- a/lua/app/global/global_func.lua +++ b/lua/app/global/global_func.lua @@ -934,13 +934,6 @@ function GFunc.getTickCount() return math.floor(UnityTime.realtimeSinceStartup) end -function GFunc.IsGotServerTime() - if not CS.BF.BFMain.IsGotServerTime then - return false - end - return true -end - ---得到展示奖励的图集名称,图片资源id function GFunc.getFrameRes(type, id) if type == GConst.REWARD_TYPE.REWARD_NONE then diff --git a/lua/app/module/battle/controller/battle_controller_stage.lua b/lua/app/module/battle/controller/battle_controller_stage.lua index f68481d9..8719b80e 100644 --- a/lua/app/module/battle/controller/battle_controller_stage.lua +++ b/lua/app/module/battle/controller/battle_controller_stage.lua @@ -8,11 +8,7 @@ function BattleControllerStage:getChapterId() end function BattleControllerStage:getMaxWave() - local chapterInfo = ConfigManager:getConfig("chapter")[self.chapterId] - if not chapterInfo then - return 0 - end - return #chapterInfo.monster + return DataManager.ChapterData:getChapterCfgMaxWave(self.chapterId) end function BattleControllerStage:getBlockIcon() diff --git a/lua/app/module/chapter/chapter_manager.lua b/lua/app/module/chapter/chapter_manager.lua index 5ef5bfc8..6a516060 100644 --- a/lua/app/module/chapter/chapter_manager.lua +++ b/lua/app/module/chapter/chapter_manager.lua @@ -6,19 +6,19 @@ function ChapterManager:openBox(chapterId, index) end local parmas = { - id = chapterId, - index = index, + chapter_id = chapterId, + wave = index, } - ServerDataManager:dataOperate(GConst.ServerDataConst.DATA_OP_BEHAVIOR.OPEN_CHAPTER_BOX, parmas, function(result) - if result.status == 0 then - GFunc.addRewards(result.rewards, BIReport.ITEM_GET_TYPE.CHAPTER_BOX) - GFunc.showRewardBox(result.rewards) - DataManager.ChapterData:init(result.chapterData, true) - DataManager.ChapterData:setDirty() + self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterBoxRewardReq, parmas, {}, self.openBoxFinish, BIReport.ITEM_GET_TYPE.CHAPTER_BOX) +end - BIReport:postChapterOpenBox(chapterId, DataManager.ChapterData:getChapterBoxNum(chapterId, index), result.rewards) - end - end) +function ChapterManager:openBoxFinish(result) + if result.err_code == GConst.ERROR_STR.SUCCESS then + GFunc.showRewardBox(result.rewards) + DataManager.ChapterData:openBox(result.reqData.chapter_id, result.reqData.wave) + + BIReport:postChapterOpenBox(result.reqData.chapter_id, DataManager.ChapterData:getChapterBoxNum(chapterId, index), result.rewards) + end end function ChapterManager:startFight() @@ -38,61 +38,51 @@ function ChapterManager:startFight() local parmas = { id = DataManager.ChapterData:getChapterId() } - ServerDataManager:dataOperate(GConst.ServerDataConst.DATA_OP_BEHAVIOR.START_FIGHT, parmas, function(result) - if result.status == 0 then - if result.cost then - GFunc.addCosts(result.cost, BIReport.ITEM_GET_TYPE.CHAPTER_FIGHT_START) - end - ModuleManager.BattleManager:playBattle(GConst.BattleConst.BATTLE_TYPE.STAGE) - end - end) + -- self:sendMessage(ProtoMsgType.FromMsgEnum., parmas, {}, self.startFightFinish, BIReport.ITEM_GET_TYPE.CHAPTER_FIGHT_START) + self:startFightFinish({err_code = "SUCCESS"}) +end + +function ChapterManager:startFightFinish(result) + if result.err_code == GConst.ERROR_STR.SUCCESS then + ModuleManager.BattleManager:playBattle(GConst.BattleConst.BATTLE_TYPE.STAGE) + end end function ChapterManager:endFight(id, combatReport) - local cfg = ConfigManager:getConfig("chapter")[id] - local rewards = {} - for i = 1, combatReport.wave do - for _, reward in ipairs(cfg.wave_reward) do - table.insert(rewards, reward) - end - end - - if combatReport.victory then - for _, reward in ipairs(cfg.finish_reward) do - table.insert(rewards, reward) - end - end - local parmas = { - id = id, + chapter_id = id, + win = combatReport.victory, + pass_wave = combatReport.wave, combatReport = combatReport, - rewards = GFunc.mergeRewards(rewards) } - ServerDataManager:dataOperate(GConst.ServerDataConst.DATA_OP_BEHAVIOR.END_FIGHT, parmas, function(result) - if result.status == 0 then - local maxChapter = DataManager.ChapterData:getNewChapterId() - if combatReport.victory and DataManager.ChapterData:getChapterId() == DataManager.ChapterData:getMaxChapterId() + 1 then - DataManager.ChapterData:goNextChapter() - end - GFunc.addRewards(result.rewards, BIReport.ITEM_GET_TYPE.CHAPTER_FIGHT_END) - local newRewards = {} - if result.rewards then - GFunc.mergeRewards2(result.rewards, newRewards) - end - ModuleManager.BattleManager:showBattleResultUI(newRewards, combatReport) - DataManager.ChapterData:init(result.chapterData, true) - DataManager.ChapterData:setDirty() - -- 处理金猪 - DataManager.GodPigData:addGoldPigCount() - local newMaxChapter = DataManager.ChapterData:getNewChapterId() - if maxChapter ~= newMaxChapter then - local data = {} - data.max_chapter = newMaxChapter - CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(data) - end + self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterSettlementReq, parmas, {}, self.startFightFinish, BIReport.ITEM_GET_TYPE.CHAPTER_FIGHT_END) +end + +function ChapterManager:endFightFinish(result) + if result.err_code == GConst.ERROR_STR.SUCCESS then + local reqData = result.reqData + local maxChapter = DataManager.ChapterData:getNewChapterId() + if reqData.combatReport.victory and DataManager.ChapterData:getChapterId() == DataManager.ChapterData:getMaxChapterId() + 1 then + DataManager.ChapterData:goNextChapter() end - end) + local newRewards = {} + if result.rewards then + GFunc.mergeRewards2(result.rewards, newRewards) + end + ModuleManager.BattleManager:showBattleResultUI(newRewards, reqData.combatReport) + -- DataManager.ChapterData:init(result.chapterData, true) + -- DataManager.ChapterData:setDirty() + -- 处理金猪 + DataManager.GodPigData:addGoldPigCount() + + local newMaxChapter = DataManager.ChapterData:getNewChapterId() + if maxChapter ~= newMaxChapter then + local data = {} + data.max_chapter = newMaxChapter + CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(data) + end + end end return ChapterManager \ No newline at end of file diff --git a/lua/app/module/formation/formation_manager.lua b/lua/app/module/formation/formation_manager.lua index 21088253..83050b43 100644 --- a/lua/app/module/formation/formation_manager.lua +++ b/lua/app/module/formation/formation_manager.lua @@ -10,12 +10,14 @@ function FormationManager:upHeroToStageFormation(heroId, matchType) matchType = matchType, heroId = heroId } - ServerDataManager:dataOperate(GConst.ServerDataConst.DATA_OP_BEHAVIOR.UPDATE_FORMATION, args, function(msgData) - if msgData.status == 0 then - DataManager.FormationData:upHeroToFormation(GConst.BattleConst.BATTLE_TYPE.STAGE, matchType, heroId) - DataManager.HeroData:setDirty() - end - end) + -- self:sendMessage(ProtoMsgType.FromMsgEnum., args, {}, self.upHeroToStageFormationFinish) +end + +function FormationManager:upHeroToStageFormationFinish(result) + if result.err_code == GConst.ERROR_STR.SUCCESS then + DataManager.FormationData:upHeroToFormation(GConst.BattleConst.BATTLE_TYPE.STAGE, matchType, heroId) + DataManager.HeroData:setDirty() + end end function FormationManager:formationIsFull() diff --git a/lua/app/module/hero/hero_manager.lua b/lua/app/module/hero/hero_manager.lua index fcf5d1ce..ed77560a 100644 --- a/lua/app/module/hero/hero_manager.lua +++ b/lua/app/module/hero/hero_manager.lua @@ -14,13 +14,14 @@ function HeroManager:upgradeHero(heroId, heroEntity) return end - ServerDataManager:dataOperate(GConst.ServerDataConst.DATA_OP_BEHAVIOR.UPGRADE_HERO, {heroId = heroId}, function(result) - if result.status == 0 then - GFunc.addCosts(result.costs, BIReport.ITEM_GET_TYPE.UPGRADE_HERO) - DataManager.HeroData:setHeroLv(result.heroId, result.lv) - DataManager.HeroData:setDirty() - end - end) + -- self:sendMessage(ProtoMsgType.FromMsgEnum., args, {}, self.upgradeHeroFinish, BIReport.ITEM_GET_TYPE.UPGRADE_HERO) +end + +function HeroManager:upgradeHeroFinish(result) + if result.err_code == GConst.ERROR_STR.SUCCESS then + DataManager.HeroData:setHeroLv(result.heroId, result.lv) + DataManager.HeroData:setDirty() + end end diff --git a/lua/app/module/login/login_manager.lua b/lua/app/module/login/login_manager.lua index 5ca67d2a..17f16ba1 100644 --- a/lua/app/module/login/login_manager.lua +++ b/lua/app/module/login/login_manager.lua @@ -20,24 +20,7 @@ end function LoginManager:loginGame() -- adjust 打开应用事件识别码 BIReport:postAdjustSimpleTrackEvent("xbszrl", {}) - - local serverTime = Time:getServerTime() * 1000 - local todayBeginTime = serverTime - serverTime%86400 - Time:updateByServer(serverTime, todayBeginTime) - - CS.BF.BFMain.IsGotServerTime = true - ServerDataManager:dataOperate(GConst.ServerDataConst.DATA_OP_BEHAVIOR.SYNC_DATA, GConst.EMPTY_TABLE, function(msgData) - DataManager:initWithServerData(msgData) - ConfigManager:preLoadConfig() - ModuleManager.MaincityManager:firstEnterMainCity() - local data = {} - data.max_chapter = DataManager.ChapterData:getNewChapterId() - -- data.ads_num = DataManager.PlayerData:getAdCount() - -- data.pay_money = DataManager.PlayerData:getPaymentCount() - data.play_days = DataManager.PlayerData:getLoginDay() - data.now_version = Platform:getClientVersion() - CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(data) - end) + ModuleManager.MaincityManager:firstEnterMainCity() end function LoginManager:goToLoginScene() @@ -157,6 +140,14 @@ function LoginManager:loginFinish(data) ServerPushManager:initWhenLogin() DataManager:initWithServerData(data) + local data = {} + data.max_chapter = DataManager.ChapterData:getNewChapterId() + -- data.ads_num = DataManager.PlayerData:getAdCount() + -- data.pay_money = DataManager.PlayerData:getPaymentCount() + data.play_days = DataManager.PlayerData:getLoginDay() + data.now_version = Platform:getClientVersion() + CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(data) + EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.LOGIN_REQ_SUCCESS) -- ModuleManager.MailManager:getMailList(true) DataManager:setLoginSuccess(true) diff --git a/lua/app/module/tutorial/tutorial_manager.lua b/lua/app/module/tutorial/tutorial_manager.lua index cefd173a..0e3d5d3e 100644 --- a/lua/app/module/tutorial/tutorial_manager.lua +++ b/lua/app/module/tutorial/tutorial_manager.lua @@ -23,14 +23,12 @@ function TutorialManager:sendTutorialId(id, callback) self.sendTutorialIdCallback = callback - ServerDataManager:dataOperate(GConst.ServerDataConst.DATA_OP_BEHAVIOR.MARK_GUIDE, args, function(result) - self:sendTutorialIdFinish(result) - end) + -- self:sendMessage(ProtoMsgType.FromMsgEnum., args, {}, self.sendTutorialIdFinish) end function TutorialManager:sendTutorialIdFinish(result) Logger.printTable(result) - if result.status == 0 then + if result.err_code == GConst.ERROR_STR.SUCCESS then if result.id then -- BIReport:postTutorialStep(result.id) -- DataManager.TutorialData:markFuncTutorialFinish(result.id) diff --git a/lua/app/net/net_manager.lua b/lua/app/net/net_manager.lua index 7c1bce77..251585a6 100644 --- a/lua/app/net/net_manager.lua +++ b/lua/app/net/net_manager.lua @@ -958,40 +958,40 @@ function NetManager:getNotCheckResponse(msgName) return false end - if msgName == ProtoMsgType.FromMsgEnum.LoginReq or - msgName == ProtoMsgType.FromMsgEnum.SyncReq or - msgName == ProtoMsgType.FromMsgEnum.ArenaInfoReq or - msgName == ProtoMsgType.FromMsgEnum.SummonReq or - msgName == ProtoMsgType.FromMsgEnum.MineResearchADReq or - msgName == ProtoMsgType.FromMsgEnum.MineResearchResultReq or - msgName == ProtoMsgType.FromMsgEnum.IdleRewardReq or - msgName == ProtoMsgType.FromMsgEnum.IdleExtraRewardReq or - msgName == ProtoMsgType.FromMsgEnum.GMReq or - msgName == ProtoMsgType.FromMsgEnum.MallPayReq or - msgName == ProtoMsgType.FromMsgEnum.ChapterPassReq or - msgName == ProtoMsgType.FromMsgEnum.MallPaidResultReq or - msgName == ProtoMsgType.FromMsgEnum.MineDoReq or - msgName == ProtoMsgType.FromMsgEnum.TaskTutorRewardReq or - msgName == ProtoMsgType.FromMsgEnum.BlessingReq or - msgName == ProtoMsgType.FromMsgEnum.MarkGuideReq or - msgName == ProtoMsgType.FromMsgEnum.EnterDungeonReq or - msgName == ProtoMsgType.FromMsgEnum.FinishedArenaReq or - msgName == ProtoMsgType.FromMsgEnum.SettleArenaReq or - msgName == ProtoMsgType.FromMsgEnum.SevenDayRewardReq or - msgName == ProtoMsgType.FromMsgEnum.MonCardRewardReq or - msgName == ProtoMsgType.FromMsgEnum.ChapterStageRewardReq or - msgName == ProtoMsgType.FromMsgEnum.BattlePassRewardReq or - msgName == ProtoMsgType.FromMsgEnum.ChapterRebornReq or - msgName == ProtoMsgType.FromMsgEnum.MineReceiveAwardReq or - msgName == ProtoMsgType.FromMsgEnum.MailExtractReq or - msgName == ProtoMsgType.FromMsgEnum.MailListReq or - msgName == ProtoMsgType.FromMsgEnum.MailDeleteReq or - msgName == ProtoMsgType.FromMsgEnum.ExistReq or - msgName == ProtoMsgType.FromMsgEnum.BindReq or - msgName == ProtoMsgType.FromMsgEnum.DeleteReq - then - return true - end + -- if msgName == ProtoMsgType.FromMsgEnum.LoginReq or + -- msgName == ProtoMsgType.FromMsgEnum.SyncReq or + -- msgName == ProtoMsgType.FromMsgEnum.ArenaInfoReq or + -- msgName == ProtoMsgType.FromMsgEnum.SummonReq or + -- msgName == ProtoMsgType.FromMsgEnum.MineResearchADReq or + -- msgName == ProtoMsgType.FromMsgEnum.MineResearchResultReq or + -- msgName == ProtoMsgType.FromMsgEnum.IdleRewardReq or + -- msgName == ProtoMsgType.FromMsgEnum.IdleExtraRewardReq or + -- msgName == ProtoMsgType.FromMsgEnum.GMReq or + -- msgName == ProtoMsgType.FromMsgEnum.MallPayReq or + -- msgName == ProtoMsgType.FromMsgEnum.ChapterPassReq or + -- msgName == ProtoMsgType.FromMsgEnum.MallPaidResultReq or + -- msgName == ProtoMsgType.FromMsgEnum.MineDoReq or + -- msgName == ProtoMsgType.FromMsgEnum.TaskTutorRewardReq or + -- msgName == ProtoMsgType.FromMsgEnum.BlessingReq or + -- msgName == ProtoMsgType.FromMsgEnum.MarkGuideReq or + -- msgName == ProtoMsgType.FromMsgEnum.EnterDungeonReq or + -- msgName == ProtoMsgType.FromMsgEnum.FinishedArenaReq or + -- msgName == ProtoMsgType.FromMsgEnum.SettleArenaReq or + -- msgName == ProtoMsgType.FromMsgEnum.SevenDayRewardReq or + -- msgName == ProtoMsgType.FromMsgEnum.MonCardRewardReq or + -- msgName == ProtoMsgType.FromMsgEnum.ChapterStageRewardReq or + -- msgName == ProtoMsgType.FromMsgEnum.BattlePassRewardReq or + -- msgName == ProtoMsgType.FromMsgEnum.ChapterRebornReq or + -- msgName == ProtoMsgType.FromMsgEnum.MineReceiveAwardReq or + -- msgName == ProtoMsgType.FromMsgEnum.MailExtractReq or + -- msgName == ProtoMsgType.FromMsgEnum.MailListReq or + -- msgName == ProtoMsgType.FromMsgEnum.MailDeleteReq or + -- msgName == ProtoMsgType.FromMsgEnum.ExistReq or + -- msgName == ProtoMsgType.FromMsgEnum.BindReq or + -- msgName == ProtoMsgType.FromMsgEnum.DeleteReq + -- then + -- return true + -- end return false end diff --git a/lua/app/server/data.meta b/lua/app/server/data.meta deleted file mode 100644 index 512fd3ba..00000000 --- a/lua/app/server/data.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: f37c247985544954bbcd2f09de7728d8 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/lua/app/server/data/server_bag_data.lua b/lua/app/server/data/server_bag_data.lua deleted file mode 100644 index 67282cd1..00000000 --- a/lua/app/server/data/server_bag_data.lua +++ /dev/null @@ -1,30 +0,0 @@ -local ServerBagData = class("ServerBagData", ServerBaseData) - -function ServerBagData:ctor() - self.ItemData = require("app/server/data/server_item_data"):create() -end - -function ServerBagData:init() - self.ItemData:init() -end - -function ServerBagData:loadLocalData() - self.ItemData:loadLocalData() -end - -function ServerBagData:getCloneData() - local data = { - ItemData = self.ItemData:getCloneData() - } - return data -end - -function ServerBagData:saveLocalData() - self.ItemData:saveLocalData() -end - -function ServerBagData:clear() - self.ItemData:clear() -end - -return ServerBagData \ No newline at end of file diff --git a/lua/app/server/data/server_bag_data.lua.meta b/lua/app/server/data/server_bag_data.lua.meta deleted file mode 100644 index 4a111d66..00000000 --- a/lua/app/server/data/server_bag_data.lua.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: d136d1a130b633146aadeca89f6c41a6 -ScriptedImporter: - internalIDToNameTable: [] - externalObjects: {} - serializedVersion: 2 - userData: - assetBundleName: - assetBundleVariant: - script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/server/data/server_base_data.lua b/lua/app/server/data/server_base_data.lua deleted file mode 100644 index ea146939..00000000 --- a/lua/app/server/data/server_base_data.lua +++ /dev/null @@ -1,82 +0,0 @@ -local ServerBaseData = class("ServerBaseData") - -function ServerBaseData:ctor(...) - self.data = {} - -- self.data.__parent = self - - -- local innerData = nil - -- innerData = { - -- __index = function (t, key) - -- return innerData[key] - -- end, - -- __newindex = function (t, key, value) - -- innerData[key] = value - -- end - -- } - -- setmetatable(self.data, innerData) -end - -function ServerBaseData:init() -end - -function ServerBaseData:clear() -end - -function ServerBaseData:loadLocalData() - local data = LocalData:getString(self:_getLocalSaveKey(), "") - local dataObj = nil - if data and data ~= "" then - dataObj = json.decode(data) - end - self:init(dataObj) -end - -function ServerBaseData:saveLocalData() - local str = json.encode(self.data) or "" - LocalData:setString(self:_getLocalSaveKey(), str) - if EDITOR_MODE then - Logger.logHighlight("save data:%s=%s", self:_getLocalSaveKey(), str) - end -end - -function ServerBaseData:_getLocalSaveKey() - if self._localSaveKey == nil then - self._localSaveKey = "ServerData_" .. self.__cname - end - return self._localSaveKey -end - -function ServerBaseData:getCloneData() - local cloneData = {} - local function _copy(object) - if type(object) ~= "table" then - return object - elseif cloneData[object] then - return cloneData[object] - end - local newObject = {} - cloneData[object] = newObject - for key, value in pairs(object) do - newObject[_copy(key)] = _copy(value) - end - return newObject - end - return _copy(self.data) -end - -function ServerBaseData:_clear() - self._localSaveKey = nil - self:clear() -end - -if NOT_PUBLISH then - ServerBaseData._editorGetLocalSaveKey = ServerBaseData._getLocalSaveKey - function ServerBaseData:_getLocalSaveKey() - if self._localSaveKey == nil then - self._localSaveKey = LocalData:getDistinctId() .. "ServerData_" .. self.__cname - end - return self._localSaveKey - end -end - -return ServerBaseData \ No newline at end of file diff --git a/lua/app/server/data/server_base_data.lua.meta b/lua/app/server/data/server_base_data.lua.meta deleted file mode 100644 index a8009226..00000000 --- a/lua/app/server/data/server_base_data.lua.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: 8b88996eb5328d742b2a198434cabef1 -ScriptedImporter: - internalIDToNameTable: [] - externalObjects: {} - serializedVersion: 2 - userData: - assetBundleName: - assetBundleVariant: - script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/server/data/server_chapter_data.lua b/lua/app/server/data/server_chapter_data.lua deleted file mode 100644 index 529597f0..00000000 --- a/lua/app/server/data/server_chapter_data.lua +++ /dev/null @@ -1,96 +0,0 @@ -local ServerChapterData = class("ServerChapterData", ServerBaseData) - -local MIN_CHAPTER_ID = 1 - -function ServerChapterData:init(data) - self.data.maxChapterId = data and data.maxChapterId or (MIN_CHAPTER_ID - 1) - self.data.chapterBoxInfo = data and data.chapterBoxInfo or {} - self.data.chapterFightInfo = data and data.chapterFightInfo or {} -end - -function ServerChapterData:enterFight(id) - local idStr = tostring(id) - if not self.data.chapterFightInfo[idStr] then - self.data.chapterFightInfo[idStr] = { - victory = false, - maxWave = 0, - fightCount = 0 - } - end - - self.data.chapterFightInfo[idStr].fightCount = (self.data.chapterFightInfo[idStr].fightCount or 0) + 1 -end - -function ServerChapterData:fightChapter(id, victory, wave) - local idStr = tostring(id) - if not self.data.chapterFightInfo[idStr] then - self.data.chapterFightInfo[idStr] = { - victory = false, - maxWave = 0, - fightCount = 0 - } - end - - local passBefore = self.data.chapterFightInfo[idStr].victory - if victory then - self.data.chapterFightInfo[idStr].victory = victory - end - - if wave > self.data.chapterFightInfo[idStr].maxWave then - self.data.chapterFightInfo[idStr].maxWave = wave - end - - if not passBefore and victory then - if id > self.data.maxChapterId then - self.data.maxChapterId = id - end - end -end - -function ServerChapterData:getChapterBoxRewardGot(chapterId, index) - local idStr = tostring(chapterId) - local list = self.data.chapterBoxInfo[idStr] - if not list then - return false - end - - for _, idx in ipairs(list) do - if idx == index then - return true - end - end - - return false -end - -function ServerChapterData:getChapterBoxRewards(chapterId, index) - local cfg = ConfigManager:getConfig("chapter")[chapterId] - if not cfg then - return - end - - return cfg["box_reward_" .. index] -end - -function ServerChapterData:openChapterBox(chapterId, index) - local idStr = tostring(chapterId) - local list = self.data.chapterBoxInfo[idStr] - if not list then - self.data.chapterBoxInfo[idStr] = {} - else - for _, idx in ipairs(list) do - if idx == index then - return false - end - end - end - - table.insert(self.data.chapterBoxInfo[idStr], index) - return true -end - -function ServerChapterData:getMaxChapterId() - return self.data.maxChapterId -end - -return ServerChapterData \ No newline at end of file diff --git a/lua/app/server/data/server_chapter_data.lua.meta b/lua/app/server/data/server_chapter_data.lua.meta deleted file mode 100644 index ffb9e57c..00000000 --- a/lua/app/server/data/server_chapter_data.lua.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: 58e11526da53ab84da05ed5fd3a6cf31 -ScriptedImporter: - internalIDToNameTable: [] - externalObjects: {} - serializedVersion: 2 - userData: - assetBundleName: - assetBundleVariant: - script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/server/data/server_formation_data.lua b/lua/app/server/data/server_formation_data.lua deleted file mode 100644 index 57460544..00000000 --- a/lua/app/server/data/server_formation_data.lua +++ /dev/null @@ -1,29 +0,0 @@ -local ServerFormationData = class("ServerFormationData", ServerBaseData) - -function ServerFormationData:init(data) - if data then - self.data.formations = data.formations or {} - else - self.data.formations = {} - end -end - -function ServerFormationData:getFormation(formationType) - local formation = self.data.formations[formationType] - if formation == nil then - formation = {} - self.data.formations[formationType] = formation - end - return formation -end - -function ServerFormationData:upHeroToFormation(formationType, matchType, heroId) - local formation = self:getFormation(formationType) - if formation[matchType] == heroId then - return false - end - formation[matchType] = heroId - return true -end - -return ServerFormationData \ No newline at end of file diff --git a/lua/app/server/data/server_formation_data.lua.meta b/lua/app/server/data/server_formation_data.lua.meta deleted file mode 100644 index 04004254..00000000 --- a/lua/app/server/data/server_formation_data.lua.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: 89bb0382eca3c184e814ee1bc10355c8 -ScriptedImporter: - internalIDToNameTable: [] - externalObjects: {} - serializedVersion: 2 - userData: - assetBundleName: - assetBundleVariant: - script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/server/data/server_hero_data.lua b/lua/app/server/data/server_hero_data.lua deleted file mode 100644 index 0225bd65..00000000 --- a/lua/app/server/data/server_hero_data.lua +++ /dev/null @@ -1,82 +0,0 @@ -local ServerHeroData = class("ServerHeroData", ServerBaseData) - -function ServerHeroData:init(data) - self.data.heroes = data and data.heroes or {} - self.data.unlockHeroes = data and data.unlockHeroes or {} -end - -function ServerHeroData:getHeroByCfgId(id) - local idStr = tostring(id) - return self.data.heroes[idStr] -end - -function ServerHeroData:getIsUnlockHero(id) - local idStr = tostring(id) - if self.data.heroes[idStr] then - return true - end - return self.data.unlockHeroes[idStr] -end - -function ServerHeroData:addHero(id, lv) - local idStr = tostring(id) - if self.data.heroes[idStr] then - return - end - self.data.heroes[idStr] = { - cfg_id = id, - lv = lv, - } -end - -function ServerHeroData:unlockHero(id) - local idStr = tostring(id) - if self.data.unlockHeroes[idStr] then - return - end - self.data.unlockHeroes[idStr] = true -end - -function ServerHeroData:tryUnlockHeroByChapterId(maxChapterId) - if self.maxChapterId and self.maxChapterId >= maxChapterId then - return - end - self.maxChapterId = maxChapterId - if self.unlockHeroList == nil then - self.unlockHeroList = {} - local config = ConfigManager:getConfig("hero") - for k, v in pairs(config) do - if not self:getIsUnlockHero(k) then - if v.unlock_chapter then - table.insert(self.unlockHeroList, k) - end - end - end - table.sort(self.unlockHeroList, function(a, b) - return config[a].unlock_chapter > config[b].unlock_chapter - end) - self.unlockChapterList = {} - for k, v in ipairs(self.unlockHeroList) do - self.unlockChapterList[k] = config[v].unlock_chapter - end - end - for i = #self.unlockChapterList, 1, -1 do - if self.unlockChapterList[i] <= maxChapterId then - self:unlockHero(self.unlockHeroList[i]) - table.remove(self.unlockChapterList, i) - table.remove(self.unlockHeroList, i) - else - break - end - end -end - -function ServerHeroData:upgradeHero(heroId, lv) - local idStr = tostring(heroId) - if not self.data.heroes[idStr] then - self:addHero(heroId, 0) - end - self.data.heroes[idStr].lv = lv -end - -return ServerHeroData \ No newline at end of file diff --git a/lua/app/server/data/server_hero_data.lua.meta b/lua/app/server/data/server_hero_data.lua.meta deleted file mode 100644 index cf2ead46..00000000 --- a/lua/app/server/data/server_hero_data.lua.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: 56a4a8f5d6118d74b9bb6971db3d030a -ScriptedImporter: - internalIDToNameTable: [] - externalObjects: {} - serializedVersion: 2 - userData: - assetBundleName: - assetBundleVariant: - script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/server/data/server_item_data.lua b/lua/app/server/data/server_item_data.lua deleted file mode 100644 index 288cfe58..00000000 --- a/lua/app/server/data/server_item_data.lua +++ /dev/null @@ -1,213 +0,0 @@ -local ServerItemData = class("ServerItemData", ServerBaseData) - -function ServerItemData:init(data) - self.data.items = {} - if data then - for idStr, item in pairs(data.items) do - local id = tonumber(idStr) - if id == GConst.ItemConst.ITEM_ID_VIT then - local ServerGameData = require "app/server/server_game_data" - ServerGameData.PlayerData:setVit(item.count) - end - self.data.items[idStr] = {cfg_id = id, count = item.count} - end - self.data.recoveries = data.recoveries or {} - else - self.data.recoveries = {} - end - self:checkRecoveries() -end - -function ServerItemData:tryAddItem(id, num) - local idStr = tostring(id) - if not self.data.items[idStr] then - if num < 0 then - return false - end - else - if self.data.items[idStr].count + num < 0 then - return false - end - end - return true -end - -function ServerItemData:getAllItems() - return self.data.items -end - -function ServerItemData:getItemNumById(id) - local idStr = tostring(id) - if not self.data.items[idStr] then - return 0 - end - local num = self.data.items[idStr].count or 0 - return num -end - -function ServerItemData:checkRecoveries() - local recoveryCfg = self:getRecoveryCfg() - for k, v in pairs(recoveryCfg) do - local inList = false - for ii, vv in ipairs(self.data.recoveries) do - if vv.cfg_id == k then - inList = true - end - end - if not inList then - table.insert(self.data.recoveries, {cfg_id = k, ts = Time:getServerTime()}) - end - end - self:recoveryItems(true) -end - -function ServerItemData:recoveryItems(isInit) - if not self.data.recoveries then - return - end - for i,v in ipairs(self.data.recoveries) do - if v.cfg_id == GConst.ItemConst.ITEM_ID_VIT then - local maxCount = self:getMaxVit() - self:recoveryItem(v, maxCount, isInit) - end - end -end - - -function ServerItemData:recoveryItem(data, maxCount, isInit) - if not CS.BF.BFMain.IsGotServerTime then - return - end - if data.cfg_id == GConst.ItemConst.ITEM_ID_VIT then - local ServerGameData = require "app/server/server_game_data" - local currentCount = ServerGameData.PlayerData:getVit() - if currentCount >= maxCount then -- 已经达到上限 - return - end - - local cfg = self:getRecoveryCfg()[data.cfg_id] - local nowTime = Time:getServerTime() - local diffTime = nowTime - data.ts - if diffTime <= 0 then - return - end - local addCount = math.floor(diffTime / cfg.time) - if addCount <= 0 then - return - end - end - - local currentCount = self:getItemNumById(data.cfg_id) - if currentCount >= maxCount then -- 已经达到上限 - return - end - local cfg = self:getRecoveryCfg()[data.cfg_id] - local nowTime = Time:getServerTime() - local diffTime = nowTime - data.ts - if diffTime <= 0 then - return - end - local addCount = math.floor(diffTime / cfg.time) - if addCount <= 0 then - return - end - data.ts = data.ts + cfg.time*addCount - if currentCount + addCount > maxCount then - addCount = maxCount - currentCount - end - self:_addItem(data.cfg_id, addCount) - - if data.cfg_id == GConst.ItemConst.ITEM_ID_VIT then - BIReport:postVitGet(addCount, BIReport.ITEM_GET_TYPE.RECOVERY_TIME, self:getItemNumById(data.cfg_id)) - end - ServerDataManager:saveData() -end - -function ServerItemData:resetVitRecoverTime() - local maxCount = self:getMaxVit() - local ServerGameData = require "app/server/server_game_data" - local currentCount = ServerGameData.PlayerData:getVit() - if currentCount >= maxCount then -- 已经达到上限 - return - end - - local currentCount = self:getItemNumById(GConst.ItemConst.ITEM_ID_VIT) - if currentCount >= maxCount then -- 已经达到上限 - return - end - for i,v in ipairs(self.data.recoveries) do - if v.cfg_id == GConst.ItemConst.ITEM_ID_VIT then - self.data.recoveries[i].ts = Time:getServerTime() - end - end -end - -function ServerItemData:getRecoveryCfg() - if self.recoveryCfg == nil then - self.recoveryCfg = ConfigManager:getConfig("recovery") - end - return self.recoveryCfg -end - -function ServerItemData:getMaxVit() - if self.maxVit == nil then - local cfg = self:getRecoveryCfg()[GConst.ItemConst.ITEM_ID_VIT] - self.maxVit = cfg.limit - end - return self.maxVit -end - -function ServerItemData:addItemReward(item, getType) - local id = GFunc.getRewardId(item) - local num = GFunc.getRewardNum(item) - self:addItem(id, num, getType) -end - -function ServerItemData:addItemCost(cost) - local id = GFunc.getRewardId(cost) - local num = GFunc.getRewardNum(cost) - self:addItem(id, -num) -end - -function ServerItemData:addItem(id, num, getType) - if id == GConst.ItemConst.ITEM_ID_VIT then - local maxCount = self:getMaxVit() - local currentCount = self:getItemNumById(GConst.ItemConst.ITEM_ID_VIT) - local isMax = currentCount >= maxCount - self:_addItem(id, num, getType) - local currentCount = currentCount + num - local isMax1 = currentCount >= maxCount - if not isMax1 then - if isMax then - self:resetVitRecoverTime() - else - self:recoveryItems() - end - end - else - self:_addItem(id, num, getType) - end -end - -function ServerItemData:_addItem(id, num, getType) - local idStr = tostring(id) - local hadNum = 0 - if self.data.items[idStr] then - hadNum = self.data.items[idStr].count - else - self.data.items[idStr] = {} - self.data.items[idStr].cfg_id = id - self.data.items[idStr].count = 0 - end - local finalNum = (hadNum or 0) + num - if finalNum < 0 then - finalNum = 0 - end - local ServerGameData = require "app/server/server_game_data" - if id == GConst.ItemConst.ITEM_ID_VIT then - ServerGameData.PlayerData:setVit(finalNum) - end - self.data.items[idStr].count = finalNum -end - -return ServerItemData \ No newline at end of file diff --git a/lua/app/server/data/server_item_data.lua.meta b/lua/app/server/data/server_item_data.lua.meta deleted file mode 100644 index a6a0cd62..00000000 --- a/lua/app/server/data/server_item_data.lua.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: 21a3f0972e236154197f14df6f246f40 -ScriptedImporter: - internalIDToNameTable: [] - externalObjects: {} - serializedVersion: 2 - userData: - assetBundleName: - assetBundleVariant: - script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/server/data/server_player_data.lua b/lua/app/server/data/server_player_data.lua deleted file mode 100644 index a226caed..00000000 --- a/lua/app/server/data/server_player_data.lua +++ /dev/null @@ -1,20 +0,0 @@ -local ServerPlayerData = class("ServerPlayerData", ServerBaseData) - -function ServerPlayerData:init(data) - self.data.loginDay = data and data.loginDay or 0 - self.data.lastLoginTime = data and data.lastLoginTime or 0 - if self.data.lastLoginTime < Time:getBeginningOfServerToday() then - self.data.lastLoginTime = Time:getBeginningOfServerToday() - self.data.loginDay = self.data.loginDay + 1 - end -end - -function ServerPlayerData:setVit(vit) - self.vit = tonumber(vit) or 0 -end - -function ServerPlayerData:getVit() - return self.vit or 0 -end - -return ServerPlayerData \ No newline at end of file diff --git a/lua/app/server/data/server_player_data.lua.meta b/lua/app/server/data/server_player_data.lua.meta deleted file mode 100644 index cb47e880..00000000 --- a/lua/app/server/data/server_player_data.lua.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: e1a04f57465c5be4882f1efdec828dc2 -ScriptedImporter: - internalIDToNameTable: [] - externalObjects: {} - serializedVersion: 2 - userData: - assetBundleName: - assetBundleVariant: - script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/server/data/server_tutorial_data.lua b/lua/app/server/data/server_tutorial_data.lua deleted file mode 100644 index 0a240513..00000000 --- a/lua/app/server/data/server_tutorial_data.lua +++ /dev/null @@ -1,19 +0,0 @@ -local ServerTutorialData = class("ServerTutorialData", ServerBaseData) - -function ServerTutorialData:init(data) - if data then - self.data.markedGuide = data.markedGuide or {} - else - self.data.markedGuide = {} - end -end - -function ServerTutorialData:markGuide(id) - id = tostring(id) - if not id then - return - end - self.data.markedGuide[id] = true -end - -return ServerTutorialData \ No newline at end of file diff --git a/lua/app/server/data/server_tutorial_data.lua.meta b/lua/app/server/data/server_tutorial_data.lua.meta deleted file mode 100644 index d934922e..00000000 --- a/lua/app/server/data/server_tutorial_data.lua.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: 8482be101c0b05347b61cef1d8925dac -ScriptedImporter: - internalIDToNameTable: [] - externalObjects: {} - serializedVersion: 2 - userData: - assetBundleName: - assetBundleVariant: - script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/server/manager.meta b/lua/app/server/manager.meta deleted file mode 100644 index 014a827a..00000000 --- a/lua/app/server/manager.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 09d17db485e3192459d5fcd0a0cefb49 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/lua/app/server/manager/server_chapter_manager.lua b/lua/app/server/manager/server_chapter_manager.lua deleted file mode 100644 index 4f7e9361..00000000 --- a/lua/app/server/manager/server_chapter_manager.lua +++ /dev/null @@ -1,98 +0,0 @@ -local ServerChapterManager = {} - -function ServerChapterManager:openBox(params, callback) - local result = { - status = 1 - } - if params == nil or not params.id or not params.index then - if callback then - callback(result) - end - return - end - - local ServerGameData = ServerDataManager:getServerGameData() - - if not ServerGameData.ChapterData:openChapterBox(params.id, params.index) then - if callback then - callback(result) - end - return - end - - local rewards = ServerGameData.ChapterData:getChapterBoxRewards(params.id, params.index) - result.rewards = ServerGameData:addRewards(rewards) - result.chapterData = ServerGameData.ChapterData:getCloneData() - result.status = 0 - - - if callback then - callback(result) - end -end - -function ServerChapterManager:startFight(params, callback) - local result = { - status = 1 - } - local cost = GFunc.getConstReward("chapter_cost") - if cost == nil then - if callback then - callback(result) - end - return - end - local vitCostNum = GFunc.getRewardNum(cost) - local ServerGameData = ServerDataManager:getServerGameData() - if vitCostNum > ServerGameData.BagData.ItemData:getItemNumById(GConst.ItemConst.ITEM_ID_VIT) then - if callback then - callback(result) - end - return - end - ServerGameData.ChapterData:enterFight(params.id) - result.cost = ServerGameData:addCosts({cost}) - result.status = 0 - if callback then - callback(result) - end -end - -function ServerChapterManager:endFight(params, callback) - local result = { - status = 1 - } - if params == nil or not params.id or not params.combatReport then - if callback then - callback(result) - end - return - end - - local cfg = ConfigManager:getConfig("chapter")[params.id] - local rewards = {} - for i = 1, params.combatReport.wave do - for _, reward in ipairs(cfg.wave_reward) do - table.insert(rewards, reward) - end - end - - if params.combatReport.victory then - for _, reward in ipairs(cfg.finish_reward) do - table.insert(rewards, reward) - end - end - rewards = GFunc.mergeRewards(rewards) - local ServerGameData = ServerDataManager:getServerGameData() - ServerGameData.ChapterData:fightChapter(params.id, params.combatReport.victory, params.combatReport.wave) - ServerGameData.HeroData:tryUnlockHeroByChapterId(ServerGameData.ChapterData:getMaxChapterId()) - result.rewards = ServerGameData:addRewards(rewards) - result.chapterData = ServerGameData.ChapterData:getCloneData() - result.status = 0 - - if callback then - callback(result) - end -end - -return ServerChapterManager \ No newline at end of file diff --git a/lua/app/server/manager/server_chapter_manager.lua.meta b/lua/app/server/manager/server_chapter_manager.lua.meta deleted file mode 100644 index 0e36fb97..00000000 --- a/lua/app/server/manager/server_chapter_manager.lua.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: 5a93eee72dda74b4695a1e0de728ac96 -ScriptedImporter: - internalIDToNameTable: [] - externalObjects: {} - serializedVersion: 2 - userData: - assetBundleName: - assetBundleVariant: - script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/server/manager/server_formation_manager.lua b/lua/app/server/manager/server_formation_manager.lua deleted file mode 100644 index e22d8082..00000000 --- a/lua/app/server/manager/server_formation_manager.lua +++ /dev/null @@ -1,27 +0,0 @@ -local ServerFormationManager = {} - -function ServerFormationManager:updateFormation(params, callback) - local result = { - status = 1 - } - if params == nil then - if callback then - callback(result) - end - return - end - local formationType = params.formationType - local matchType = tostring(params.matchType) - local heroId = params.heroId - if formationType and matchType and heroId then - local ServerGameData = require "app/server/server_game_data" - if ServerGameData.FormationData:upHeroToFormation(formationType, matchType, heroId) then - result.status = 0 - end - end - if callback then - callback(result) - end -end - -return ServerFormationManager \ No newline at end of file diff --git a/lua/app/server/manager/server_formation_manager.lua.meta b/lua/app/server/manager/server_formation_manager.lua.meta deleted file mode 100644 index 54f093a9..00000000 --- a/lua/app/server/manager/server_formation_manager.lua.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: 3f6f74ff6268bec4593ef0e060480d93 -ScriptedImporter: - internalIDToNameTable: [] - externalObjects: {} - serializedVersion: 2 - userData: - assetBundleName: - assetBundleVariant: - script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/server/manager/server_hero_manager.lua b/lua/app/server/manager/server_hero_manager.lua deleted file mode 100644 index 0d9ad23c..00000000 --- a/lua/app/server/manager/server_hero_manager.lua +++ /dev/null @@ -1,65 +0,0 @@ -local ServerHeroManager = {} - -function ServerHeroManager:onUpgradeHero(params, callback) - local result = { - status = 1 - } - if params == nil then - if callback then - callback(result) - end - return - end - local heroId = params.heroId - local heroCfg = ConfigManager:getConfig("hero")[heroId] - if heroId and heroCfg then - local ServerGameData = ServerDataManager:getServerGameData() - local ItemData = ServerGameData.BagData.ItemData - local heroInfo = ServerGameData.HeroData:getHeroByCfgId(heroId) or {cfg_id = heroId, lv = 0} - local lv = heroInfo.lv + 1 - if lv < heroCfg.begin_lv then - lv = heroCfg.begin_lv - end - local nextLvInfo = ConfigManager:getConfig("hero_level")[lv] - if not nextLvInfo then - return - end - local fieldName = "cost_" .. heroCfg.qlt - nextLvInfo = nextLvInfo[fieldName] - - local fragmentCost = nextLvInfo[1] or 0 - if not ItemData:tryAddItem(heroCfg.item_id, -fragmentCost) then - return - end - - local goldCost = nextLvInfo[2] or 0 - if not ItemData:tryAddItem(GConst.ItemConst.ITEM_ID_GOLD, -goldCost) then - return - end - - local costs = { - { - type = GConst.REWARD_TYPE.ITEM, - id = heroCfg.item_id, - num = fragmentCost - }, - { - type = GConst.REWARD_TYPE.ITEM, - id = GConst.ItemConst.ITEM_ID_GOLD, - num = goldCost - } - } - - ServerGameData.HeroData:upgradeHero(heroId, lv) - result.heroId = heroId - result.lv = lv - result.costs = ServerGameData:addCosts(costs) - - result.status = 0 - end - if callback then - callback(result) - end -end - -return ServerHeroManager \ No newline at end of file diff --git a/lua/app/server/manager/server_hero_manager.lua.meta b/lua/app/server/manager/server_hero_manager.lua.meta deleted file mode 100644 index d063a5dc..00000000 --- a/lua/app/server/manager/server_hero_manager.lua.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: b697148ece07e2f4c873aa1bd9589e59 -ScriptedImporter: - internalIDToNameTable: [] - externalObjects: {} - serializedVersion: 2 - userData: - assetBundleName: - assetBundleVariant: - script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/server/manager/server_tutorial_manager.lua b/lua/app/server/manager/server_tutorial_manager.lua deleted file mode 100644 index 8e6c1150..00000000 --- a/lua/app/server/manager/server_tutorial_manager.lua +++ /dev/null @@ -1,24 +0,0 @@ -local ServerChapterManager = {} - -function ServerChapterManager:markGuide(params, callback) - local result = { - status = 1 - } - if params == nil or not params.id then - if callback then - callback(result) - end - return - end - - local ServerGameData = ServerDataManager:getServerGameData() - ServerGameData.TutorialData:markGuide(params.id) - result.id = params.id - result.status = 0 - - if callback then - callback(result) - end -end - -return ServerChapterManager \ No newline at end of file diff --git a/lua/app/server/manager/server_tutorial_manager.lua.meta b/lua/app/server/manager/server_tutorial_manager.lua.meta deleted file mode 100644 index b9e2a302..00000000 --- a/lua/app/server/manager/server_tutorial_manager.lua.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: 635bfc3932a24014192fd87a7c164c14 -ScriptedImporter: - internalIDToNameTable: [] - externalObjects: {} - serializedVersion: 2 - userData: - assetBundleName: - assetBundleVariant: - script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/server/server_data_const.lua b/lua/app/server/server_data_const.lua deleted file mode 100644 index 93abbc2c..00000000 --- a/lua/app/server/server_data_const.lua +++ /dev/null @@ -1,19 +0,0 @@ -local ServerDataConst = {} - -ServerDataConst.REWARD_TYPE = { - REWARD_NONE = 0, - ITEM = 1, -} - -ServerDataConst.DATA_OP_BEHAVIOR = { - SYNC_DATA = "SYNC_DATA", - CROSS_DAY = "CROSS_DAY", - UPDATE_FORMATION = "UPDATE_FORMATION", - UPGRADE_HERO = "UPGRADE_HERO", - START_FIGHT = "START_FIGHT", - END_FIGHT = "END_FIGHT", - OPEN_CHAPTER_BOX = "OPEN_CHAPTER_BOX", - MARK_GUIDE = "MARK_GUIDE", -} - -return ServerDataConst \ No newline at end of file diff --git a/lua/app/server/server_data_const.lua.meta b/lua/app/server/server_data_const.lua.meta deleted file mode 100644 index 135b5bbe..00000000 --- a/lua/app/server/server_data_const.lua.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: 8af3001c06ad5ab44ba95cb6a2486229 -ScriptedImporter: - internalIDToNameTable: [] - externalObjects: {} - serializedVersion: 2 - userData: - assetBundleName: - assetBundleVariant: - script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/server/server_data_manager.lua b/lua/app/server/server_data_manager.lua deleted file mode 100644 index e7c73c67..00000000 --- a/lua/app/server/server_data_manager.lua +++ /dev/null @@ -1,181 +0,0 @@ -local ServerGameData = require "app/server/server_game_data" - -local ServerDataManager = {} - -function ServerDataManager:init() - self.ServerFormationManager = require("app/server/manager/server_formation_manager") - self.ServerHeroManager = require("app/server/manager/server_hero_manager") - self.ServerChapterManager = require("app/server/manager/server_chapter_manager") - self.ServerTutorialManager = require("app/server/manager/server_tutorial_manager") -end - -function ServerDataManager:saveData() - ServerGameData:saveData() -end - -function ServerDataManager:randomReward(rewardsArr, count, callback) - local maxWeight = 0 - local reward - for i = 1, count do - reward = rewardsArr[i] - maxWeight = maxWeight + reward.weight - end - local randomWeight - if callback then - randomWeight = callback(1, maxWeight) - else - randomWeight = math.random(1, maxWeight) - end - local idx - for i = 1, count do - if randomWeight <= rewardsArr[i].weight then - idx = i - break - else - randomWeight = randomWeight - rewardsArr[i].weight - end - end - return idx -end - -function ServerDataManager:dataOperate(behavior, params, callback) - local opFunc = ServerDataManager.OP_FUNC[behavior] - if opFunc then - opFunc(params, function(result) - if callback then - callback(result) - end - end) - -- TODO临时处理 - ServerGameData:saveData() - else - Logger.logError("Undefined data operation function, please check :%s", behavior) - end -end - -function ServerDataManager:onSyncData(params, callback) - -- 初始化本地数据 - ServerGameData:initData() - local data = ServerGameData:getData() - if callback then - callback(data) - end -end - -ServerDataManager.OP_FUNC = { - [GConst.ServerDataConst.DATA_OP_BEHAVIOR.SYNC_DATA] = function (...) ServerDataManager:onSyncData(...) end, - [GConst.ServerDataConst.DATA_OP_BEHAVIOR.UPDATE_FORMATION] = function (...) ServerDataManager.ServerFormationManager:updateFormation(...) end, - [GConst.ServerDataConst.DATA_OP_BEHAVIOR.UPGRADE_HERO] = function (...) ServerDataManager.ServerHeroManager:onUpgradeHero(...) end, - [GConst.ServerDataConst.DATA_OP_BEHAVIOR.START_FIGHT] = function(...) ServerDataManager.ServerChapterManager:startFight(...) end, - [GConst.ServerDataConst.DATA_OP_BEHAVIOR.END_FIGHT] = function(...) ServerDataManager.ServerChapterManager:endFight(...) end, - [GConst.ServerDataConst.DATA_OP_BEHAVIOR.OPEN_CHAPTER_BOX] = function(...) ServerDataManager.ServerChapterManager:openBox(...) end, - [GConst.ServerDataConst.DATA_OP_BEHAVIOR.MARK_GUIDE] = function(...) ServerDataManager.ServerTutorialManager:markGuide(...) end, -} - -function ServerDataManager:dealGM(params, callback) - if IS_PUBLISH then - return - end - if not params or not params.args then - return - end - local args = params.args - if args[1] == "add_item" then - local id = tonumber(args[2]) - local count = tonumber(args[3]) - if not id or not count then - return - end - ServerGameData.BagData.ItemData:addItem(id, count) - ServerGameData.BagData.ItemData:saveLocalData() - if id == GConst.ItemConst.ITEM_ID_EXP then - ServerGameData.PlayerData:addExp(count) - end - elseif args[1] == "add_items" then - local cfg = ConfigManager:getConfig("item") - local count = tonumber(args[2]) - if not count then - for k, v in pairs(cfg) do - if k == GConst.ItemConst.ITEM_ID_GOLD then - ServerGameData.BagData.ItemData:addItem(k, 99999999) - else - ServerGameData.BagData.ItemData:addItem(k, 2000) - end - if k == GConst.ItemConst.ITEM_ID_EXP then - ServerGameData.PlayerData:addExp(1000) - end - end - else - for k, v in pairs(cfg) do - ServerGameData.BagData:addItem(k, count) - if k == GConst.ItemConst.ITEM_ID_EXP then - ServerGameData.PlayerData:addExp(count) - end - end - end - elseif args[1] == "del_item" then - local id = tonumber(args[2]) - local count = tonumber(args[3]) - if not id or not count then - return - end - ServerGameData.BagData.ItemData:addItem(id, -count) - if id == GConst.ItemConst.ITEM_ID_EXP then - ServerGameData.PlayerData:addExp(-count) - end - elseif args[1] == "clear_item" then - local items = ServerGameData.BagData.ItemData:getAllItems() - 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 - elseif args[1] == "pass_chapter" then - local maxId = tonumber(args[2]) - if not maxId then - return - end - local cfg = ConfigManager:getConfig("chapter") - for id, info in ipairs(cfg) do - if id > maxId then - break - end - - local maxWave = info.box_num[#info.box_num] - if maxWave then - ServerGameData.ChapterData:fightChapter(id, true, maxWave) - end - ServerGameData.HeroData:tryUnlockHeroByChapterId(id) - end - ServerGameData.ChapterData.data.maxChapterId = maxId - end - - ServerGameData:saveData() - if callback then - callback() - end -end - -function ServerDataManager:getServerGameData() - return ServerGameData -end - -return ServerDataManager \ No newline at end of file diff --git a/lua/app/server/server_data_manager.lua.meta b/lua/app/server/server_data_manager.lua.meta deleted file mode 100644 index 0d713de2..00000000 --- a/lua/app/server/server_data_manager.lua.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: 46cc0de161cb26d4f901f3475f83927a -ScriptedImporter: - internalIDToNameTable: [] - externalObjects: {} - serializedVersion: 2 - userData: - assetBundleName: - assetBundleVariant: - script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/server/server_game_data.lua b/lua/app/server/server_game_data.lua deleted file mode 100644 index d60dc15f..00000000 --- a/lua/app/server/server_game_data.lua +++ /dev/null @@ -1,272 +0,0 @@ -local ServerGameData = { - seed = {} -} - -local TempRewards = {} -local WeightArr = {} - -function ServerGameData:init() - if self.isInit then - for k, v in pairs(self.dataMap) do - v:_clear() - end - return - end - self.isInit = true - self:initServerData("PlayerData", "app/server/data/server_player_data") - self:initServerData("BagData", "app/server/data/server_bag_data") - self:initServerData("HeroData", "app/server/data/server_hero_data") - self:initServerData("ChapterData", "app/server/data/server_chapter_data") - self:initServerData("FormationData", "app/server/data/server_formation_data") - self:initServerData("TutorialData", "app/server/data/server_tutorial_data") -end - -function ServerGameData:initData() - self.disableSave = true - self:init() - if self.distinctId == nil or self.distinctId == "" then - self.distinctId = LocalData:getDistinctId() - end - local isNewPlayer = self:getIsNewPlayer() - if isNewPlayer then - if EDITOR_MODE then - Logger.logHighlight("create new player") - end - for k, v in pairs(self.dataMap) do - v:init() - end - local playerInitialCfg = ConfigManager:getConfig("player_initial") - if playerInitialCfg then - for k, v in pairs(playerInitialCfg) do - if v.reward then - self.BagData.ItemData:addItemReward(v.reward, BIReport.ITEM_GET_TYPE.NEW_PLAYER_INITIAL) - local rewardId = GFunc.getRewardId(v.reward) - local rewardNum = GFunc.getRewardNum(v.reward) - if rewardId == GConst.ItemConst.ITEM_ID_EXP then - self.PlayerData:addExp(rewardNum) - end - end - end - local itemCfg = ConfigManager:getConfig("item") - local heroCfg = ConfigManager:getConfig("hero") - local heroLvCfg = ConfigManager:getConfig("hero_level") - -- 如果初始化里面有碎片就直接合成 - local initHeroMap = {} - local items = self.BagData.ItemData:getAllItems() - for idStr, item in pairs(items) do - local itemInfo = itemCfg[item.cfg_id] - if itemInfo and itemInfo.type == GConst.ItemConst.ITEM_TYPE.HERO_FRAGMENT then -- 英雄碎片就直接合成 - local heroCfgId = itemInfo.parameter or 0 - local hero = self.HeroData:getHeroByCfgId(heroCfgId) - if hero == nil or hero.lv <= 0 then -- 没有此英雄的时候才自动转化,不消耗金币,且只激活1级 - local heroInfo = heroCfg[heroCfgId] - if heroInfo then - local costKey = "cost_" .. heroInfo.qlt - for k, v in ipairs(heroLvCfg) do - if v[costKey] then -- 第一个有值的就是解锁所需的数量 - local needCout = v[costKey][1] - if item.count >= needCout then - item.count = item.count - needCout - self.HeroData:addHero(heroCfgId, k) - initHeroMap[heroInfo.position] = heroCfgId - end - break - end - end - end - end - end - end - for matchType, heroId in pairs(initHeroMap) do - matchType = tostring(matchType) - self.FormationData:upHeroToFormation(GConst.BattleConst.BATTLE_TYPE.STAGE, matchType, heroId) - end - end - self:setNotNewPlayer() - else - for k, v in pairs(self.dataMap) do - v:loadLocalData() - end - end - self.disableSave = false -end - -function ServerGameData:initServerData(name, path) - self[name] = require(path):create() - if self.dataMap == nil then - self.dataMap = {} - end - self.dataMap[name] = self[name] -end - -function ServerGameData:getData() - local data = {} - for k, v in pairs(self.dataMap) do - data[k] = v:getCloneData() - end - return data -end - -function ServerGameData:saveData() - if self.disableSave then - return - end - for k, v in pairs(self.dataMap) do - v:saveLocalData() - end - LocalData:save() -end - --- 根据配置表添加奖励 -function ServerGameData:addRewards(cfgRewards, getType) - local rewards = {} - if cfgRewards then - local count = #TempRewards - for i = 1, count do - table.remove(TempRewards) - end - for _, reward in ipairs(cfgRewards) do - local rewardType = GFunc.getRewardType(reward) - if rewardType == GConst.ServerDataConst.REWARD_TYPE.ITEM then - local rewardId = GFunc.getRewardId(reward) - local rewardNum = GFunc.getRewardNum(reward) - local cfg = ConfigManager:getItemConfig()[rewardId] - if cfg.hero_drop then - self:openRewardBox(TempRewards, cfg.hero_drop, rewardNum, rewardId) - else - table.insert(TempRewards, reward) - end - else - table.insert(TempRewards, reward) - end - end - count = #TempRewards - for i = 1, count do - local reward = table.remove(TempRewards) - local newReward = self:getNewReward() - local rewardType = GFunc.getRewardType(reward) - newReward.type = rewardType - if rewardType == GConst.ServerDataConst.REWARD_TYPE.ITEM then - self.BagData.ItemData:addItemReward(reward, getType) - local rewardId = GFunc.getRewardId(reward) - local rewardNum = GFunc.getRewardNum(reward) - if rewardId == GConst.ItemConst.ITEM_ID_EXP then - self.PlayerData:addExp(rewardNum) - end - local item = self:getNewItem() - item.cfg_id = rewardId - item.count = rewardNum - newReward.item = item - end - table.insert(rewards, newReward) - end - end - return rewards -end - - --- 根据配置表添加奖励 -function ServerGameData:addCosts(cfgRewards, getType) - local rewards = {} - if cfgRewards then - local count = #TempRewards - for i = 1, count do - table.remove(TempRewards) - end - for _, reward in ipairs(cfgRewards) do - table.insert(TempRewards, reward) - end - count = #TempRewards - for i = 1, count do - local reward = table.remove(TempRewards) - local newReward = self:getNewReward() - local rewardType = GFunc.getRewardType(reward) - newReward.type = rewardType - if rewardType == GConst.ServerDataConst.REWARD_TYPE.ITEM then - self.BagData.ItemData:addItemCost(reward, getType) - local rewardId = GFunc.getRewardId(reward) - local rewardNum = GFunc.getRewardNum(reward) - newReward.item = { - id = rewardId, - num = rewardNum - } - end - table.insert(rewards, newReward) - end - end - return rewards -end - -function ServerGameData:getNewReward() - local rewards = { - type = 0, - item = {}, - } - return rewards -end - -function ServerGameData:getNewItem() - local item = { - cfg_id = 0, - count = 0 - } - return item -end - -function ServerGameData:openRewardBox(finalReward, drop, num, id) - local count = 0 - for _, v in ipairs(drop) do - if self.HeroData:getIsUnlockHero(v.id) then - count = count + 1 - WeightArr[count] = v - end - end - for i = 1, num do - local rewardIdx = ServerDataManager:randomReward(WeightArr, count, function (min, max) - return ServerGameData:randomItemBox(id, min, max) - end) - table.insert(finalReward, WeightArr[rewardIdx]) - end -end - -function ServerGameData:randomItemBox(id, min, max) - id = tostring(id) - local seed = self.seed[id] - if not seed then - local str = self.distinctId .. "_ItemBox_" .. id - seed = GFunc.hash(str) - self.seed[id] = seed - end - self.seed[id] = (seed*9301 + 49297)%233280 - return min + self.seed[id]*(max - min + 1)//233280 -end - -function ServerGameData:getDistinctId() - return self.distinctId -end - -function ServerGameData:setDistinctId(distinctId) - self.distinctId = distinctId -end - -function ServerGameData:getIsNewPlayer() - return LocalData:getIsNewPlayer() -end - -function ServerGameData:setNotNewPlayer() - LocalData:setNotNewPlayer() -end - -if NOT_PUBLISH then - ServerGameData.editorGetIsNewPlayer = ServerGameData.getIsNewPlayer - function ServerGameData:getIsNewPlayer() - return LocalData:getInt(LocalData:getDistinctId() .. LocalData.KEYS.IS_NEW_PLAYER, 0) == 0 - end - - ServerGameData.editorSetNotNewPlayer = ServerGameData.setNotNewPlayer - function ServerGameData:setNotNewPlayer() - LocalData:setInt(LocalData:getDistinctId() .. LocalData.KEYS.IS_NEW_PLAYER, 1) - end -end - -return ServerGameData \ No newline at end of file diff --git a/lua/app/server/server_game_data.lua.meta b/lua/app/server/server_game_data.lua.meta deleted file mode 100644 index 3f257a04..00000000 --- a/lua/app/server/server_game_data.lua.meta +++ /dev/null @@ -1,10 +0,0 @@ -fileFormatVersion: 2 -guid: 341e1d539fc4d7a45a47ebb7a3376088 -ScriptedImporter: - internalIDToNameTable: [] - externalObjects: {} - serializedVersion: 2 - userData: - assetBundleName: - assetBundleVariant: - script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/ui/gm/gm_tool_ui.lua b/lua/app/ui/gm/gm_tool_ui.lua index 5a83b59a..24fa325b 100644 --- a/lua/app/ui/gm/gm_tool_ui.lua +++ b/lua/app/ui/gm/gm_tool_ui.lua @@ -89,12 +89,12 @@ function GMToolUI:sendMsg(gmCommand) else local args = {} args.args = string.split(gmCommand, " ") - ServerDataManager:dealGM(args, function() - ServerDataManager:dataOperate(GConst.ServerDataConst.DATA_OP_BEHAVIOR.SYNC_DATA, GConst.EMPTY_TABLE, function(msgData) - DataManager:initWithServerData(msgData) - ModuleManager.MaincityManager:firstEnterMainCity() - end) - end) + -- :dealGM(args, function() + -- :dataOperate(GConst..DATA_OP_BEHAVIOR.SYNC_DATA, GConst.EMPTY_TABLE, function(msgData) + -- DataManager:initWithServerData(msgData) + -- ModuleManager.MaincityManager:firstEnterMainCity() + -- end) + -- end) end end diff --git a/lua/app/userdata/chapter/chapter_data.lua b/lua/app/userdata/chapter/chapter_data.lua index 3e008d2e..954000a5 100644 --- a/lua/app/userdata/chapter/chapter_data.lua +++ b/lua/app/userdata/chapter/chapter_data.lua @@ -7,24 +7,30 @@ function ChapterData:ctor() self.data.chapterId = MIN_CHAPTER_ID self.data.maxChapterId = 0 self.data.isDirty = false - self.data.chapterBoxInfo = {} - self.data.chapterFightInfo = {} end function ChapterData:clear() self.data.chapterId = MIN_CHAPTER_ID self.data.maxChapterId = 0 - self.data.chapterBoxInfo = {} - self.data.chapterFightInfo = {} end function ChapterData:init(data, notChangeChapterId) - self.data.maxChapterId = data and data.maxChapterId or MIN_CHAPTER_ID - 1 - if not notChangeChapterId then - self.data.chapterId = self:getNextChapter(self.data.maxChapterId) + if not data then + return end - self.data.chapterBoxInfo = data and data.chapterBoxInfo or {} - self.data.chapterFightInfo = data and data.chapterFightInfo or {} + + self.maxWave = data.max_wave or 0 + if self.maxWave >= self:getChapterCfgMaxWave(data.max_chapter_id) then + self.data.maxChapterId = data.max_chapter_id + else + self.data.maxChapterId = data.max_chapter_id - 1 + end + + if not notChangeChapterId then + self.data.chapterId = data.max_chapter_id + end + + self.data.chapterInfo = data.chapter_info or {} end function ChapterData:getIsFirstChapter(chapterId) @@ -129,13 +135,13 @@ function ChapterData:getChapterBoxNum(chapterId, index) end function ChapterData:getChapterBoxRewardGot(chapterId, index) - chapterId = tostring(chapterId or self:getChapterId()) - local list = self.data.chapterBoxInfo[chapterId] - if not list then + chapterId = chapterId or self:getChapterId() + local info = self.data.chapterInfo[chapterId] + if not info or not info.index then return false end - for _, idx in ipairs(list) do + for _, idx in ipairs(info.index) do if idx == index then return true end @@ -166,18 +172,34 @@ function ChapterData:getChapterBoxRewards(chapterId, index) end function ChapterData:getChapterMaxWave(chapterId) - chapterId = tostring(chapterId or self:getChapterId()) - if self.data.chapterFightInfo[chapterId] then - return self.data.chapterFightInfo[chapterId].maxWave + chapterId = chapterId or self:getChapterId() + if chapterId <= self.maxChapterId then + return self:getChapterCfgMaxWave(chapterId) + else + return self.maxWave + end +end + +function ChapterData:getChapterCfgMaxWave(chapterId) + if not self.chapterCfgMaxWaveMap then + self.chapterCfgMaxWaveMap = {} + end + if not self.chapterCfgMaxWaveMap[chapterId] then + local chapterInfo = self:getChapterCfg()[chapterId] + if not chapterInfo then + self.chapterCfgMaxWaveMap[chapterId] = 1 + else + self.chapterCfgMaxWaveMap[chapterId] = #chapterInfo.monster + end end - return 0 + return self.chapterCfgMaxWaveMap[chapterId] end function ChapterData:getChapterFightCount(chapterId) - chapterId = tostring(chapterId or self:getChapterId()) - if self.data.chapterFightInfo[chapterId] then - return self.data.chapterFightInfo[chapterId].fightCount or 0 + chapterId = chapterId or self:getChapterId() + if self.data.chapterInfo[chapterId] then + return self.data.chapterInfo[chapterId].total_count or 0 end return 0 @@ -227,18 +249,21 @@ function ChapterData:getIsHaveRewards(chapterId) if chapterId > self.data.maxChapterId + 1 then return false end - local chapterStr = tostring(chapterId) - local list = self.data.chapterBoxInfo[chapterStr] + local info = self.data.chapterInfo[chapterId] + if not info or not info.index then + return false + end + local count = self:getChapterBoxCount(chapterId) - if list and #list == count then -- 数量一致说明都领完了 + if info.index and #info.index == count then -- 数量一致说明都领完了 return false elseif chapterId < self.data.maxChapterId then return true end - local curMaxWave = self:getChapterMaxWave(chapterStr) + local curMaxWave = self:getChapterMaxWave(chapterId) for i = 1, count do local needWave = self:getChapterBoxNum(chapterId, i) - local rewardGot = self:getChapterBoxRewardGot(chapterStr, i) + local rewardGot = self:getChapterBoxRewardGot(chapterId, i) if needWave <= curMaxWave and not rewardGot then -- 有可以领但是没有领的奖励 return true end @@ -247,12 +272,27 @@ function ChapterData:getIsHaveRewards(chapterId) end function ChapterData:getChapterPassed(chapterId) - chapterId = tostring(chapterId or self:getChapterId()) - if self.data.chapterFightInfo[chapterId] then - return self.data.chapterFightInfo[chapterId].victory or false + chapterId = chapterId or self:getChapterId() + if chapterId <= self.maxChapterId then + return true + else + return self.maxWave >= self:getChapterCfgMaxWave(chapterId) + end +end + +function ChapterData:openBox(chapterId, index) + if not self.data.chapterInfo[chapterId] or not self.data.chapterInfo[chapterId].index then + return + end + for _, idx in ipairs(self.data.chapterInfo[chapterId].index) do + if idx == index then + return + end end - return false + table.insert(self.data.chapterInfo[chapterId].index, index) + + self:setDirty() end return ChapterData \ No newline at end of file