diff --git a/lua/app/common/bi_report.lua b/lua/app/common/bi_report.lua index e37195f7..0ffca24e 100644 --- a/lua/app/common/bi_report.lua +++ b/lua/app/common/bi_report.lua @@ -115,57 +115,7 @@ BIReport.RUNE_OPT_TYPE = { } BIReport.ITEM_GET_TYPE = { - RUNE_LV_UP = "RuneLvUp", -- 符文升级 - RUNE_SUMMON = "RuneSummon", -- 符文召唤 - MINING_DIGGING = "MiningDigging", -- 挖矿 - MINING_RECOVER = "MiningRecover", -- 挖矿回复 - MINING_REWARD = "MiningReward", -- 挖矿领奖 - RESEARCH = "Research", -- 研究快速结束 - MASTERY_UPGRADE = "MasteryUpgrade", - MASTERY_RESET = "MasteryReset", - TRAIN_UP = "TrainUp", -- 修炼升级 - QUICK_PASS_UP = "QuickPassUp", -- 速通升级 - REBORN = "Reborn", -- 领悟 - QUICK_PASS = "QuickPass", -- 速通 - SIGNIN = "SignIn", -- 签到 - CHAPTER_DROP = "ChapterDrop", - CHAPTER_PASS = "ChapterPass", -- 章节通关 - CHAPTER_REWARD_STAGE = "ChapterRewardStage", -- 章节奖励 - LOOK_ADS = "LookAds",-- 看广告 - DAILY_TASK = "DailyTask", -- 每日任务 - IDLE_BASE = "IdleBase", -- 普通挂机 - IDLE_AD = "IdleAd", -- 广告挂机 - SEVEN_DAY_TASK = "SevenDayTask", - SEVEN_DAY_STEP_REWARD = "SevenDayStepReward", - SDK_PAY = "SdkPay", - TUTORIAL_TASK = "TutorialTask", - DUNGEON = "Dungeon", -- 副本 - ARENA = "Arena", -- 英雄大会 - MONTH_CARD = "MnonthCard", -- 月卡 - BATTLE_PASS_REWARD = "BattlePassReward", - BATTLE_PASS_TASK = "BattlePassTask", - BATTLE_REVIVE = "BattleRevive", - RENAME = "Rename", - MAIL = "Mail", - FUND_CHAPTER = "FuncChapter", - - MALL_POP_GIFT = "MallPopGift", - MALL_SKIP_AD_GIFT = "MallSkipAdGift", - MALL_SUBSCRIBE_BLESSING_GIFT = "MallSubscribeBlessingGift", - MALL_MONTH_CARD = "MallMonthCard", - MALL_LIMIT_GIFT = "MallLimitGift", - MALL_FIRST_RECHARGE_GIFT = "MallFirstRechargeGift", - MALL_CHAPTER_FUND = "MallChapterFund", - MALL_BATTLE_PASS = "MallBattlePass", - - MALL_TREASURE = "MallTreasure", - DAILY_GIFT = "DailyGift", - WEEKLY_GIFT = "WeeklyGift", - - UPDATE_TIME = "UpdateTime", - CROSS_DAY = "CrossDay", - - SUMMON = "Summon", -- 抽卡获取 + NEW_PLAYER_INITIAL = "NewPlayerInitial", -- 新玩家创号自带 } BIReport.ADS_CLICK_TYPE = { @@ -326,8 +276,7 @@ function BIReport:report(name, args) args.gold_value = goldBigBNum.value args.gold_unit = goldBigBNum.unit - local gemBigNum = DataManager.BagData.ItemData:getItemBigNumById(GConst.ItemConst.ITEM_ID_GEM) - args.gem = BigNumOpt.bigNum2Num(gemBigNum) + args.gem = DataManager.BagData.ItemData:getItemById(GConst.ItemConst.ITEM_ID_GEM) end end args.current_version = CS.BF.BFMain.Instance.GameLaunchMgr:GetCurrentVersion() diff --git a/lua/app/common/data_manager.lua b/lua/app/common/data_manager.lua index d03b170a..c55d5f17 100644 --- a/lua/app/common/data_manager.lua +++ b/lua/app/common/data_manager.lua @@ -8,6 +8,7 @@ function DataManager:init() self:initManager("PlayerData", "app/userdata/player/player_data") self:initManager("ChapterData", "app/userdata/chapter/chapter_data") self:initManager("HeroData", "app/userdata/hero/hero_data") + self:initManager("BagData", "app/userdata/bag/bag_data") self:initManager("BattleData", "app/userdata/battle/battle_data") end @@ -48,7 +49,6 @@ function DataManager:checkDataBind() for name, baseData in pairs(self._cacheManager) do if name == "BagData" then changeBindFunc(baseData.ItemData, self[name].ItemData) - changeBindFunc(baseData.EquipData, self[name].EquipData) else changeBindFunc(baseData, self[name]) end @@ -67,6 +67,7 @@ function DataManager:clear() self.BattleData:clear() self.ChapterData:clear() self.HeroData:clear() + self.BagData:clear() ModuleManager.TaskManager:clear() end @@ -76,9 +77,14 @@ function DataManager:initWithServerData(data) Time:setServerTimeZone(0) self.initWithServer = true + if EDITOR_MODE then + Logger.logHighlight("initWithServerData") + Logger.printTable(data) + end self.PlayerData:init(data.PlayerData) self.ChapterData:init(data.ChapterData) self.HeroData:init(data.HeroData) + self.BagData:init(data) self:scheduleGlobal() self:checkDataBind() diff --git a/lua/app/config/hero.lua b/lua/app/config/hero.lua index 46be3308..4aae8ba3 100644 --- a/lua/app/config/hero.lua +++ b/lua/app/config/hero.lua @@ -1,157 +1,5 @@ local hero = { - [1]={ - ["position"]=3, - ["qlt"]=2, - ["base_skill"]=10, - ["rouge_skill_1"]=200101, - ["rouge_skill_2"]=200102, - ["rouge_skill_3"]=200103, - ["hp_1"]=100, - ["hp_2"]=110, - ["hp_3"]=120, - ["hp_4"]=130, - ["hp_5"]=140, - ["hp_6"]=150, - ["hp_7"]=160, - ["hp_8"]=170, - ["hp_9"]=180, - ["hp_10"]=190, - ["hp_11"]=200, - ["hp_12"]=210, - ["hp_13"]=220, - ["hp_14"]=230, - ["hp_15"]=240, - ["atk_1"]=100, - ["atk_2"]=110, - ["atk_3"]=120, - ["atk_4"]=130, - ["atk_5"]=140, - ["atk_6"]=150, - ["atk_7"]=160, - ["atk_8"]=170, - ["atk_9"]=180, - ["atk_10"]=190, - ["atk_11"]=200, - ["atk_12"]=210, - ["atk_13"]=220, - ["atk_14"]=230, - ["atk_15"]=240 - }, - [2]={ - ["position"]=2, - ["qlt"]=2, - ["base_skill"]=20, - ["rouge_skill_1"]=200201, - ["rouge_skill_2"]=200202, - ["rouge_skill_3"]=200203, - ["hp_1"]=100, - ["hp_2"]=110, - ["hp_3"]=120, - ["hp_4"]=130, - ["hp_5"]=140, - ["hp_6"]=150, - ["hp_7"]=160, - ["hp_8"]=170, - ["hp_9"]=180, - ["hp_10"]=190, - ["hp_11"]=200, - ["hp_12"]=210, - ["hp_13"]=220, - ["hp_14"]=230, - ["hp_15"]=240, - ["atk_1"]=100, - ["atk_2"]=110, - ["atk_3"]=120, - ["atk_4"]=130, - ["atk_5"]=140, - ["atk_6"]=150, - ["atk_7"]=160, - ["atk_8"]=170, - ["atk_9"]=180, - ["atk_10"]=190, - ["atk_11"]=200, - ["atk_12"]=210, - ["atk_13"]=220, - ["atk_14"]=230, - ["atk_15"]=240 - }, - [3]={ - ["position"]=4, - ["qlt"]=2, - ["base_skill"]=30, - ["rouge_skill_1"]=200301, - ["rouge_skill_2"]=200302, - ["rouge_skill_3"]=200303, - ["hp_1"]=100, - ["hp_2"]=110, - ["hp_3"]=120, - ["hp_4"]=130, - ["hp_5"]=140, - ["hp_6"]=150, - ["hp_7"]=160, - ["hp_8"]=170, - ["hp_9"]=180, - ["hp_10"]=190, - ["hp_11"]=200, - ["hp_12"]=210, - ["hp_13"]=220, - ["hp_14"]=230, - ["hp_15"]=240, - ["atk_1"]=100, - ["atk_2"]=110, - ["atk_3"]=120, - ["atk_4"]=130, - ["atk_5"]=140, - ["atk_6"]=150, - ["atk_7"]=160, - ["atk_8"]=170, - ["atk_9"]=180, - ["atk_10"]=190, - ["atk_11"]=200, - ["atk_12"]=210, - ["atk_13"]=220, - ["atk_14"]=230, - ["atk_15"]=240 - }, - [4]={ - ["position"]=5, - ["qlt"]=2, - ["base_skill"]=40, - ["rouge_skill_1"]=200401, - ["rouge_skill_2"]=200402, - ["rouge_skill_3"]=200403, - ["hp_1"]=100, - ["hp_2"]=110, - ["hp_3"]=120, - ["hp_4"]=130, - ["hp_5"]=140, - ["hp_6"]=150, - ["hp_7"]=160, - ["hp_8"]=170, - ["hp_9"]=180, - ["hp_10"]=190, - ["hp_11"]=200, - ["hp_12"]=210, - ["hp_13"]=220, - ["hp_14"]=230, - ["hp_15"]=240, - ["atk_1"]=100, - ["atk_2"]=110, - ["atk_3"]=120, - ["atk_4"]=130, - ["atk_5"]=140, - ["atk_6"]=150, - ["atk_7"]=160, - ["atk_8"]=170, - ["atk_9"]=180, - ["atk_10"]=190, - ["atk_11"]=200, - ["atk_12"]=210, - ["atk_13"]=220, - ["atk_14"]=230, - ["atk_15"]=240 - }, - [5]={ + [12001]={ ["position"]=1, ["qlt"]=2, ["base_skill"]=50, @@ -189,45 +37,159 @@ local hero = { ["atk_14"]=230, ["atk_15"]=240 }, - [6]={ - ["position"]=3, - ["qlt"]=3, - ["base_skill"]=60, - ["rouge_skill_1"]=200601, - ["rouge_skill_2"]=200602, - ["rouge_skill_3"]=200603, - ["hp_1"]=150, - ["hp_2"]=165, - ["hp_3"]=180, - ["hp_4"]=195, - ["hp_5"]=210, - ["hp_6"]=225, - ["hp_7"]=240, - ["hp_8"]=255, - ["hp_9"]=270, - ["hp_10"]=285, - ["hp_11"]=300, - ["hp_12"]=315, - ["hp_13"]=330, - ["hp_14"]=345, - ["hp_15"]=360, - ["atk_1"]=150, - ["atk_2"]=165, - ["atk_3"]=180, - ["atk_4"]=195, - ["atk_5"]=210, - ["atk_6"]=225, - ["atk_7"]=240, - ["atk_8"]=255, - ["atk_9"]=270, - ["atk_10"]=285, - ["atk_11"]=300, - ["atk_12"]=315, - ["atk_13"]=330, - ["atk_14"]=345, - ["atk_15"]=360 + [22001]={ + ["position"]=2, + ["qlt"]=2, + ["base_skill"]=20, + ["rouge_skill_1"]=200201, + ["rouge_skill_2"]=200202, + ["rouge_skill_3"]=200203, + ["hp_1"]=100, + ["hp_2"]=110, + ["hp_3"]=120, + ["hp_4"]=130, + ["hp_5"]=140, + ["hp_6"]=150, + ["hp_7"]=160, + ["hp_8"]=170, + ["hp_9"]=180, + ["hp_10"]=190, + ["hp_11"]=200, + ["hp_12"]=210, + ["hp_13"]=220, + ["hp_14"]=230, + ["hp_15"]=240, + ["atk_1"]=100, + ["atk_2"]=110, + ["atk_3"]=120, + ["atk_4"]=130, + ["atk_5"]=140, + ["atk_6"]=150, + ["atk_7"]=160, + ["atk_8"]=170, + ["atk_9"]=180, + ["atk_10"]=190, + ["atk_11"]=200, + ["atk_12"]=210, + ["atk_13"]=220, + ["atk_14"]=230, + ["atk_15"]=240 }, - [7]={ + [32001]={ + ["position"]=3, + ["qlt"]=2, + ["base_skill"]=10, + ["rouge_skill_1"]=200101, + ["rouge_skill_2"]=200102, + ["rouge_skill_3"]=200103, + ["hp_1"]=100, + ["hp_2"]=110, + ["hp_3"]=120, + ["hp_4"]=130, + ["hp_5"]=140, + ["hp_6"]=150, + ["hp_7"]=160, + ["hp_8"]=170, + ["hp_9"]=180, + ["hp_10"]=190, + ["hp_11"]=200, + ["hp_12"]=210, + ["hp_13"]=220, + ["hp_14"]=230, + ["hp_15"]=240, + ["atk_1"]=100, + ["atk_2"]=110, + ["atk_3"]=120, + ["atk_4"]=130, + ["atk_5"]=140, + ["atk_6"]=150, + ["atk_7"]=160, + ["atk_8"]=170, + ["atk_9"]=180, + ["atk_10"]=190, + ["atk_11"]=200, + ["atk_12"]=210, + ["atk_13"]=220, + ["atk_14"]=230, + ["atk_15"]=240 + }, + [42001]={ + ["position"]=4, + ["qlt"]=2, + ["base_skill"]=30, + ["rouge_skill_1"]=200301, + ["rouge_skill_2"]=200302, + ["rouge_skill_3"]=200303, + ["hp_1"]=100, + ["hp_2"]=110, + ["hp_3"]=120, + ["hp_4"]=130, + ["hp_5"]=140, + ["hp_6"]=150, + ["hp_7"]=160, + ["hp_8"]=170, + ["hp_9"]=180, + ["hp_10"]=190, + ["hp_11"]=200, + ["hp_12"]=210, + ["hp_13"]=220, + ["hp_14"]=230, + ["hp_15"]=240, + ["atk_1"]=100, + ["atk_2"]=110, + ["atk_3"]=120, + ["atk_4"]=130, + ["atk_5"]=140, + ["atk_6"]=150, + ["atk_7"]=160, + ["atk_8"]=170, + ["atk_9"]=180, + ["atk_10"]=190, + ["atk_11"]=200, + ["atk_12"]=210, + ["atk_13"]=220, + ["atk_14"]=230, + ["atk_15"]=240 + }, + [52001]={ + ["position"]=5, + ["qlt"]=2, + ["base_skill"]=40, + ["rouge_skill_1"]=200401, + ["rouge_skill_2"]=200402, + ["rouge_skill_3"]=200403, + ["hp_1"]=100, + ["hp_2"]=110, + ["hp_3"]=120, + ["hp_4"]=130, + ["hp_5"]=140, + ["hp_6"]=150, + ["hp_7"]=160, + ["hp_8"]=170, + ["hp_9"]=180, + ["hp_10"]=190, + ["hp_11"]=200, + ["hp_12"]=210, + ["hp_13"]=220, + ["hp_14"]=230, + ["hp_15"]=240, + ["atk_1"]=100, + ["atk_2"]=110, + ["atk_3"]=120, + ["atk_4"]=130, + ["atk_5"]=140, + ["atk_6"]=150, + ["atk_7"]=160, + ["atk_8"]=170, + ["atk_9"]=180, + ["atk_10"]=190, + ["atk_11"]=200, + ["atk_12"]=210, + ["atk_13"]=220, + ["atk_14"]=230, + ["atk_15"]=240 + }, + [23001]={ ["position"]=2, ["qlt"]=3, ["base_skill"]=70, @@ -265,7 +227,45 @@ local hero = { ["atk_14"]=345, ["atk_15"]=360 }, - [8]={ + [33001]={ + ["position"]=3, + ["qlt"]=3, + ["base_skill"]=60, + ["rouge_skill_1"]=200601, + ["rouge_skill_2"]=200602, + ["rouge_skill_3"]=200603, + ["hp_1"]=150, + ["hp_2"]=165, + ["hp_3"]=180, + ["hp_4"]=195, + ["hp_5"]=210, + ["hp_6"]=225, + ["hp_7"]=240, + ["hp_8"]=255, + ["hp_9"]=270, + ["hp_10"]=285, + ["hp_11"]=300, + ["hp_12"]=315, + ["hp_13"]=330, + ["hp_14"]=345, + ["hp_15"]=360, + ["atk_1"]=150, + ["atk_2"]=165, + ["atk_3"]=180, + ["atk_4"]=195, + ["atk_5"]=210, + ["atk_6"]=225, + ["atk_7"]=240, + ["atk_8"]=255, + ["atk_9"]=270, + ["atk_10"]=285, + ["atk_11"]=300, + ["atk_12"]=315, + ["atk_13"]=330, + ["atk_14"]=345, + ["atk_15"]=360 + }, + [43001]={ ["position"]=4, ["qlt"]=3, ["base_skill"]=80, diff --git a/lua/app/config/item.lua b/lua/app/config/item.lua index 7237d986..e39f7e3f 100644 --- a/lua/app/config/item.lua +++ b/lua/app/config/item.lua @@ -79,53 +79,53 @@ local item = { } } }, - [5001]={ + [32001]={ ["type"]=5, - ["parameter"]=10, + ["parameter"]=32001, ["qlt"]=2, - ["icon"]="5001" + ["icon"]="32001" }, - [5002]={ + [22001]={ ["type"]=5, - ["parameter"]=20, + ["parameter"]=22001, ["qlt"]=2, - ["icon"]="5002" + ["icon"]="22001" }, - [5003]={ + [42001]={ ["type"]=5, - ["parameter"]=30, + ["parameter"]=42001, ["qlt"]=2, - ["icon"]="5003" + ["icon"]="42001" }, - [5004]={ + [52001]={ ["type"]=5, - ["parameter"]=40, + ["parameter"]=52001, ["qlt"]=2, - ["icon"]="5004" + ["icon"]="52001" }, - [5005]={ + [12001]={ ["type"]=5, - ["parameter"]=50, + ["parameter"]=12001, ["qlt"]=2, - ["icon"]="5005" + ["icon"]="12001" }, - [5006]={ + [33001]={ ["type"]=5, - ["parameter"]=60, + ["parameter"]=33001, ["qlt"]=3, - ["icon"]="5006" + ["icon"]="33001" }, - [5007]={ + [23001]={ ["type"]=5, - ["parameter"]=70, + ["parameter"]=23001, ["qlt"]=3, - ["icon"]="5007" + ["icon"]="23001" }, - [5008]={ + [43001]={ ["type"]=5, - ["parameter"]=80, + ["parameter"]=43001, ["qlt"]=3, - ["icon"]="5008" + ["icon"]="43001" } } local config = { diff --git a/lua/app/config/player_initial.lua b/lua/app/config/player_initial.lua index d9db9ca5..20c92c4d 100644 --- a/lua/app/config/player_initial.lua +++ b/lua/app/config/player_initial.lua @@ -13,8 +13,8 @@ local player_initial = { ["reward"]={ ["type"]=1, ["type_for_nothing"]="Vw==", - ["id"]=5001, - ["id_for_nothing"]="UwhcAg==", + ["id"]=32001, + ["id_for_nothing"]="VQpcA2Q=", ["num"]=3, ["num_for_nothing"]="VQ==" } @@ -23,24 +23,14 @@ local player_initial = { ["reward"]={ ["type"]=1, ["type_for_nothing"]="Vw==", - ["id"]=5002, - ["id_for_nothing"]="UwhcAQ==", - ["num"]=3, - ["num_for_nothing"]="VQ==" - } - }, - [4]={ - ["reward"]={ - ["type"]=1, - ["type_for_nothing"]="Vw==", - ["id"]=5003, - ["id_for_nothing"]="UwhcAA==", + ["id"]=22001, + ["id_for_nothing"]="VApcA2Q=", ["num"]=3, ["num_for_nothing"]="VQ==" } } } local config = { -data=player_initial,count=4 +data=player_initial,count=3 } return config \ No newline at end of file diff --git a/lua/app/config/skill_hero.lua b/lua/app/config/skill_hero.lua index 1adfcb3c..505206f6 100644 --- a/lua/app/config/skill_hero.lua +++ b/lua/app/config/skill_hero.lua @@ -1,6 +1,6 @@ local skill_hero = { [10]={ - ["energy"]=3, + ["energy"]=10, ["position"]=3, ["method"]=2, ["skill_type"]=1, @@ -14,11 +14,10 @@ local skill_hero = { ["range"]=1 } }, - ["icon"]=10, - ["battle_icon"]=1 + ["icon"]=10 }, [20]={ - ["energy"]=3, + ["energy"]=10, ["position"]=2, ["method"]=2, ["skill_type"]=0, @@ -31,13 +30,12 @@ local skill_hero = { } }, ["obj"]=2, - ["icon"]=20, - ["battle_icon"]=2 + ["icon"]=20 }, [21]={ - ["energy"]=3, + ["energy"]=10, ["position"]=2, - ["method"]=1, + ["method"]=2, ["skill_type"]=2, ["skill_type_parameter"]=2, ["boardrange"]={ @@ -66,11 +64,10 @@ local skill_hero = { ["round"]=0 } }, - ["icon"]=20, - ["battle_icon"]=2 + ["icon"]=20 }, [30]={ - ["energy"]=3, + ["energy"]=10, ["position"]=4, ["method"]=2, ["skill_type"]=1, @@ -80,11 +77,10 @@ local skill_hero = { ["range"]=2 } }, - ["icon"]=30, - ["battle_icon"]=3 + ["icon"]=30 }, [40]={ - ["energy"]=3, + ["energy"]=10, ["position"]=5, ["method"]=2, ["skill_type"]=0, @@ -97,11 +93,10 @@ local skill_hero = { } }, ["obj"]=1, - ["icon"]=40, - ["battle_icon"]=4 + ["icon"]=40 }, [50]={ - ["energy"]=3, + ["energy"]=10, ["position"]=1, ["method"]=2, ["skill_type"]=1, @@ -115,11 +110,10 @@ local skill_hero = { ["range"]=2 } }, - ["icon"]=50, - ["battle_icon"]=5 + ["icon"]=50 }, [60]={ - ["energy"]=3, + ["energy"]=10, ["position"]=3, ["method"]=2, ["skill_type"]=0, @@ -132,11 +126,10 @@ local skill_hero = { } }, ["obj"]=1, - ["icon"]=60, - ["battle_icon"]=6 + ["icon"]=60 }, [70]={ - ["energy"]=3, + ["energy"]=10, ["position"]=2, ["method"]=2, ["skill_type"]=0, @@ -149,11 +142,10 @@ local skill_hero = { } }, ["obj"]=1, - ["icon"]=70, - ["battle_icon"]=7 + ["icon"]=70 }, [71]={ - ["energy"]=3, + ["energy"]=10, ["position"]=2, ["method"]=1, ["skill_type"]=2, @@ -185,11 +177,10 @@ local skill_hero = { } }, ["obj"]=1, - ["icon"]=70, - ["battle_icon"]=7 + ["icon"]=70 }, [72]={ - ["energy"]=3, + ["energy"]=10, ["position"]=2, ["method"]=1, ["skill_type"]=2, @@ -228,11 +219,10 @@ local skill_hero = { ["range"]=1 } }, - ["icon"]=70, - ["battle_icon"]=7 + ["icon"]=70 }, [80]={ - ["energy"]=3, + ["energy"]=10, ["position"]=4, ["method"]=2, ["skill_type"]=0, @@ -250,11 +240,10 @@ local skill_hero = { ["round"]=1 } }, - ["icon"]=80, - ["battle_icon"]=8 + ["icon"]=80 }, [81]={ - ["energy"]=3, + ["energy"]=10, ["position"]=4, ["method"]=2, ["skill_type"]=1, @@ -290,8 +279,7 @@ local skill_hero = { ["round"]=1 } }, - ["icon"]=80, - ["battle_icon"]=8 + ["icon"]=80 } } local config = { diff --git a/lua/app/config/strings/cn/hero.lua b/lua/app/config/strings/cn/hero.lua index 05043874..b4031dec 100644 --- a/lua/app/config/strings/cn/hero.lua +++ b/lua/app/config/strings/cn/hero.lua @@ -1,26 +1,26 @@ local hero = { - [1]={ + [12001]={ ["name"]="王八拳" }, - [2]={ + [22001]={ ["name"]="无影腿" }, - [3]={ + [32001]={ ["name"]="闪电鞭" }, - [4]={ + [42001]={ ["name"]="金钟罩" }, - [5]={ + [52001]={ ["name"]="大鹏展翅" }, - [6]={ + [23001]={ ["name"]="丹田吐纳" }, - [7]={ + [33001]={ ["name"]="疾风骤雨" }, - [8]={ + [43001]={ ["name"]="寒冰掌" } } diff --git a/lua/app/config/strings/cn/item.lua b/lua/app/config/strings/cn/item.lua index bc5e5752..5120f7ab 100644 --- a/lua/app/config/strings/cn/item.lua +++ b/lua/app/config/strings/cn/item.lua @@ -20,38 +20,32 @@ local item = { [6]={ ["name"]="史诗招式箱" }, - [5001]={ + [32001]={ ["name"]="王八拳招式碎片" }, - [5002]={ + [22001]={ ["name"]="无影腿招式碎片" }, - [5003]={ + [42001]={ ["name"]="闪电鞭招式碎片" }, - [5004]={ + [52001]={ ["name"]="金钟罩招式碎片" }, - [5005]={ + [12001]={ ["name"]="大鹏展翅招式碎片" }, - [5006]={ + [33001]={ ["name"]="丹田吐纳招式碎片" }, - [5007]={ + [23001]={ ["name"]="疾风骤雨招式碎片" }, - [5008]={ + [43001]={ ["name"]="寒冰掌招式碎片" - }, - [5009]={ - ["name"]="蓄力拳招式碎片" - }, - [5010]={ - ["name"]="烈火神拳招式碎片" } } local config = { -data=item,count=16 +data=item,count=14 } return config \ No newline at end of file diff --git a/lua/app/config/strings/de/hero.lua b/lua/app/config/strings/de/hero.lua index 936c545c..7465a593 100644 --- a/lua/app/config/strings/de/hero.lua +++ b/lua/app/config/strings/de/hero.lua @@ -1,26 +1,26 @@ local hero = { - [1]={ + [12001]={ }, - [2]={ + [22001]={ }, - [3]={ + [32001]={ }, - [4]={ + [42001]={ }, - [5]={ + [52001]={ }, - [6]={ + [23001]={ }, - [7]={ + [33001]={ }, - [8]={ + [43001]={ } } diff --git a/lua/app/config/strings/de/item.lua b/lua/app/config/strings/de/item.lua index e7008832..18e52a2b 100644 --- a/lua/app/config/strings/de/item.lua +++ b/lua/app/config/strings/de/item.lua @@ -20,38 +20,32 @@ local item = { [6]={ }, - [5001]={ + [32001]={ }, - [5002]={ + [22001]={ }, - [5003]={ + [42001]={ }, - [5004]={ + [52001]={ }, - [5005]={ + [12001]={ }, - [5006]={ + [33001]={ }, - [5007]={ + [23001]={ }, - [5008]={ - - }, - [5009]={ - - }, - [5010]={ + [43001]={ } } local config = { -data=item,count=16 +data=item,count=14 } return config \ No newline at end of file diff --git a/lua/app/config/strings/en/hero.lua b/lua/app/config/strings/en/hero.lua index 936c545c..7465a593 100644 --- a/lua/app/config/strings/en/hero.lua +++ b/lua/app/config/strings/en/hero.lua @@ -1,26 +1,26 @@ local hero = { - [1]={ + [12001]={ }, - [2]={ + [22001]={ }, - [3]={ + [32001]={ }, - [4]={ + [42001]={ }, - [5]={ + [52001]={ }, - [6]={ + [23001]={ }, - [7]={ + [33001]={ }, - [8]={ + [43001]={ } } diff --git a/lua/app/config/strings/en/item.lua b/lua/app/config/strings/en/item.lua index 5059245d..481a9403 100644 --- a/lua/app/config/strings/en/item.lua +++ b/lua/app/config/strings/en/item.lua @@ -20,38 +20,32 @@ local item = { [6]={ }, - [5001]={ + [32001]={ }, - [5002]={ + [22001]={ }, - [5003]={ + [42001]={ }, - [5004]={ + [52001]={ }, - [5005]={ + [12001]={ }, - [5006]={ + [33001]={ }, - [5007]={ + [23001]={ }, - [5008]={ - - }, - [5009]={ - - }, - [5010]={ + [43001]={ } } local config = { -data=item,count=16 +data=item,count=14 } return config \ No newline at end of file diff --git a/lua/app/config/strings/fr/hero.lua b/lua/app/config/strings/fr/hero.lua index 936c545c..7465a593 100644 --- a/lua/app/config/strings/fr/hero.lua +++ b/lua/app/config/strings/fr/hero.lua @@ -1,26 +1,26 @@ local hero = { - [1]={ + [12001]={ }, - [2]={ + [22001]={ }, - [3]={ + [32001]={ }, - [4]={ + [42001]={ }, - [5]={ + [52001]={ }, - [6]={ + [23001]={ }, - [7]={ + [33001]={ }, - [8]={ + [43001]={ } } diff --git a/lua/app/config/strings/fr/item.lua b/lua/app/config/strings/fr/item.lua index 434bbc35..c9a55b66 100644 --- a/lua/app/config/strings/fr/item.lua +++ b/lua/app/config/strings/fr/item.lua @@ -20,38 +20,32 @@ local item = { [6]={ }, - [5001]={ + [32001]={ }, - [5002]={ + [22001]={ }, - [5003]={ + [42001]={ }, - [5004]={ + [52001]={ }, - [5005]={ + [12001]={ }, - [5006]={ + [33001]={ }, - [5007]={ + [23001]={ }, - [5008]={ - - }, - [5009]={ - - }, - [5010]={ + [43001]={ } } local config = { -data=item,count=16 +data=item,count=14 } return config \ No newline at end of file diff --git a/lua/app/config/strings/id/hero.lua b/lua/app/config/strings/id/hero.lua index 936c545c..7465a593 100644 --- a/lua/app/config/strings/id/hero.lua +++ b/lua/app/config/strings/id/hero.lua @@ -1,26 +1,26 @@ local hero = { - [1]={ + [12001]={ }, - [2]={ + [22001]={ }, - [3]={ + [32001]={ }, - [4]={ + [42001]={ }, - [5]={ + [52001]={ }, - [6]={ + [23001]={ }, - [7]={ + [33001]={ }, - [8]={ + [43001]={ } } diff --git a/lua/app/config/strings/id/item.lua b/lua/app/config/strings/id/item.lua index e01d4998..6ed03a59 100644 --- a/lua/app/config/strings/id/item.lua +++ b/lua/app/config/strings/id/item.lua @@ -20,38 +20,32 @@ local item = { [6]={ }, - [5001]={ + [32001]={ }, - [5002]={ + [22001]={ }, - [5003]={ + [42001]={ }, - [5004]={ + [52001]={ }, - [5005]={ + [12001]={ }, - [5006]={ + [33001]={ }, - [5007]={ + [23001]={ }, - [5008]={ - - }, - [5009]={ - - }, - [5010]={ + [43001]={ } } local config = { -data=item,count=16 +data=item,count=14 } return config \ No newline at end of file diff --git a/lua/app/config/strings/ja/hero.lua b/lua/app/config/strings/ja/hero.lua index 936c545c..7465a593 100644 --- a/lua/app/config/strings/ja/hero.lua +++ b/lua/app/config/strings/ja/hero.lua @@ -1,26 +1,26 @@ local hero = { - [1]={ + [12001]={ }, - [2]={ + [22001]={ }, - [3]={ + [32001]={ }, - [4]={ + [42001]={ }, - [5]={ + [52001]={ }, - [6]={ + [23001]={ }, - [7]={ + [33001]={ }, - [8]={ + [43001]={ } } diff --git a/lua/app/config/strings/ja/item.lua b/lua/app/config/strings/ja/item.lua index 922357ca..8756474e 100644 --- a/lua/app/config/strings/ja/item.lua +++ b/lua/app/config/strings/ja/item.lua @@ -20,38 +20,32 @@ local item = { [6]={ }, - [5001]={ + [32001]={ }, - [5002]={ + [22001]={ }, - [5003]={ + [42001]={ }, - [5004]={ + [52001]={ }, - [5005]={ + [12001]={ }, - [5006]={ + [33001]={ }, - [5007]={ + [23001]={ }, - [5008]={ - - }, - [5009]={ - - }, - [5010]={ + [43001]={ } } local config = { -data=item,count=16 +data=item,count=14 } return config \ No newline at end of file diff --git a/lua/app/config/strings/ko/hero.lua b/lua/app/config/strings/ko/hero.lua index 936c545c..7465a593 100644 --- a/lua/app/config/strings/ko/hero.lua +++ b/lua/app/config/strings/ko/hero.lua @@ -1,26 +1,26 @@ local hero = { - [1]={ + [12001]={ }, - [2]={ + [22001]={ }, - [3]={ + [32001]={ }, - [4]={ + [42001]={ }, - [5]={ + [52001]={ }, - [6]={ + [23001]={ }, - [7]={ + [33001]={ }, - [8]={ + [43001]={ } } diff --git a/lua/app/config/strings/ko/item.lua b/lua/app/config/strings/ko/item.lua index 0bb35521..8b05342c 100644 --- a/lua/app/config/strings/ko/item.lua +++ b/lua/app/config/strings/ko/item.lua @@ -20,38 +20,32 @@ local item = { [6]={ }, - [5001]={ + [32001]={ }, - [5002]={ + [22001]={ }, - [5003]={ + [42001]={ }, - [5004]={ + [52001]={ }, - [5005]={ + [12001]={ }, - [5006]={ + [33001]={ }, - [5007]={ + [23001]={ }, - [5008]={ - - }, - [5009]={ - - }, - [5010]={ + [43001]={ } } local config = { -data=item,count=16 +data=item,count=14 } return config \ No newline at end of file diff --git a/lua/app/config/strings/pt/hero.lua b/lua/app/config/strings/pt/hero.lua index 936c545c..7465a593 100644 --- a/lua/app/config/strings/pt/hero.lua +++ b/lua/app/config/strings/pt/hero.lua @@ -1,26 +1,26 @@ local hero = { - [1]={ + [12001]={ }, - [2]={ + [22001]={ }, - [3]={ + [32001]={ }, - [4]={ + [42001]={ }, - [5]={ + [52001]={ }, - [6]={ + [23001]={ }, - [7]={ + [33001]={ }, - [8]={ + [43001]={ } } diff --git a/lua/app/config/strings/pt/item.lua b/lua/app/config/strings/pt/item.lua index 889ea95c..c704ec00 100644 --- a/lua/app/config/strings/pt/item.lua +++ b/lua/app/config/strings/pt/item.lua @@ -19,38 +19,32 @@ local item = { [6]={ }, - [5001]={ + [32001]={ }, - [5002]={ + [22001]={ }, - [5003]={ + [42001]={ }, - [5004]={ + [52001]={ }, - [5005]={ + [12001]={ }, - [5006]={ + [33001]={ }, - [5007]={ + [23001]={ }, - [5008]={ - - }, - [5009]={ - - }, - [5010]={ + [43001]={ } } local config = { -data=item,count=16 +data=item,count=14 } return config \ No newline at end of file diff --git a/lua/app/config/strings/ru/hero.lua b/lua/app/config/strings/ru/hero.lua index 936c545c..7465a593 100644 --- a/lua/app/config/strings/ru/hero.lua +++ b/lua/app/config/strings/ru/hero.lua @@ -1,26 +1,26 @@ local hero = { - [1]={ + [12001]={ }, - [2]={ + [22001]={ }, - [3]={ + [32001]={ }, - [4]={ + [42001]={ }, - [5]={ + [52001]={ }, - [6]={ + [23001]={ }, - [7]={ + [33001]={ }, - [8]={ + [43001]={ } } diff --git a/lua/app/config/strings/ru/item.lua b/lua/app/config/strings/ru/item.lua index a97be73a..1b799a09 100644 --- a/lua/app/config/strings/ru/item.lua +++ b/lua/app/config/strings/ru/item.lua @@ -17,38 +17,32 @@ local item = { [6]={ }, - [5001]={ + [32001]={ }, - [5002]={ + [22001]={ }, - [5003]={ + [42001]={ }, - [5004]={ + [52001]={ }, - [5005]={ + [12001]={ }, - [5006]={ + [33001]={ }, - [5007]={ + [23001]={ }, - [5008]={ - - }, - [5009]={ - - }, - [5010]={ + [43001]={ } } local config = { -data=item,count=16 +data=item,count=14 } return config \ No newline at end of file diff --git a/lua/app/config/strings/th/hero.lua b/lua/app/config/strings/th/hero.lua index 936c545c..7465a593 100644 --- a/lua/app/config/strings/th/hero.lua +++ b/lua/app/config/strings/th/hero.lua @@ -1,26 +1,26 @@ local hero = { - [1]={ + [12001]={ }, - [2]={ + [22001]={ }, - [3]={ + [32001]={ }, - [4]={ + [42001]={ }, - [5]={ + [52001]={ }, - [6]={ + [23001]={ }, - [7]={ + [33001]={ }, - [8]={ + [43001]={ } } diff --git a/lua/app/config/strings/th/item.lua b/lua/app/config/strings/th/item.lua index a97be73a..1b799a09 100644 --- a/lua/app/config/strings/th/item.lua +++ b/lua/app/config/strings/th/item.lua @@ -17,38 +17,32 @@ local item = { [6]={ }, - [5001]={ + [32001]={ }, - [5002]={ + [22001]={ }, - [5003]={ + [42001]={ }, - [5004]={ + [52001]={ }, - [5005]={ + [12001]={ }, - [5006]={ + [33001]={ }, - [5007]={ + [23001]={ }, - [5008]={ - - }, - [5009]={ - - }, - [5010]={ + [43001]={ } } local config = { -data=item,count=16 +data=item,count=14 } return config \ No newline at end of file diff --git a/lua/app/config/strings/vi/hero.lua b/lua/app/config/strings/vi/hero.lua index 936c545c..7465a593 100644 --- a/lua/app/config/strings/vi/hero.lua +++ b/lua/app/config/strings/vi/hero.lua @@ -1,26 +1,26 @@ local hero = { - [1]={ + [12001]={ }, - [2]={ + [22001]={ }, - [3]={ + [32001]={ }, - [4]={ + [42001]={ }, - [5]={ + [52001]={ }, - [6]={ + [23001]={ }, - [7]={ + [33001]={ }, - [8]={ + [43001]={ } } diff --git a/lua/app/config/strings/vi/item.lua b/lua/app/config/strings/vi/item.lua index f86536ff..3c815eb3 100644 --- a/lua/app/config/strings/vi/item.lua +++ b/lua/app/config/strings/vi/item.lua @@ -20,38 +20,32 @@ local item = { [6]={ }, - [5001]={ + [32001]={ }, - [5002]={ + [22001]={ }, - [5003]={ + [42001]={ }, - [5004]={ + [52001]={ }, - [5005]={ + [12001]={ }, - [5006]={ + [33001]={ }, - [5007]={ + [23001]={ }, - [5008]={ - - }, - [5009]={ - - }, - [5010]={ + [43001]={ } } local config = { -data=item,count=16 +data=item,count=14 } return config \ No newline at end of file diff --git a/lua/app/config/strings/zh/hero.lua b/lua/app/config/strings/zh/hero.lua index 936c545c..7465a593 100644 --- a/lua/app/config/strings/zh/hero.lua +++ b/lua/app/config/strings/zh/hero.lua @@ -1,26 +1,26 @@ local hero = { - [1]={ + [12001]={ }, - [2]={ + [22001]={ }, - [3]={ + [32001]={ }, - [4]={ + [42001]={ }, - [5]={ + [52001]={ }, - [6]={ + [23001]={ }, - [7]={ + [33001]={ }, - [8]={ + [43001]={ } } diff --git a/lua/app/config/strings/zh/item.lua b/lua/app/config/strings/zh/item.lua index 85d57415..69b06456 100644 --- a/lua/app/config/strings/zh/item.lua +++ b/lua/app/config/strings/zh/item.lua @@ -20,38 +20,32 @@ local item = { [6]={ }, - [5001]={ + [32001]={ }, - [5002]={ + [22001]={ }, - [5003]={ + [42001]={ }, - [5004]={ + [52001]={ }, - [5005]={ + [12001]={ }, - [5006]={ + [33001]={ }, - [5007]={ + [23001]={ }, - [5008]={ - - }, - [5009]={ - - }, - [5010]={ + [43001]={ } } local config = { -data=item,count=16 +data=item,count=14 } return config \ No newline at end of file diff --git a/lua/app/module/battle/battle_const.lua b/lua/app/module/battle/battle_const.lua index d2f92e8a..e71707f5 100644 --- a/lua/app/module/battle/battle_const.lua +++ b/lua/app/module/battle/battle_const.lua @@ -11,11 +11,21 @@ BattleConst.ONE_STEP_TIME = 0.2 BattleConst.ELEMENT_TYPE_COUNT = 5 BattleConst.ELEMENT_WIGHT = 100 BattleConst.MAX_ELEMENT_WIGHT = 500 +BattleConst.SIDE_ATK = 1 +BattleConst.SIDE_DEF = 2 BattleConst.BATTLE_TYPE = { STAGE = 1, } +BattleConst.UNIT_STATE = { + INIT = 0, + IDLE = 1, -- 待机 + ATTACK = 2, -- 攻击 + HURT = 3, -- 受伤 + DEAD = 4, -- 死亡 +} + ---- 格子类型 BattleConst.GRID_TYPE = { EMPTY = 0, diff --git a/lua/app/module/battle/component.meta b/lua/app/module/battle/component.meta new file mode 100644 index 00000000..c3d51863 --- /dev/null +++ b/lua/app/module/battle/component.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1d2b66c71824629498617879343ea43a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/lua/app/module/battle/component/battle_unit_comp.lua b/lua/app/module/battle/component/battle_unit_comp.lua new file mode 100644 index 00000000..66d9b36f --- /dev/null +++ b/lua/app/module/battle/component/battle_unit_comp.lua @@ -0,0 +1,36 @@ +local BattleConst = require "app/module/battle/battle_const" + +local BattleUnitComp = class("BattleUnitComp", LuaComponent) + +local UNIT_STATE = BattleConst.UNIT_STATE + +function BattleUnitComp:ctor() +end + +function BattleUnitComp:init() + self:_initBase() +end + +function BattleUnitComp:_initBase() + self.isClear = false + self.isDead = false +end + +function BattleUnitComp:tick(dt) + if self.isClear then + return + end + if self.isDead then + self:updateDead(dt) + return + end + if self.currState == UNIT_STATE.IDLE then + self:updateIdle(dt) + return + end + if self.currState == UNIT_STATE.ATTACK then + self:updateAttack(dt) + end +end + +return BattleUnitComp \ No newline at end of file diff --git a/lua/app/userdata/bag/equip_data.lua.meta b/lua/app/module/battle/component/battle_unit_comp.lua.meta similarity index 86% rename from lua/app/userdata/bag/equip_data.lua.meta rename to lua/app/module/battle/component/battle_unit_comp.lua.meta index 34b4cb7e..df443351 100644 --- a/lua/app/userdata/bag/equip_data.lua.meta +++ b/lua/app/module/battle/component/battle_unit_comp.lua.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: e202fd02d78948749809ede46846c300 +guid: 612a5421ff64f07409a9786ba07c6e59 ScriptedImporter: internalIDToNameTable: [] externalObjects: {} diff --git a/lua/app/module/item/item_const.lua b/lua/app/module/item/item_const.lua index 41d1a86d..2de80f80 100644 --- a/lua/app/module/item/item_const.lua +++ b/lua/app/module/item/item_const.lua @@ -3,4 +3,12 @@ local ItemConst = {} ItemConst.ITEM_ID_GOLD = 1 ItemConst.ITEM_ID_GEM = 2 +ItemConst.ITEM_TYPE = { + RES = 1, + ITEM = 2, + RANDOM_FRAGMENT = 3, + BOX = 4, + HERO_FRAGMENT = 5 +} + return ItemConst \ No newline at end of file diff --git a/lua/app/server/data/server_bag_data.lua b/lua/app/server/data/server_bag_data.lua index 4bd9d05d..861bd580 100644 --- a/lua/app/server/data/server_bag_data.lua +++ b/lua/app/server/data/server_bag_data.lua @@ -4,64 +4,27 @@ 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() + self.ItemData:init(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 -function ServerBagData:getItemData() - return self.ItemData:getAllItems() -end - -function ServerBagData:tryAddItem(id, num) - return self.ItemData:tryAddItem(id, num) -end - -function ServerBagData:tryAddItemReward(item) - local id = GFunc.getRewardId(item) - local num = GFunc.getRewardNum(item) - return self.ItemData:tryAddItem(id, num) -end - -function ServerBagData:tryAddItemCost(cost) - local id = GFunc.getRewardId(cost) - local num = GFunc.getRewardNum(cost) - return self.ItemData:tryAddItem(id, -num) -end - -function ServerBagData:addItemReward(item, getType) - local id = GFunc.getRewardId(item) - local num = GFunc.getRewardNum(item) - self:addItem(id, num, getType) -end - -function ServerBagData:addItemCost(cost) - local id = GFunc.getRewardId(cost) - local num = GFunc.getRewardNum(cost) - self:addItem(id, -num) -end - -function ServerBagData:addItem(id, num, getType) - if id == GConst.ItemConst.ITEM_ID_VIT then - local maxCount = self.ItemData:getMaxVit() - local currentCount = self.ItemData:getItemNumById(GConst.ItemConst.ITEM_ID_VIT) - local isMax = currentCount >= maxCount - self.ItemData:addItem(id, num, getType) - local currentCount = currentCount + num - local isMax1 = currentCount >= maxCount - if not isMax1 then - if isMax then - self.ItemData:resetVitRecoverTime() - else - self.ItemData:recoveryItems() - end - end - else - self.ItemData:addItem(id, num, getType) - end -end - return ServerBagData \ No newline at end of file diff --git a/lua/app/server/data/server_base_data.lua b/lua/app/server/data/server_base_data.lua index 3dda8880..d5fdcc51 100644 --- a/lua/app/server/data/server_base_data.lua +++ b/lua/app/server/data/server_base_data.lua @@ -19,17 +19,28 @@ end function ServerBaseData:init() end +function ServerBaseData:clear() +end + function ServerBaseData:loadLocalData() - local data = LocalData:getString("ServerData_" .. self.__cname, "") + local data = LocalData:getString(self:_getLocalSaveKey(), "") local dataObj = nil if data and data ~= "" then dataObj = json.decode(data) end - self:init(dataObj) + return dataObj end -function ServerBaseData:loadNewPlayerData() - self:init() +function ServerBaseData:saveLocalData() + local str = json.encode(self.data) or "" + LocalData:setString(self:_getLocalSaveKey(), str) +end + +function ServerBaseData:_getLocalSaveKey() + if self._localSaveKey == nil then + self._localSaveKey = "ServerData_" .. self.__cname + end + return self._localSaveKey end function ServerBaseData:getCloneData() @@ -50,8 +61,19 @@ function ServerBaseData:getCloneData() return _copy(self.data) end -function ServerBaseData:clone() +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_hero_data.lua b/lua/app/server/data/server_hero_data.lua index 2b53bc97..ab866e3c 100644 --- a/lua/app/server/data/server_hero_data.lua +++ b/lua/app/server/data/server_hero_data.lua @@ -1,3 +1,25 @@ local ServerHeroData = class("ServerHeroData", ServerBaseData) +function ServerHeroData:init(data) + Logger.logHighlight("ServerHeroData") + Logger.printTable(data) + self.data.heroes = data and data.heroes or {} +end + +function ServerHeroData:getHeroByCfgId(id) + local idStr = tostring(id) + return self.data.heroes[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 + return ServerHeroData \ No newline at end of file diff --git a/lua/app/server/data/server_item_data.lua b/lua/app/server/data/server_item_data.lua index 6ad902b6..4137ad21 100644 --- a/lua/app/server/data/server_item_data.lua +++ b/lua/app/server/data/server_item_data.lua @@ -1,74 +1,47 @@ local ServerItemData = class("ServerItemData", ServerBaseData) function ServerItemData:init(data) - data = data or {} self.data.items = {} - for idStr, item in pairs(data) do - local id = tonumber(idStr) - if id == GConst.ItemConst.ITEM_ID_VIT then - local ServerGameData = require "app/server/data/server_game_data" - ServerGameData.PlayerData:setVit(item.count) + 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.items[id] = {cfg_id = id, count = item.count} + self.data.recoveries = data.recoveries + else + self.data.recoveries = {} end - self.data.recoveries = data.recoveries or {} self:checkRecoveries() end function ServerItemData:tryAddItem(id, num) - if not self.data.items[id] then + local idStr = tostring(id) + if not self.data.items[idStr] then if num < 0 then return false end else - if self.data.items[id].count + num < 0 then + if self.data.items[idStr].count + num < 0 then return false end end return true end -function ServerItemData:addItem(id, num, getType) - local hadNum = 0 - if self.data.items[id] then - hadNum = self.data.items[id].count - else - self.data.items[id] = {} - self.data.items[id].cfg_id = id - self.data.items[id].count = 0 - end - local finalNum = (hadNum or 0) + num - if finalNum < 0 then - finalNum = 0 - end - local ServerGameData = require "app/server/data/server_game_data" - if id == GConst.ItemConst.ITEM_ID_VIT then - ServerGameData.PlayerData:setVit(finalNum) - end - self.data.items[id].count = finalNum - if num < 0 then - if id == GConst.ItemConst.ITEM_ID_GEM then - ServerGameData.TaskData:addTaskProgress(GConst.TASK_TYPE.TASK_GEM_COST, -num) - end - end - - getType = getType or "" - if num > 0 and id == GConst.ItemConst.ITEM_ID_GOLD and - getType ~= GConst.ServerDataConst.DATA_OP_BEHAVIOR.EQUIP_RESOLVE and - getType ~= GConst.ServerDataConst.DATA_OP_BEHAVIOR.EQUIP_REBACK then - ServerGameData.TaskData:addTaskProgress(GConst.TASK_TYPE.TASK_GOLD_GET, num) - end -end - function ServerItemData:getAllItems() return self.data.items end function ServerItemData:getItemNumById(id) - if not self.data.items[id] then + local idStr = tostring(id) + if not self.data.items[idStr] then return 0 end - local num = self.data.items[id].count or 0 + local num = self.data.items[idStr].count or 0 return num end @@ -106,7 +79,7 @@ function ServerItemData:recoveryItem(data, maxCount) return end if data.cfg_id == GConst.ItemConst.ITEM_ID_VIT then - local ServerGameData = require "app/server/data/server_game_data" + local ServerGameData = require "app/server/server_game_data" local currentCount = ServerGameData.PlayerData:getVit() if currentCount >= maxCount then -- 已经达到上限 return @@ -142,7 +115,7 @@ function ServerItemData:recoveryItem(data, maxCount) if currentCount + addCount > maxCount then addCount = maxCount - currentCount end - self:addItem(data.cfg_id, addCount) + self:_addItem(data.cfg_id, addCount) ServerDataManager:saveData() end @@ -180,4 +153,69 @@ function ServerItemData:getMaxVit() 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 + if num < 0 then + if id == GConst.ItemConst.ITEM_ID_GEM then + ServerGameData.TaskData:addTaskProgress(GConst.TASK_TYPE.TASK_GEM_COST, -num) + end + end + + getType = getType or "" + if num > 0 and id == GConst.ItemConst.ITEM_ID_GOLD and + getType ~= GConst.ServerDataConst.DATA_OP_BEHAVIOR.EQUIP_RESOLVE and + getType ~= GConst.ServerDataConst.DATA_OP_BEHAVIOR.EQUIP_REBACK then + ServerGameData.TaskData:addTaskProgress(GConst.TASK_TYPE.TASK_GOLD_GET, num) + end +end + return ServerItemData \ No newline at end of file diff --git a/lua/app/server/server_game_data.lua b/lua/app/server/server_game_data.lua index e64c1bcf..904afdfd 100644 --- a/lua/app/server/server_game_data.lua +++ b/lua/app/server/server_game_data.lua @@ -6,6 +6,9 @@ local TempRewards = {} function ServerGameData:init() if self.isInit then + for k, v in pairs(self.dataMap) do + v:_clear() + end return end self.isInit = true @@ -23,20 +26,55 @@ function ServerGameData:initData() local isNewPlayer = LocalData:getIsNewPlayer() if isNewPlayer then for k, v in pairs(self.dataMap) do - v:loadNewPlayerData() + v:init() end local playerInitialCfg = ConfigManager:getConfig("player_initial") if playerInitialCfg then for k, v in pairs(playerInitialCfg) do if v.reward then - self:addReward(v.reward) + 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 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) + end + break + end + end + end + end end end end + self:saveData() LocalData:setNotNewPlayer() + LocalData:save() else for k, v in pairs(self.dataMap) do - v:loadLocalData() + v:init(v:loadLocalData()) end end end @@ -57,6 +95,12 @@ function ServerGameData:getData() return data end +function ServerGameData:saveData() + for k, v in pairs(self.dataMap) do + v:saveLocalData() + end +end + -- 根据配置表添加奖励 function ServerGameData:addRewards(cfgRewards, getType) local rewards = {} @@ -87,7 +131,7 @@ function ServerGameData:addRewards(cfgRewards, getType) local rewardType = GFunc.getRewardType(reward) newReward.type = rewardType if rewardType == GConst.ServerDataConst.REWARD_TYPE.ITEM then - self.BagData:addItemReward(reward, getType) + self.BagData.ItemData:addItemReward(reward, getType) local rewardId = GFunc.getRewardId(reward) local rewardNum = GFunc.getRewardNum(reward) if rewardId == GConst.ItemConst.ITEM_ID_EXP then @@ -104,42 +148,6 @@ function ServerGameData:addRewards(cfgRewards, getType) return rewards end -function ServerGameData:addRewards(cfgReward, getType) - if cfgReward == nil then - return - end - local count = #TempRewards - for i = 1, count do - table.remove(TempRewards) - end - local rewardType = GFunc.getRewardType(cfgReward) - if rewardType == GConst.ServerDataConst.REWARD_TYPE.ITEM then - local rewardId = GFunc.getRewardId(cfgReward) - local rewardNum = GFunc.getRewardNum(cfgReward) - local cfg = ConfigManager:getItemConfig()[rewardId] - if cfg.box_drop then - self:openRewardBox(TempRewards, cfg.box_drop, rewardNum, rewardId) - else - table.insert(TempRewards, cfgReward) - end - else - table.insert(TempRewards, cfgReward) - end - count = #TempRewards - for i = 1, count do - local reward = table.remove(TempRewards) - local rewardType = GFunc.getRewardType(reward) - if rewardType == GConst.ServerDataConst.REWARD_TYPE.ITEM then - self.BagData: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 - end - end -end - function ServerGameData:getNewReward() local rewards = { type = 0, diff --git a/lua/app/userdata/bag/bag_data.lua b/lua/app/userdata/bag/bag_data.lua index 85ce87cb..29a93e5e 100644 --- a/lua/app/userdata/bag/bag_data.lua +++ b/lua/app/userdata/bag/bag_data.lua @@ -11,17 +11,19 @@ BagData.RECOVERY_TYPE = { function BagData:ctor() self.ItemData = require("app/userdata/bag/item_data"):create() - self.EquipData = require("app/userdata/bag/equip_data"):create() end function BagData:init(data) - self.ItemData:init(data.items) - self.EquipData:init(data.equips) + if data then + self.ItemData:init(data.ItemData) + else + self.ItemData:init() + end self.recoveries = data.recoveries or {} -- ts在此处做转换:对每日回复来说,ts指下次回复时间;对时间回复来说,ts仍指上次回复时间 for i,v in pairs(self.recoveries) do - self.recoveries[i].ts = self.recoveries[i].ts // 1000 + self.recoveries[i].ts = self.recoveries[i].ts // 1000 -- local cfg = RecoveryCfg[v.id] -- if cfg.type == self.RECOVERY_TYPE.DAILY then -- self.recoveries[i].ts = self.recoveries[i].ts + SECONDS_PRE_DAY @@ -32,7 +34,6 @@ end function BagData:clear() self.ItemData:clear() - self.EquipData:clear() self.recoveries = {} DataManager:unregisterDataCd("BagData") end @@ -65,7 +66,6 @@ function BagData:getTimelyItemRecoveryTime(itemId) -- data.ts = Time:getServerTime() -- return 1000 -- 需要持续重置,保持时间更新 -- end - -- -- 计算时间 -- local intervalTime = cfg.time -- if itemId == GConst.ItemConst.ITEM_ID_MINING_PICK then @@ -90,7 +90,6 @@ function BagData:getDailyItemRecoveryMaxTime(itemId) if data then return data.ts - Time:getServerTime() end - return -1 end @@ -123,10 +122,10 @@ function BagData:getTimelyItemRecoveryMaxTime(itemId) -- return curTime end -- 按时间回复的在此回复 -function BagData:recoveryItem(data, maxBigNum) +function BagData:recoveryItem(data, maxNum) -- 计算已经达到上限 - local curBigNum = self.ItemData:getItemBigNumById(data.id) - if BigNumOpt.bigNumCompare(curBigNum, maxBigNum) >= 0 then + local curBigNum = self.ItemData:getItemNumById(data.id) + if curBigNum >= maxNum then return end -- 计算恢复间隔 diff --git a/lua/app/userdata/bag/equip_data.lua b/lua/app/userdata/bag/equip_data.lua deleted file mode 100644 index d2158c63..00000000 --- a/lua/app/userdata/bag/equip_data.lua +++ /dev/null @@ -1,229 +0,0 @@ -local EquipEntity = require "app/userdata/bag/equip_entity" -local EquipData = class("EquipData", BaseData) - -function EquipData:setDirty() - self.data.isDirty = not self.data.isDirty -end - -function EquipData:setAttrDirty() - self.isAttrDirty = true -end - -function EquipData:ctor() - self.equips = {} - self.data.isDirty = false - self.isAttrDirty = true -end - -function EquipData:init(data) - if not data then - return - end - - self.equips = {} - for _, equip in pairs(data) do - self:_add(equip) - end - - self.allWearAttr = {} - self.allOwnAttr = {} -end - -function EquipData:_add(equip) - self.equips[equip.id] = EquipEntity:create(equip) -end - -function EquipData:clear() - self.equips = {} -end - -function EquipData:addEquipCountById(id, count, equipGetType) - if EDITOR_MODE then - if not equipGetType then - local params = { - content = "EquipData addEquipCountById has no equipGetType", - boxType = GConst.MESSAGE_BOX_TYPE.MB_OK, - okText = I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_OK), - } - GFunc.showMessageBox(params) - Logger.log("EquipData addEquipCountById has no equipGetType") - end - end - - local data = {id = id, count = count} - local equipEntity = self:getEquipByCfgId(id) - equipEntity:addCount(count) - BIReport:postEquipGet(id, equipGetType) -end - --- 是否有装备可以升级 -function EquipData:isEquipsCanUp(part) - for k,v in pairs(self.equips) do - if v:getPart() == part and v:lvUpCostEnough() then - return true - end - end - return false -end - --- 获取所有可升级装备信息 -function EquipData:getAllEquipsCanUpByPart(part) - local reqEquips = {} - local rspEquips = {} - for k,v in pairs(self.equips) do - if v:getPart() == part then - local canUpLv, targetUpLv, targetNum = v:getCanUpLv() - if canUpLv then - -- table.insert(equipInfos, {id = k, targetUpLv = targetUpLv, costNum = costNum}) - table.insert(reqEquips, k) - table.insert(rspEquips, {id = k, level = targetUpLv, count = targetNum}) - end - end - end - return reqEquips, rspEquips -end - --- 升级所有装备 --- function EquipData:onAllEquipsUp(equipUpInfos) --- for i,v in ipairs(equipUpInfos) do --- local entity = self:getEquipByCfgId(v.id) --- entity:setLv(v.targetUpLv) --- entity:addCount(-v.costNum) --- end --- self:setDirty() --- end - --- 获取所有装备数据 -function EquipData:getAllEquips() - return self.equips -end - -function EquipData:updateAllAttr() - self.allWearAttr = {} - self.allOwnAttr = {} - local wearEquips = DataManager.FightInfoData:getWearEquips() - for part, equipEntity in pairs(wearEquips) do - if equipEntity then - local allAttr = equipEntity:getAllWearAttr() - for type, value in pairs(allAttr) do - if not self.allWearAttr[type] then - self.allWearAttr[type] = BigNumOpt.getEmptyBigNum() - end - self.allWearAttr[type] = BigNumOpt.bigNumAdd(self.allWearAttr[type], value) - end - end - end - - for k,v in pairs(self.equips) do - if v:getLv() > 0 then - local allAttr = v:getAllOwnAttr() - for type, value in pairs(allAttr) do - if not self.allOwnAttr[type] then - self.allOwnAttr[type] = BigNumOpt.getEmptyBigNum() - end - self.allOwnAttr[type] = BigNumOpt.bigNumAdd(self.allOwnAttr[type], value) - end - end - end -end - --- 获取所有已穿戴装备属性 -function EquipData:getAllWearAttr() - if self.isAttrDirty then - self.isAttrDirty = false - self:updateAllAttr() - end - return self.allWearAttr -end - --- 获取所有已拥有装备属性 -function EquipData:getAllOwnAttr() - if self.isAttrDirty then - self.isAttrDirty = false - self:updateAllAttr() - end - return self.allOwnAttr -end - -function EquipData:getEquipByCfgId(id) - if not self.equips[id] then - self.equips[id] = EquipEntity:create({id = id, count = 0, level = 0}) - end - return self.equips[id] -end - -function EquipData:getBestEquipByPart(part) - local equip - for k,v in pairs(self.equips) do - if v:getLv() > 0 and v:getPart() == part then - if not equip then - equip = v - else - local wearAttr1 = equip:getAllWearAttr() - local wearAttr2 = v:getAllWearAttr() - for k, vv in pairs(wearAttr1) do - if BigNumOpt.bigNumCompare(wearAttr2[k], vv) > 0 then - equip = v - break - end - end - end - end - end - local equips = {} - if equip then - for k,v in pairs(self.equips) do - if v:getLv() > 0 and v:getPart() == part then - local wearAttr1 = equip:getAllWearAttr() - local wearAttr2 = v:getAllWearAttr() - for k, vv in pairs(wearAttr1) do - if BigNumOpt.bigNumCompare(wearAttr2[k], vv) == 0 then - table.insert(equips, v) - break - end - end - end - end - end - return equips -end - --- function EquipData:onEquipLvUp(id) --- if not self.equips[id] then --- return --- end --- self.equips[id]:onEquipLvUp() --- self:setDirty() --- end - --- 读取配置 -function EquipData:getEquipCfgArrByPart(part) - local equipCfg = ConfigManager:getConfig("equip") - local tab = {} - for k,v in pairs(equipCfg) do - if part and v.part == part then - v.id = k - table.insert(tab, v) - end - end - table.sort(tab, function (a, b) - if a.qlt == b.qlt then - return a.id < b.id - end - return a.qlt < b.qlt - end) - return tab -end - -function EquipData:getEquipCfgArrByPartAndQlt(part, qlt) - local equipCfg = ConfigManager:getConfig("equip") - local tab = {} - for k,v in pairs(equipCfg) do - if part and v.part == part and v.qlt == qlt then - table.insert(tab, k) - end - end - return tab -end - -return EquipData \ No newline at end of file diff --git a/lua/app/userdata/bag/equip_entity.lua b/lua/app/userdata/bag/equip_entity.lua deleted file mode 100644 index ab312d34..00000000 --- a/lua/app/userdata/bag/equip_entity.lua +++ /dev/null @@ -1,347 +0,0 @@ -local EquipEntity = class("EquipEntity", BaseData) - -function EquipEntity:ctor(equip) - self.config = nil - self:init(equip) -end - -function EquipEntity:init(equip) - self.id = equip.id - self.data.count = equip.count or 0 - self.data.lv = equip.level or 0 - - self.allOwnAttr = {} - self.allWearAttr = {} - self:_loadConfig(equip.id) -end - -function EquipEntity:getConfig(id) - local EquipCfg = ConfigManager:getConfig("equip") - local config = EquipCfg[id] - return config -end - -function EquipEntity:_loadConfig(id) - local config = self:getConfig(id) - if EDITOR_MODE then - if not config then - Logger.logError("装备初始化异常 配置表ID不存在 -- id:%s", self.id) - end - end - self.config = config - self:updateAttr() -end - -function EquipEntity:setLv(lv) - lv = lv or 1 - self.data.lv = lv - self:updateAttr() - DataManager.BagData.EquipData:setAttrDirty() -end - -function EquipEntity:getLv() - return self.data.lv -end - -function EquipEntity:getCount() - return self.data.count -end - -function EquipEntity:addCount(count) - if self.data.lv == 0 then - self.data.lv = 1 - self.data.isNew = true - DataManager.BagData.EquipData:setAttrDirty() - end - self.data.count = self.data.count + count -end - -function EquipEntity:getIsNew() - return self.data.isNew or false -end - -function EquipEntity:setIsNew(isNew) - self.data.isNew = isNew -end - -function EquipEntity:setCount(count) - self.data.count = count -end - --- id -function EquipEntity:getId() - return self.id -end - -function EquipEntity:setId(id) - self.id = id - self:_loadConfig(self.id) -end - -function EquipEntity:getNextId() - return self.config.next_id -end - -function EquipEntity:isLock() - if self.data.lv > 0 or self.data.count > 0 then - return false - end - return true -end - -function EquipEntity:getSkillIds() - if self.data.lv == 0 then - return self.config.skill_id or {}, {1, 1, 1} - end - local lvs = {} - local re = (self.data.lv - 1)%3 - local baseLv = (self.data.lv - 1) // 3 - for i = 1, 3 do - if re >= i then - lvs[i] = baseLv + 2 - else - lvs[i] = baseLv + 1 - end - end - return self.config.skill_id or {}, lvs -end - -function EquipEntity:getAttackIds() - return self.config.attack_id or {} -end - -function EquipEntity:getAttackExtraIds() - return self.config.attack_extra_id or {} -end - --- 品质 -function EquipEntity:getQuality() - return self.config.qlt -end - -function EquipEntity:getQltDesc() - return I18N:getGlobalText("QLT_DESC_" .. self.config.qlt) -end - --- 装备图标 -function EquipEntity:getFrameRes() - return GConst.ATLAS_PATH.ICON_EQUIP, "frame_" .. self.config.qlt -end - --- 装备图标 -function EquipEntity:getIconRes() - return GConst.ATLAS_PATH.ICON_EQUIP, tostring(self.config.icon) -end - --- 部位 -function EquipEntity:getPart() - return self.config.part -end - -function EquipEntity:getWeaponPart() - return self.config.weapon_part -end - -function EquipEntity:getPartBgRes() - return GConst.ATLAS_PATH.ICON_EQUIP, "type_" .. self.config.qlt -end - -function EquipEntity:getPartRes() - return GConst.ATLAS_PATH.ICON_EQUIP, "e" .. self.config.part -end - -function EquipEntity:isMaxLv() - if self.data.lv >= self:getMaxLv() then - return true - end - return false -end - -function EquipEntity:getName() - return I18N:getText("equip", self.id, "name") -end - -function EquipEntity:getDesc() - return I18N:getText("equip", self.id, "desc") -end - --- 拥有属性 -function EquipEntity:getBaseOwnAttr() - return self.config.base_own -end - --- function EquipEntity:getBaseOwnAttrType() --- return self.config.base_own.type --- end - --- function EquipEntity:getBaseOwnAttrTypeId() --- return GConst.ATTR_TYPE[self.config.base_own.type] --- end - --- function EquipEntity:getBaseOwnAttrBignum() --- return self.config.base_own.bignum --- end - --- function EquipEntity:getBaseOwnAttrStr() --- return self.config.base_own.bignum.value .. BigNumOpt.getBigNumUnit(self.config.base_own.bignum.unit) --- end - -function EquipEntity:getGrowOwnAttr() - return self.config.grow_own -end - --- function EquipEntity:getGrowOwnAttrType() --- return self.config.grow_own.type --- end - --- function EquipEntity:getGrowOwnAttrTypeId() --- return GConst.ATTR_TYPE[self.config.grow_own.type] --- end - --- function EquipEntity:getGrowOwnAttrBigNum() --- return self.config.grow_own.bignum --- end - --- 穿戴属性 -function EquipEntity:getBaseWearAttr() - return self.config.base_wear -end - --- function EquipEntity:getBaseWearAttrType() --- return self.config.base_wear.type --- end - --- function EquipEntity:getBaseWearAttrTypeId() --- return GConst.ATTR_TYPE[self.config.base_wear.type] --- end - --- function EquipEntity:getBaseWearAttrBignum() --- return self.config.base_wear.bignum --- end - --- function EquipEntity:getBaseWearAttrStr() --- return self.config.base_wear.bignum.value .. BigNumOpt.getBigNumUnit(self.config.base_wear.bignum.unit) --- end - -function EquipEntity:getGrowWearAttr() - return self.config.grow_wear -end - --- function EquipEntity:getGrowWearAttrType() --- return self.config.grow_wear.type --- end - -function EquipEntity:getUpgradeCost() - return self.config.upgrade_cost or {} -end - --- function EquipEntity:getGrowWearAttrTypeId() --- return GConst.ATTR_TYPE[self.config.grow_wear.type] --- end - --- function EquipEntity:getWeaponModel() --- return self.config.equip_model --- end - --- function EquipEntity:getWeaponAniName() --- return self.config.act_type --- end - -function EquipEntity:updateAttr() - self.allOwnAttr = {} - self.allWearAttr = {} - local baseOwnAttr = self:getBaseOwnAttr() - local growOwnAttr = self:getGrowOwnAttr() - local baseWearAttr = self:getBaseWearAttr() - local growWearAttr = self:getGrowWearAttr() - - for i,v in ipairs(baseOwnAttr) do - self.allOwnAttr[GConst.ATTR_TYPE[v.type]] = v.bignum - end - for i,v in ipairs(baseWearAttr) do - self.allWearAttr[GConst.ATTR_TYPE[v.type]] = v.bignum - end - -- self.allOwnAttr[baseOwnAttr.type] = baseOwnAttr.bignum - -- self.allWearAttr[baseWearAttr.type] = baseWearAttr.bignum - - if self.data.lv > 1 then - for i,v in ipairs(growOwnAttr) do - if not self.allOwnAttr[GConst.ATTR_TYPE[v.type]] then - self.allOwnAttr[GConst.ATTR_TYPE[v.type]] = BigNumOpt.getEmptyBigNum() - end - local growAttr = BigNumOpt.bigNumMultNum(v.bignum, self.data.lv - 1) - self.allOwnAttr[GConst.ATTR_TYPE[v.type]] = BigNumOpt.bigNumAdd(self.allOwnAttr[GConst.ATTR_TYPE[v.type]], growAttr) - end - for i,v in ipairs(growWearAttr) do - if not self.allWearAttr[GConst.ATTR_TYPE[v.type]] then - self.allWearAttr[GConst.ATTR_TYPE[v.type]] = BigNumOpt.getEmptyBigNum() - end - local growAttr = BigNumOpt.bigNumMultNum(v.bignum, self.data.lv - 1) - self.allWearAttr[GConst.ATTR_TYPE[v.type]] = BigNumOpt.bigNumAdd(self.allWearAttr[GConst.ATTR_TYPE[v.type]], growAttr) - end - end -end - -function EquipEntity:getAllOwnAttr() - return self.allOwnAttr -end - -function EquipEntity:getAllWearAttr() - return self.allWearAttr -end - -function EquipEntity:getNeedNum(lv) - lv = lv or self.data.lv - local costCount = 0 - local upgradeCost = self:getUpgradeCost() - if lv >= #upgradeCost then - costCount = upgradeCost[#upgradeCost] - elseif lv == 0 then - costCount = upgradeCost[1] - else - costCount = upgradeCost[lv] - end - return costCount -end - -function EquipEntity:lvUpCostEnough() - local costCount = self:getNeedNum() - if self.data.count >= costCount then - return true - end - return false -end - --- function EquipEntity:onEquipLvUp() --- if self:lvUpCostEnough() then --- self.data.count = self.data.count - self:getNeedNum() --- self:setLv(self.data.lv + 1) --- end --- end - --- function EquipEntity:getPerEquipLvUpRsp() --- local tab = {} --- tab.id = self.id --- tab.count = self.data.count - self:getNeedNum() --- tab.level = self.data.lv + 1 --- return tab --- end - -function EquipEntity:getCanUpLv() - local hadNum = self.data.count - local costNum = 0 - local lv = self.data.lv - while true do - local needNum = self:getNeedNum(lv) - if hadNum >= needNum then - lv = lv + 1 - hadNum = hadNum - needNum - costNum = costNum + needNum - else - break - end - end - return costNum > 0, lv, hadNum -end - -return EquipEntity \ No newline at end of file diff --git a/lua/app/userdata/bag/item_data.lua b/lua/app/userdata/bag/item_data.lua index 0a3d5007..0ca621d2 100644 --- a/lua/app/userdata/bag/item_data.lua +++ b/lua/app/userdata/bag/item_data.lua @@ -19,24 +19,23 @@ function ItemData:init(data) self.items = {} data = data or {} for _, info in pairs(data) do - if info.id == GConst.ItemConst.ITEM_ID_GEM then - local parmas = {} - parmas.gem = BigNumOpt.bigNum2Num(info.count) - CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(parmas) - elseif info.id == GConst.ItemConst.ITEM_ID_GOLD then - local parmas = {} - parmas.gold_value = info.count.value - parmas.gold_unit = info.count.unit - CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(parmas) - end - self:_add(info.id, info.count) + -- if info.id == GConst.ItemConst.ITEM_ID_GEM then + -- local parmas = {} + -- parmas.gem = BigNumOpt.bigNum2Num(info.count) + -- CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(parmas) + -- elseif info.id == GConst.ItemConst.ITEM_ID_GOLD then + -- local parmas = {} + -- parmas.gold_value = info.count.value + -- parmas.gold_unit = info.count.unit + -- CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(parmas) + -- end + self:_add(info.cfg_id, info.count) end - self.data.dirty = false end -function ItemData:_add(id, bigNum) - self.items[id] = ItemEntity:create(id, bigNum) +function ItemData:_add(id, num) + self.items[id] = ItemEntity:create(id, num) end function ItemData:clear() @@ -48,7 +47,7 @@ function ItemData:getItemById(id) if self.items[id] then return self.items[id] end - local item = ItemEntity:create(id, BigNumOpt.num2BigNum(0)) + local item = ItemEntity:create(id, 0) self.items[id] = item return self.items[id] end @@ -61,32 +60,22 @@ end function ItemData:getItemBigNumById(id) local num if self.items[id] then - num = self.items[id]:getBigNum() + num = self.items[id]:getNum() else - num = BigNumOpt.num2BigNum(0) - end - return num -end - -function ItemData:getItemBigNumStrById(id) - local num = 0 - if self.items[id] then - num = self.items[id]:getBigNumStr() + num = 0 end return num end function ItemData:addItemReward(item, itemGetType) - CACHE_ITEM.id = item.id - CACHE_ITEM.count.unit = item.count.unit - CACHE_ITEM.count.value = item.count.value + CACHE_ITEM.cfg_id = GFunc.getRewardId(item) + CACHE_ITEM.count = GFunc.getRewardNum(item) self:addItem(CACHE_ITEM, itemGetType) end function ItemData:addItemCost(cost, itemGetType) - CACHE_ITEM.id = cost.id - CACHE_ITEM.count.unit = cost.count.unit - CACHE_ITEM.count.value = -cost.count.value + CACHE_ITEM.cfg_id = GFunc.getRewardId(cost) + CACHE_ITEM.count = -GFunc.getRewardNum(cost) self:addItem(CACHE_ITEM, itemGetType) end @@ -94,8 +83,8 @@ function ItemData:addItemCosts(costs, itemGetType) if not costs then return end - for _, unitCost in ipairs(costs) do - self:addItemCost(unitCost, itemGetType) + for _, cost in ipairs(costs) do + self:addItemCost(cost, itemGetType) end end @@ -116,72 +105,49 @@ function ItemData:addItem(data, itemGetType) end end - local itemCfg = ConfigManager:getConfig("item")[data.id] + self:_addItemNumById(data.cfg_id, data.count) - self:_addItemNumById(data.id, data.count) - - if data.id == GConst.ItemConst.ITEM_ID_GEM or data.id == GConst.ItemConst.ITEM_ID_GOLD then + if data.cfg_id == GConst.ItemConst.ITEM_ID_GEM or data.cfg_id == GConst.ItemConst.ITEM_ID_GOLD then if data.count.value < 0 then - if data.id == GConst.ItemConst.ITEM_ID_GOLD and itemGetType == BIReport.ITEM_GET_TYPE.TRAIN_UP then + if data.cfg_id == GConst.ItemConst.ITEM_ID_GOLD and itemGetType == BIReport.ITEM_GET_TYPE.TRAIN_UP then else - BIReport:postGemUse(data.count, itemGetType, data.id) - if data.id == GConst.ItemConst.ITEM_ID_GEM then - CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserAdd("gem", BigNumOpt.bigNum2Num(data.count)) - elseif data.id == GConst.ItemConst.ITEM_ID_GOLD then - local goldBigNum = DataManager.BagData.ItemData:getItemBigNumById(GConst.ItemConst.ITEM_ID_GOLD) + BIReport:postGemUse(data.count, itemGetType, data.cfg_id) + if data.cfg_id == GConst.ItemConst.ITEM_ID_GEM then + CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserAdd("gem", data.count) + elseif data.cfg_id == GConst.ItemConst.ITEM_ID_GOLD then + local goldNum = DataManager.BagData.ItemData:getItemNumById(GConst.ItemConst.ITEM_ID_GOLD) local parmas = {} - parmas.gold_value = goldBigNum.value - parmas.gold_unit = goldBigNum.unit + parmas.gold = goldNum CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(parmas) end end else - if data.id == GConst.ItemConst.ITEM_ID_GOLD and itemGetType == BIReport.ITEM_GET_TYPE.CHAPTER_DROP then + if data.cfg_id == GConst.ItemConst.ITEM_ID_GOLD and itemGetType == BIReport.ITEM_GET_TYPE.CHAPTER_DROP then else - BIReport:postGemGet(data.count, itemGetType, data.id) - if data.id == GConst.ItemConst.ITEM_ID_GEM then - CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserAdd("gem", BigNumOpt.bigNum2Num(data.count)) - elseif data.id == GConst.ItemConst.ITEM_ID_GOLD then - local goldBigNum = DataManager.BagData.ItemData:getItemBigNumById(GConst.ItemConst.ITEM_ID_GOLD) + BIReport:postGemGet(data.count, itemGetType, data.cfg_id) + if data.cfg_id == GConst.ItemConst.ITEM_ID_GEM then + CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserAdd("gem", data.count) + elseif data.cfg_id == GConst.ItemConst.ITEM_ID_GOLD then + local goldNum = DataManager.BagData.ItemData:getItemNumById(GConst.ItemConst.ITEM_ID_GOLD) local parmas = {} - parmas.gold_value = goldBigNum.value - parmas.gold_unit = goldBigNum.unit + parmas.gold = goldNum CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(parmas) end end end else if data.count.value < 0 then - BIReport:postItemUse(data.count, data.id, itemGetType) + BIReport:postItemUse(data.count, data.cfg_id, itemGetType) else - BIReport:postItemGet(data.count, data.id, itemGetType) - end - end - - if data.id == GConst.ItemConst.ITEM_ID_MINING_PICK then - local num = BigNumOpt.bigNum2Num(data.count) - if num < 0 then - num = -num - ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_HOE_USE, {num = num}) - end - elseif data.id == GConst.ItemConst.ITEM_ID_DRILL then - local num = BigNumOpt.bigNum2Num(data.count) - if num < 0 then - num = -num - ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_BORING_CROWN_USE, {num = num}) - end - elseif data.id == GConst.ItemConst.ITEM_ID_EXPLOSIVE then - local num = BigNumOpt.bigNum2Num(data.count) - if num < 0 then - num = -num - ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_BOOM_USE, {num = num}) + BIReport:postItemGet(data.count, data.cfg_id, itemGetType) end end end function ItemData:addItemNumById(id, num, itemGetType) - local data = {id = id, count = num} - self:addItem(data, itemGetType) + CACHE_ITEM.cfg_id = id + CACHE_ITEM.count = num + self:addItem(CACHE_ITEM, itemGetType) end function ItemData:_addItemNumById(id, bigNum) @@ -195,7 +161,7 @@ function ItemData:_addItemNumById(id, bigNum) -- isFull = currentCount >= maxVit -- end if self.items[id] then - self.items[id]:addBigNum(bigNum) + self.items[id]:addNum(bigNum) else self:_add(id, bigNum) end diff --git a/lua/app/userdata/bag/item_entity.lua b/lua/app/userdata/bag/item_entity.lua index 75c8483f..49a60df7 100644 --- a/lua/app/userdata/bag/item_entity.lua +++ b/lua/app/userdata/bag/item_entity.lua @@ -34,12 +34,8 @@ function ItemEntity:getBigNum() return self.data.bigNum end -function ItemEntity:getBigNumStr() - return BigNumOpt.bigNum2Str(self.data.bigNum) -end - -- 加减道具数量 -function ItemEntity:addBigNum(bigNum) +function ItemEntity:addNum(num) self.data.bigNum = BigNumOpt.bigNumAdd(self.data.bigNum, bigNum) self:setDirty() end diff --git a/lua/app/userdata/battle/battle_data.lua b/lua/app/userdata/battle/battle_data.lua index a2cdcaf9..3644a3d8 100644 --- a/lua/app/userdata/battle/battle_data.lua +++ b/lua/app/userdata/battle/battle_data.lua @@ -1,3 +1,5 @@ +local BattleTeamEntity = require "app/userdata/battle/team/battle_team_entity" + local BattleData = class("BattleData", BaseData) local SKILL_HERO_CFG = ConfigManager:getConfig("skill_hero") @@ -7,6 +9,8 @@ local BATTLE_BOARD_SKILL_ENTITY = require "app/userdata/battle/skill/battle_bora function BattleData:init(board, skillIds) self:clear() + self.atkTeam = self:initTeam(BattleConst.SIDE_ATK) + self.defTeam = self:initTeam(BattleConst.SIDE_DEF) for i, info in ipairs(board) do local r = 1 @@ -237,4 +241,10 @@ function BattleData:addSkillEnergy(elementMap) end end +function BattleData:initTeam(side) + local team = BattleTeamEntity:create() + team:init(side) + return team +end + return BattleData \ No newline at end of file diff --git a/lua/app/userdata/battle/team.meta b/lua/app/userdata/battle/team.meta new file mode 100644 index 00000000..fab6b040 --- /dev/null +++ b/lua/app/userdata/battle/team.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 589f4571d71430d4e8c91ff45291e5c4 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/lua/app/userdata/battle/team/battle_team_entity.lua b/lua/app/userdata/battle/team/battle_team_entity.lua new file mode 100644 index 00000000..c2a76b62 --- /dev/null +++ b/lua/app/userdata/battle/team/battle_team_entity.lua @@ -0,0 +1,13 @@ +local BattleUnitEntity = require "app/userdata/battle/team/battle_unit_entity" + +local BattleTeamEntity = class("BattleTeamEntity", BaseData) + +function BattleTeamEntity:ctor() + self.members = {} +end + +function BattleTeamEntity:init(side) + self.side = side +end + +return BattleTeamEntity \ No newline at end of file diff --git a/lua/app/userdata/bag/equip_entity.lua.meta b/lua/app/userdata/battle/team/battle_team_entity.lua.meta similarity index 86% rename from lua/app/userdata/bag/equip_entity.lua.meta rename to lua/app/userdata/battle/team/battle_team_entity.lua.meta index 5605f328..59e15277 100644 --- a/lua/app/userdata/bag/equip_entity.lua.meta +++ b/lua/app/userdata/battle/team/battle_team_entity.lua.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 4b8e39bcbd3e7764cab23eeb28728ba0 +guid: 2338db9a689f0bb43a3a28739268ea4e ScriptedImporter: internalIDToNameTable: [] externalObjects: {} diff --git a/lua/app/userdata/battle/team/battle_unit_entity.lua b/lua/app/userdata/battle/team/battle_unit_entity.lua new file mode 100644 index 00000000..e7444ba9 --- /dev/null +++ b/lua/app/userdata/battle/team/battle_unit_entity.lua @@ -0,0 +1,9 @@ +local BattleUnitEntity = class("BattleUnitEntity", BaseData) + +function BattleUnitEntity:ctor() +end + +function BattleUnitEntity:init() +end + +return BattleUnitEntity \ No newline at end of file diff --git a/lua/app/userdata/battle/team/battle_unit_entity.lua.meta b/lua/app/userdata/battle/team/battle_unit_entity.lua.meta new file mode 100644 index 00000000..f3bf9c10 --- /dev/null +++ b/lua/app/userdata/battle/team/battle_unit_entity.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: d87717a1e70e9c443afefb650cd9105f +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/userdata/hero/hero_data.lua b/lua/app/userdata/hero/hero_data.lua index f584464b..a86c8be0 100644 --- a/lua/app/userdata/hero/hero_data.lua +++ b/lua/app/userdata/hero/hero_data.lua @@ -12,14 +12,20 @@ end function HeroData:init(data) self.heroes = {} - local heroCfg = ConfigManager:getConfig("hero") - for heroId, heroInfo in pairs(heroCfg) do - self:createHeroById(heroId, heroInfo) + if data then + for _, heroInfo in pairs(data.heroes) do + self:addHero(heroInfo.cfg_id, heroInfo.lv) + end end end -function HeroData:createHeroById(heroId, heroInfo) - self.heroes[heroId] = HeroEntity:create(heroId, heroInfo) +function HeroData:addHero(cfgId, lv) + if self.heroes[cfgId] then + return + end + Logger.logHighlight("cfgId=%s, lv=%s", cfgId, lv) + self.heroes[cfgId] = HeroEntity:create(cfgId, lv) + self.data.activeCount = self.data.activeCount + 1 end function HeroData:getAllHeroes() diff --git a/lua/app/userdata/hero/hero_entity.lua b/lua/app/userdata/hero/hero_entity.lua index 597886ee..84322578 100644 --- a/lua/app/userdata/hero/hero_entity.lua +++ b/lua/app/userdata/hero/hero_entity.lua @@ -1,11 +1,11 @@ local HeroEntity = class("HeroEntity", BaseData) -function HeroEntity:ctor(cfgId, config) +function HeroEntity:ctor(cfgId, lv) self.id = cfgId - self.config = config self.cfgId = cfgId - self.data.lv = 0 + self.data.lv = lv self.attrDirty = false + self.config = ConfigManager:getConfig("hero")[self.cfgId] self.baseAttrOriginal = {} self.allAttr = {}