This commit is contained in:
xiekaidong 2023-04-10 21:13:34 +08:00
commit 918f55e814
53 changed files with 838 additions and 1421 deletions

View File

@ -115,57 +115,7 @@ BIReport.RUNE_OPT_TYPE = {
} }
BIReport.ITEM_GET_TYPE = { BIReport.ITEM_GET_TYPE = {
RUNE_LV_UP = "RuneLvUp", -- 符文升级 NEW_PLAYER_INITIAL = "NewPlayerInitial", -- 新玩家创号自带
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", -- 抽卡获取
} }
BIReport.ADS_CLICK_TYPE = { BIReport.ADS_CLICK_TYPE = {
@ -326,8 +276,7 @@ function BIReport:report(name, args)
args.gold_value = goldBigBNum.value args.gold_value = goldBigBNum.value
args.gold_unit = goldBigBNum.unit args.gold_unit = goldBigBNum.unit
local gemBigNum = DataManager.BagData.ItemData:getItemBigNumById(GConst.ItemConst.ITEM_ID_GEM) args.gem = DataManager.BagData.ItemData:getItemById(GConst.ItemConst.ITEM_ID_GEM)
args.gem = BigNumOpt.bigNum2Num(gemBigNum)
end end
end end
args.current_version = CS.BF.BFMain.Instance.GameLaunchMgr:GetCurrentVersion() args.current_version = CS.BF.BFMain.Instance.GameLaunchMgr:GetCurrentVersion()

View File

@ -8,6 +8,7 @@ function DataManager:init()
self:initManager("PlayerData", "app/userdata/player/player_data") self:initManager("PlayerData", "app/userdata/player/player_data")
self:initManager("ChapterData", "app/userdata/chapter/chapter_data") self:initManager("ChapterData", "app/userdata/chapter/chapter_data")
self:initManager("HeroData", "app/userdata/hero/hero_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") self:initManager("BattleData", "app/userdata/battle/battle_data")
end end
@ -48,7 +49,6 @@ function DataManager:checkDataBind()
for name, baseData in pairs(self._cacheManager) do for name, baseData in pairs(self._cacheManager) do
if name == "BagData" then if name == "BagData" then
changeBindFunc(baseData.ItemData, self[name].ItemData) changeBindFunc(baseData.ItemData, self[name].ItemData)
changeBindFunc(baseData.EquipData, self[name].EquipData)
else else
changeBindFunc(baseData, self[name]) changeBindFunc(baseData, self[name])
end end
@ -67,6 +67,7 @@ function DataManager:clear()
self.BattleData:clear() self.BattleData:clear()
self.ChapterData:clear() self.ChapterData:clear()
self.HeroData:clear() self.HeroData:clear()
self.BagData:clear()
ModuleManager.TaskManager:clear() ModuleManager.TaskManager:clear()
end end
@ -76,9 +77,14 @@ function DataManager:initWithServerData(data)
Time:setServerTimeZone(0) Time:setServerTimeZone(0)
self.initWithServer = true self.initWithServer = true
if EDITOR_MODE then
Logger.logHighlight("initWithServerData")
Logger.printTable(data)
end
self.PlayerData:init(data.PlayerData) self.PlayerData:init(data.PlayerData)
self.ChapterData:init(data.ChapterData) self.ChapterData:init(data.ChapterData)
self.HeroData:init(data.HeroData) self.HeroData:init(data.HeroData)
self.BagData:init(data)
self:scheduleGlobal() self:scheduleGlobal()
self:checkDataBind() self:checkDataBind()

View File

@ -1,157 +1,5 @@
local hero = { local hero = {
[1]={ [12001]={
["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]={
["position"]=1, ["position"]=1,
["qlt"]=2, ["qlt"]=2,
["base_skill"]=50, ["base_skill"]=50,
@ -189,45 +37,159 @@ local hero = {
["atk_14"]=230, ["atk_14"]=230,
["atk_15"]=240 ["atk_15"]=240
}, },
[6]={ [22001]={
["position"]=3, ["position"]=2,
["qlt"]=3, ["qlt"]=2,
["base_skill"]=60, ["base_skill"]=20,
["rouge_skill_1"]=200601, ["rouge_skill_1"]=200201,
["rouge_skill_2"]=200602, ["rouge_skill_2"]=200202,
["rouge_skill_3"]=200603, ["rouge_skill_3"]=200203,
["hp_1"]=150, ["hp_1"]=100,
["hp_2"]=165, ["hp_2"]=110,
["hp_3"]=180, ["hp_3"]=120,
["hp_4"]=195, ["hp_4"]=130,
["hp_5"]=210, ["hp_5"]=140,
["hp_6"]=225, ["hp_6"]=150,
["hp_7"]=240, ["hp_7"]=160,
["hp_8"]=255, ["hp_8"]=170,
["hp_9"]=270, ["hp_9"]=180,
["hp_10"]=285, ["hp_10"]=190,
["hp_11"]=300, ["hp_11"]=200,
["hp_12"]=315, ["hp_12"]=210,
["hp_13"]=330, ["hp_13"]=220,
["hp_14"]=345, ["hp_14"]=230,
["hp_15"]=360, ["hp_15"]=240,
["atk_1"]=150, ["atk_1"]=100,
["atk_2"]=165, ["atk_2"]=110,
["atk_3"]=180, ["atk_3"]=120,
["atk_4"]=195, ["atk_4"]=130,
["atk_5"]=210, ["atk_5"]=140,
["atk_6"]=225, ["atk_6"]=150,
["atk_7"]=240, ["atk_7"]=160,
["atk_8"]=255, ["atk_8"]=170,
["atk_9"]=270, ["atk_9"]=180,
["atk_10"]=285, ["atk_10"]=190,
["atk_11"]=300, ["atk_11"]=200,
["atk_12"]=315, ["atk_12"]=210,
["atk_13"]=330, ["atk_13"]=220,
["atk_14"]=345, ["atk_14"]=230,
["atk_15"]=360 ["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, ["position"]=2,
["qlt"]=3, ["qlt"]=3,
["base_skill"]=70, ["base_skill"]=70,
@ -265,7 +227,45 @@ local hero = {
["atk_14"]=345, ["atk_14"]=345,
["atk_15"]=360 ["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, ["position"]=4,
["qlt"]=3, ["qlt"]=3,
["base_skill"]=80, ["base_skill"]=80,

View File

@ -79,53 +79,53 @@ local item = {
} }
} }
}, },
[5001]={ [32001]={
["type"]=5, ["type"]=5,
["parameter"]=10, ["parameter"]=32001,
["qlt"]=2, ["qlt"]=2,
["icon"]="5001" ["icon"]="32001"
}, },
[5002]={ [22001]={
["type"]=5, ["type"]=5,
["parameter"]=20, ["parameter"]=22001,
["qlt"]=2, ["qlt"]=2,
["icon"]="5002" ["icon"]="22001"
}, },
[5003]={ [42001]={
["type"]=5, ["type"]=5,
["parameter"]=30, ["parameter"]=42001,
["qlt"]=2, ["qlt"]=2,
["icon"]="5003" ["icon"]="42001"
}, },
[5004]={ [52001]={
["type"]=5, ["type"]=5,
["parameter"]=40, ["parameter"]=52001,
["qlt"]=2, ["qlt"]=2,
["icon"]="5004" ["icon"]="52001"
}, },
[5005]={ [12001]={
["type"]=5, ["type"]=5,
["parameter"]=50, ["parameter"]=12001,
["qlt"]=2, ["qlt"]=2,
["icon"]="5005" ["icon"]="12001"
}, },
[5006]={ [33001]={
["type"]=5, ["type"]=5,
["parameter"]=60, ["parameter"]=33001,
["qlt"]=3, ["qlt"]=3,
["icon"]="5006" ["icon"]="33001"
}, },
[5007]={ [23001]={
["type"]=5, ["type"]=5,
["parameter"]=70, ["parameter"]=23001,
["qlt"]=3, ["qlt"]=3,
["icon"]="5007" ["icon"]="23001"
}, },
[5008]={ [43001]={
["type"]=5, ["type"]=5,
["parameter"]=80, ["parameter"]=43001,
["qlt"]=3, ["qlt"]=3,
["icon"]="5008" ["icon"]="43001"
} }
} }
local config = { local config = {

View File

@ -13,8 +13,8 @@ local player_initial = {
["reward"]={ ["reward"]={
["type"]=1, ["type"]=1,
["type_for_nothing"]="Vw==", ["type_for_nothing"]="Vw==",
["id"]=5001, ["id"]=32001,
["id_for_nothing"]="UwhcAg==", ["id_for_nothing"]="VQpcA2Q=",
["num"]=3, ["num"]=3,
["num_for_nothing"]="VQ==" ["num_for_nothing"]="VQ=="
} }
@ -23,24 +23,14 @@ local player_initial = {
["reward"]={ ["reward"]={
["type"]=1, ["type"]=1,
["type_for_nothing"]="Vw==", ["type_for_nothing"]="Vw==",
["id"]=5002, ["id"]=22001,
["id_for_nothing"]="UwhcAQ==", ["id_for_nothing"]="VApcA2Q=",
["num"]=3,
["num_for_nothing"]="VQ=="
}
},
[4]={
["reward"]={
["type"]=1,
["type_for_nothing"]="Vw==",
["id"]=5003,
["id_for_nothing"]="UwhcAA==",
["num"]=3, ["num"]=3,
["num_for_nothing"]="VQ==" ["num_for_nothing"]="VQ=="
} }
} }
} }
local config = { local config = {
data=player_initial,count=4 data=player_initial,count=3
} }
return config return config

View File

@ -1,6 +1,6 @@
local skill_hero = { local skill_hero = {
[10]={ [10]={
["energy"]=3, ["energy"]=10,
["position"]=3, ["position"]=3,
["method"]=2, ["method"]=2,
["skill_type"]=1, ["skill_type"]=1,
@ -14,11 +14,10 @@ local skill_hero = {
["range"]=1 ["range"]=1
} }
}, },
["icon"]=10, ["icon"]=10
["battle_icon"]=1
}, },
[20]={ [20]={
["energy"]=3, ["energy"]=10,
["position"]=2, ["position"]=2,
["method"]=2, ["method"]=2,
["skill_type"]=0, ["skill_type"]=0,
@ -31,13 +30,12 @@ local skill_hero = {
} }
}, },
["obj"]=2, ["obj"]=2,
["icon"]=20, ["icon"]=20
["battle_icon"]=2
}, },
[21]={ [21]={
["energy"]=3, ["energy"]=10,
["position"]=2, ["position"]=2,
["method"]=1, ["method"]=2,
["skill_type"]=2, ["skill_type"]=2,
["skill_type_parameter"]=2, ["skill_type_parameter"]=2,
["boardrange"]={ ["boardrange"]={
@ -66,11 +64,10 @@ local skill_hero = {
["round"]=0 ["round"]=0
} }
}, },
["icon"]=20, ["icon"]=20
["battle_icon"]=2
}, },
[30]={ [30]={
["energy"]=3, ["energy"]=10,
["position"]=4, ["position"]=4,
["method"]=2, ["method"]=2,
["skill_type"]=1, ["skill_type"]=1,
@ -80,11 +77,10 @@ local skill_hero = {
["range"]=2 ["range"]=2
} }
}, },
["icon"]=30, ["icon"]=30
["battle_icon"]=3
}, },
[40]={ [40]={
["energy"]=3, ["energy"]=10,
["position"]=5, ["position"]=5,
["method"]=2, ["method"]=2,
["skill_type"]=0, ["skill_type"]=0,
@ -97,11 +93,10 @@ local skill_hero = {
} }
}, },
["obj"]=1, ["obj"]=1,
["icon"]=40, ["icon"]=40
["battle_icon"]=4
}, },
[50]={ [50]={
["energy"]=3, ["energy"]=10,
["position"]=1, ["position"]=1,
["method"]=2, ["method"]=2,
["skill_type"]=1, ["skill_type"]=1,
@ -115,11 +110,10 @@ local skill_hero = {
["range"]=2 ["range"]=2
} }
}, },
["icon"]=50, ["icon"]=50
["battle_icon"]=5
}, },
[60]={ [60]={
["energy"]=3, ["energy"]=10,
["position"]=3, ["position"]=3,
["method"]=2, ["method"]=2,
["skill_type"]=0, ["skill_type"]=0,
@ -132,11 +126,10 @@ local skill_hero = {
} }
}, },
["obj"]=1, ["obj"]=1,
["icon"]=60, ["icon"]=60
["battle_icon"]=6
}, },
[70]={ [70]={
["energy"]=3, ["energy"]=10,
["position"]=2, ["position"]=2,
["method"]=2, ["method"]=2,
["skill_type"]=0, ["skill_type"]=0,
@ -149,11 +142,10 @@ local skill_hero = {
} }
}, },
["obj"]=1, ["obj"]=1,
["icon"]=70, ["icon"]=70
["battle_icon"]=7
}, },
[71]={ [71]={
["energy"]=3, ["energy"]=10,
["position"]=2, ["position"]=2,
["method"]=1, ["method"]=1,
["skill_type"]=2, ["skill_type"]=2,
@ -185,11 +177,10 @@ local skill_hero = {
} }
}, },
["obj"]=1, ["obj"]=1,
["icon"]=70, ["icon"]=70
["battle_icon"]=7
}, },
[72]={ [72]={
["energy"]=3, ["energy"]=10,
["position"]=2, ["position"]=2,
["method"]=1, ["method"]=1,
["skill_type"]=2, ["skill_type"]=2,
@ -228,11 +219,10 @@ local skill_hero = {
["range"]=1 ["range"]=1
} }
}, },
["icon"]=70, ["icon"]=70
["battle_icon"]=7
}, },
[80]={ [80]={
["energy"]=3, ["energy"]=10,
["position"]=4, ["position"]=4,
["method"]=2, ["method"]=2,
["skill_type"]=0, ["skill_type"]=0,
@ -250,11 +240,10 @@ local skill_hero = {
["round"]=1 ["round"]=1
} }
}, },
["icon"]=80, ["icon"]=80
["battle_icon"]=8
}, },
[81]={ [81]={
["energy"]=3, ["energy"]=10,
["position"]=4, ["position"]=4,
["method"]=2, ["method"]=2,
["skill_type"]=1, ["skill_type"]=1,
@ -290,8 +279,7 @@ local skill_hero = {
["round"]=1 ["round"]=1
} }
}, },
["icon"]=80, ["icon"]=80
["battle_icon"]=8
} }
} }
local config = { local config = {

View File

@ -1,26 +1,26 @@
local hero = { local hero = {
[1]={ [12001]={
["name"]="王八拳" ["name"]="王八拳"
}, },
[2]={ [22001]={
["name"]="无影腿" ["name"]="无影腿"
}, },
[3]={ [32001]={
["name"]="闪电鞭" ["name"]="闪电鞭"
}, },
[4]={ [42001]={
["name"]="金钟罩" ["name"]="金钟罩"
}, },
[5]={ [52001]={
["name"]="大鹏展翅" ["name"]="大鹏展翅"
}, },
[6]={ [23001]={
["name"]="丹田吐纳" ["name"]="丹田吐纳"
}, },
[7]={ [33001]={
["name"]="疾风骤雨" ["name"]="疾风骤雨"
}, },
[8]={ [43001]={
["name"]="寒冰掌" ["name"]="寒冰掌"
} }
} }

View File

@ -20,38 +20,32 @@ local item = {
[6]={ [6]={
["name"]="史诗招式箱" ["name"]="史诗招式箱"
}, },
[5001]={ [32001]={
["name"]="王八拳招式碎片" ["name"]="王八拳招式碎片"
}, },
[5002]={ [22001]={
["name"]="无影腿招式碎片" ["name"]="无影腿招式碎片"
}, },
[5003]={ [42001]={
["name"]="闪电鞭招式碎片" ["name"]="闪电鞭招式碎片"
}, },
[5004]={ [52001]={
["name"]="金钟罩招式碎片" ["name"]="金钟罩招式碎片"
}, },
[5005]={ [12001]={
["name"]="大鹏展翅招式碎片" ["name"]="大鹏展翅招式碎片"
}, },
[5006]={ [33001]={
["name"]="丹田吐纳招式碎片" ["name"]="丹田吐纳招式碎片"
}, },
[5007]={ [23001]={
["name"]="疾风骤雨招式碎片" ["name"]="疾风骤雨招式碎片"
}, },
[5008]={ [43001]={
["name"]="寒冰掌招式碎片" ["name"]="寒冰掌招式碎片"
},
[5009]={
["name"]="蓄力拳招式碎片"
},
[5010]={
["name"]="烈火神拳招式碎片"
} }
} }
local config = { local config = {
data=item,count=16 data=item,count=14
} }
return config return config

View File

@ -1,26 +1,26 @@
local hero = { local hero = {
[1]={ [12001]={
}, },
[2]={ [22001]={
}, },
[3]={ [32001]={
}, },
[4]={ [42001]={
}, },
[5]={ [52001]={
}, },
[6]={ [23001]={
}, },
[7]={ [33001]={
}, },
[8]={ [43001]={
} }
} }

View File

@ -20,38 +20,32 @@ local item = {
[6]={ [6]={
}, },
[5001]={ [32001]={
}, },
[5002]={ [22001]={
}, },
[5003]={ [42001]={
}, },
[5004]={ [52001]={
}, },
[5005]={ [12001]={
}, },
[5006]={ [33001]={
}, },
[5007]={ [23001]={
}, },
[5008]={ [43001]={
},
[5009]={
},
[5010]={
} }
} }
local config = { local config = {
data=item,count=16 data=item,count=14
} }
return config return config

View File

@ -1,26 +1,26 @@
local hero = { local hero = {
[1]={ [12001]={
}, },
[2]={ [22001]={
}, },
[3]={ [32001]={
}, },
[4]={ [42001]={
}, },
[5]={ [52001]={
}, },
[6]={ [23001]={
}, },
[7]={ [33001]={
}, },
[8]={ [43001]={
} }
} }

View File

@ -20,38 +20,32 @@ local item = {
[6]={ [6]={
}, },
[5001]={ [32001]={
}, },
[5002]={ [22001]={
}, },
[5003]={ [42001]={
}, },
[5004]={ [52001]={
}, },
[5005]={ [12001]={
}, },
[5006]={ [33001]={
}, },
[5007]={ [23001]={
}, },
[5008]={ [43001]={
},
[5009]={
},
[5010]={
} }
} }
local config = { local config = {
data=item,count=16 data=item,count=14
} }
return config return config

View File

@ -1,26 +1,26 @@
local hero = { local hero = {
[1]={ [12001]={
}, },
[2]={ [22001]={
}, },
[3]={ [32001]={
}, },
[4]={ [42001]={
}, },
[5]={ [52001]={
}, },
[6]={ [23001]={
}, },
[7]={ [33001]={
}, },
[8]={ [43001]={
} }
} }

View File

@ -20,38 +20,32 @@ local item = {
[6]={ [6]={
}, },
[5001]={ [32001]={
}, },
[5002]={ [22001]={
}, },
[5003]={ [42001]={
}, },
[5004]={ [52001]={
}, },
[5005]={ [12001]={
}, },
[5006]={ [33001]={
}, },
[5007]={ [23001]={
}, },
[5008]={ [43001]={
},
[5009]={
},
[5010]={
} }
} }
local config = { local config = {
data=item,count=16 data=item,count=14
} }
return config return config

View File

@ -1,26 +1,26 @@
local hero = { local hero = {
[1]={ [12001]={
}, },
[2]={ [22001]={
}, },
[3]={ [32001]={
}, },
[4]={ [42001]={
}, },
[5]={ [52001]={
}, },
[6]={ [23001]={
}, },
[7]={ [33001]={
}, },
[8]={ [43001]={
} }
} }

View File

@ -20,38 +20,32 @@ local item = {
[6]={ [6]={
}, },
[5001]={ [32001]={
}, },
[5002]={ [22001]={
}, },
[5003]={ [42001]={
}, },
[5004]={ [52001]={
}, },
[5005]={ [12001]={
}, },
[5006]={ [33001]={
}, },
[5007]={ [23001]={
}, },
[5008]={ [43001]={
},
[5009]={
},
[5010]={
} }
} }
local config = { local config = {
data=item,count=16 data=item,count=14
} }
return config return config

View File

@ -1,26 +1,26 @@
local hero = { local hero = {
[1]={ [12001]={
}, },
[2]={ [22001]={
}, },
[3]={ [32001]={
}, },
[4]={ [42001]={
}, },
[5]={ [52001]={
}, },
[6]={ [23001]={
}, },
[7]={ [33001]={
}, },
[8]={ [43001]={
} }
} }

View File

@ -20,38 +20,32 @@ local item = {
[6]={ [6]={
}, },
[5001]={ [32001]={
}, },
[5002]={ [22001]={
}, },
[5003]={ [42001]={
}, },
[5004]={ [52001]={
}, },
[5005]={ [12001]={
}, },
[5006]={ [33001]={
}, },
[5007]={ [23001]={
}, },
[5008]={ [43001]={
},
[5009]={
},
[5010]={
} }
} }
local config = { local config = {
data=item,count=16 data=item,count=14
} }
return config return config

View File

@ -1,26 +1,26 @@
local hero = { local hero = {
[1]={ [12001]={
}, },
[2]={ [22001]={
}, },
[3]={ [32001]={
}, },
[4]={ [42001]={
}, },
[5]={ [52001]={
}, },
[6]={ [23001]={
}, },
[7]={ [33001]={
}, },
[8]={ [43001]={
} }
} }

View File

@ -20,38 +20,32 @@ local item = {
[6]={ [6]={
}, },
[5001]={ [32001]={
}, },
[5002]={ [22001]={
}, },
[5003]={ [42001]={
}, },
[5004]={ [52001]={
}, },
[5005]={ [12001]={
}, },
[5006]={ [33001]={
}, },
[5007]={ [23001]={
}, },
[5008]={ [43001]={
},
[5009]={
},
[5010]={
} }
} }
local config = { local config = {
data=item,count=16 data=item,count=14
} }
return config return config

View File

@ -1,26 +1,26 @@
local hero = { local hero = {
[1]={ [12001]={
}, },
[2]={ [22001]={
}, },
[3]={ [32001]={
}, },
[4]={ [42001]={
}, },
[5]={ [52001]={
}, },
[6]={ [23001]={
}, },
[7]={ [33001]={
}, },
[8]={ [43001]={
} }
} }

View File

@ -19,38 +19,32 @@ local item = {
[6]={ [6]={
}, },
[5001]={ [32001]={
}, },
[5002]={ [22001]={
}, },
[5003]={ [42001]={
}, },
[5004]={ [52001]={
}, },
[5005]={ [12001]={
}, },
[5006]={ [33001]={
}, },
[5007]={ [23001]={
}, },
[5008]={ [43001]={
},
[5009]={
},
[5010]={
} }
} }
local config = { local config = {
data=item,count=16 data=item,count=14
} }
return config return config

View File

@ -1,26 +1,26 @@
local hero = { local hero = {
[1]={ [12001]={
}, },
[2]={ [22001]={
}, },
[3]={ [32001]={
}, },
[4]={ [42001]={
}, },
[5]={ [52001]={
}, },
[6]={ [23001]={
}, },
[7]={ [33001]={
}, },
[8]={ [43001]={
} }
} }

View File

@ -17,38 +17,32 @@ local item = {
[6]={ [6]={
}, },
[5001]={ [32001]={
}, },
[5002]={ [22001]={
}, },
[5003]={ [42001]={
}, },
[5004]={ [52001]={
}, },
[5005]={ [12001]={
}, },
[5006]={ [33001]={
}, },
[5007]={ [23001]={
}, },
[5008]={ [43001]={
},
[5009]={
},
[5010]={
} }
} }
local config = { local config = {
data=item,count=16 data=item,count=14
} }
return config return config

View File

@ -1,26 +1,26 @@
local hero = { local hero = {
[1]={ [12001]={
}, },
[2]={ [22001]={
}, },
[3]={ [32001]={
}, },
[4]={ [42001]={
}, },
[5]={ [52001]={
}, },
[6]={ [23001]={
}, },
[7]={ [33001]={
}, },
[8]={ [43001]={
} }
} }

View File

@ -17,38 +17,32 @@ local item = {
[6]={ [6]={
}, },
[5001]={ [32001]={
}, },
[5002]={ [22001]={
}, },
[5003]={ [42001]={
}, },
[5004]={ [52001]={
}, },
[5005]={ [12001]={
}, },
[5006]={ [33001]={
}, },
[5007]={ [23001]={
}, },
[5008]={ [43001]={
},
[5009]={
},
[5010]={
} }
} }
local config = { local config = {
data=item,count=16 data=item,count=14
} }
return config return config

View File

@ -1,26 +1,26 @@
local hero = { local hero = {
[1]={ [12001]={
}, },
[2]={ [22001]={
}, },
[3]={ [32001]={
}, },
[4]={ [42001]={
}, },
[5]={ [52001]={
}, },
[6]={ [23001]={
}, },
[7]={ [33001]={
}, },
[8]={ [43001]={
} }
} }

View File

@ -20,38 +20,32 @@ local item = {
[6]={ [6]={
}, },
[5001]={ [32001]={
}, },
[5002]={ [22001]={
}, },
[5003]={ [42001]={
}, },
[5004]={ [52001]={
}, },
[5005]={ [12001]={
}, },
[5006]={ [33001]={
}, },
[5007]={ [23001]={
}, },
[5008]={ [43001]={
},
[5009]={
},
[5010]={
} }
} }
local config = { local config = {
data=item,count=16 data=item,count=14
} }
return config return config

View File

@ -1,26 +1,26 @@
local hero = { local hero = {
[1]={ [12001]={
}, },
[2]={ [22001]={
}, },
[3]={ [32001]={
}, },
[4]={ [42001]={
}, },
[5]={ [52001]={
}, },
[6]={ [23001]={
}, },
[7]={ [33001]={
}, },
[8]={ [43001]={
} }
} }

View File

@ -20,38 +20,32 @@ local item = {
[6]={ [6]={
}, },
[5001]={ [32001]={
}, },
[5002]={ [22001]={
}, },
[5003]={ [42001]={
}, },
[5004]={ [52001]={
}, },
[5005]={ [12001]={
}, },
[5006]={ [33001]={
}, },
[5007]={ [23001]={
}, },
[5008]={ [43001]={
},
[5009]={
},
[5010]={
} }
} }
local config = { local config = {
data=item,count=16 data=item,count=14
} }
return config return config

View File

@ -11,11 +11,21 @@ BattleConst.ONE_STEP_TIME = 0.2
BattleConst.ELEMENT_TYPE_COUNT = 5 BattleConst.ELEMENT_TYPE_COUNT = 5
BattleConst.ELEMENT_WIGHT = 100 BattleConst.ELEMENT_WIGHT = 100
BattleConst.MAX_ELEMENT_WIGHT = 500 BattleConst.MAX_ELEMENT_WIGHT = 500
BattleConst.SIDE_ATK = 1
BattleConst.SIDE_DEF = 2
BattleConst.BATTLE_TYPE = { BattleConst.BATTLE_TYPE = {
STAGE = 1, STAGE = 1,
} }
BattleConst.UNIT_STATE = {
INIT = 0,
IDLE = 1, -- 待机
ATTACK = 2, -- 攻击
HURT = 3, -- 受伤
DEAD = 4, -- 死亡
}
---- 格子类型 ---- 格子类型
BattleConst.GRID_TYPE = { BattleConst.GRID_TYPE = {
EMPTY = 0, EMPTY = 0,

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1d2b66c71824629498617879343ea43a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: e202fd02d78948749809ede46846c300 guid: 612a5421ff64f07409a9786ba07c6e59
ScriptedImporter: ScriptedImporter:
internalIDToNameTable: [] internalIDToNameTable: []
externalObjects: {} externalObjects: {}

View File

@ -3,4 +3,12 @@ local ItemConst = {}
ItemConst.ITEM_ID_GOLD = 1 ItemConst.ITEM_ID_GOLD = 1
ItemConst.ITEM_ID_GEM = 2 ItemConst.ITEM_ID_GEM = 2
ItemConst.ITEM_TYPE = {
RES = 1,
ITEM = 2,
RANDOM_FRAGMENT = 3,
BOX = 4,
HERO_FRAGMENT = 5
}
return ItemConst return ItemConst

View File

@ -4,64 +4,27 @@ function ServerBagData:ctor()
self.ItemData = require("app/server/data/server_item_data"):create() self.ItemData = require("app/server/data/server_item_data"):create()
end end
function ServerBagData:init()
self.ItemData:init()
end
function ServerBagData:loadLocalData() 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 end
function ServerBagData:clear() function ServerBagData:clear()
self.ItemData:clear() self.ItemData:clear()
end 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 return ServerBagData

View File

@ -19,17 +19,28 @@ end
function ServerBaseData:init() function ServerBaseData:init()
end end
function ServerBaseData:clear()
end
function ServerBaseData:loadLocalData() function ServerBaseData:loadLocalData()
local data = LocalData:getString("ServerData_" .. self.__cname, "") local data = LocalData:getString(self:_getLocalSaveKey(), "")
local dataObj = nil local dataObj = nil
if data and data ~= "" then if data and data ~= "" then
dataObj = json.decode(data) dataObj = json.decode(data)
end end
self:init(dataObj) return dataObj
end end
function ServerBaseData:loadNewPlayerData() function ServerBaseData:saveLocalData()
self:init() 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 end
function ServerBaseData:getCloneData() function ServerBaseData:getCloneData()
@ -50,8 +61,19 @@ function ServerBaseData:getCloneData()
return _copy(self.data) return _copy(self.data)
end 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 end
return ServerBaseData return ServerBaseData

View File

@ -1,3 +1,25 @@
local ServerHeroData = class("ServerHeroData", ServerBaseData) 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 return ServerHeroData

View File

@ -1,74 +1,47 @@
local ServerItemData = class("ServerItemData", ServerBaseData) local ServerItemData = class("ServerItemData", ServerBaseData)
function ServerItemData:init(data) function ServerItemData:init(data)
data = data or {}
self.data.items = {} self.data.items = {}
for idStr, item in pairs(data) do if data then
local id = tonumber(idStr) for idStr, item in pairs(data.items) do
if id == GConst.ItemConst.ITEM_ID_VIT then local id = tonumber(idStr)
local ServerGameData = require "app/server/data/server_game_data" if id == GConst.ItemConst.ITEM_ID_VIT then
ServerGameData.PlayerData:setVit(item.count) 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 end
self.data.items[id] = {cfg_id = id, count = item.count} self.data.recoveries = data.recoveries
else
self.data.recoveries = {}
end end
self.data.recoveries = data.recoveries or {}
self:checkRecoveries() self:checkRecoveries()
end end
function ServerItemData:tryAddItem(id, num) 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 if num < 0 then
return false return false
end end
else else
if self.data.items[id].count + num < 0 then if self.data.items[idStr].count + num < 0 then
return false return false
end end
end end
return true return true
end 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() function ServerItemData:getAllItems()
return self.data.items return self.data.items
end end
function ServerItemData:getItemNumById(id) function ServerItemData:getItemNumById(id)
if not self.data.items[id] then local idStr = tostring(id)
if not self.data.items[idStr] then
return 0 return 0
end end
local num = self.data.items[id].count or 0 local num = self.data.items[idStr].count or 0
return num return num
end end
@ -106,7 +79,7 @@ function ServerItemData:recoveryItem(data, maxCount)
return return
end end
if data.cfg_id == GConst.ItemConst.ITEM_ID_VIT then 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() local currentCount = ServerGameData.PlayerData:getVit()
if currentCount >= maxCount then -- 已经达到上限 if currentCount >= maxCount then -- 已经达到上限
return return
@ -142,7 +115,7 @@ function ServerItemData:recoveryItem(data, maxCount)
if currentCount + addCount > maxCount then if currentCount + addCount > maxCount then
addCount = maxCount - currentCount addCount = maxCount - currentCount
end end
self:addItem(data.cfg_id, addCount) self:_addItem(data.cfg_id, addCount)
ServerDataManager:saveData() ServerDataManager:saveData()
end end
@ -180,4 +153,69 @@ function ServerItemData:getMaxVit()
return self.maxVit return self.maxVit
end 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 return ServerItemData

View File

@ -6,6 +6,9 @@ local TempRewards = {}
function ServerGameData:init() function ServerGameData:init()
if self.isInit then if self.isInit then
for k, v in pairs(self.dataMap) do
v:_clear()
end
return return
end end
self.isInit = true self.isInit = true
@ -23,20 +26,55 @@ function ServerGameData:initData()
local isNewPlayer = LocalData:getIsNewPlayer() local isNewPlayer = LocalData:getIsNewPlayer()
if isNewPlayer then if isNewPlayer then
for k, v in pairs(self.dataMap) do for k, v in pairs(self.dataMap) do
v:loadNewPlayerData() v:init()
end end
local playerInitialCfg = ConfigManager:getConfig("player_initial") local playerInitialCfg = ConfigManager:getConfig("player_initial")
if playerInitialCfg then if playerInitialCfg then
for k, v in pairs(playerInitialCfg) do for k, v in pairs(playerInitialCfg) do
if v.reward then 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 end
end end
self:saveData()
LocalData:setNotNewPlayer() LocalData:setNotNewPlayer()
LocalData:save()
else else
for k, v in pairs(self.dataMap) do for k, v in pairs(self.dataMap) do
v:loadLocalData() v:init(v:loadLocalData())
end end
end end
end end
@ -57,6 +95,12 @@ function ServerGameData:getData()
return data return data
end end
function ServerGameData:saveData()
for k, v in pairs(self.dataMap) do
v:saveLocalData()
end
end
-- 根据配置表添加奖励 -- 根据配置表添加奖励
function ServerGameData:addRewards(cfgRewards, getType) function ServerGameData:addRewards(cfgRewards, getType)
local rewards = {} local rewards = {}
@ -87,7 +131,7 @@ function ServerGameData:addRewards(cfgRewards, getType)
local rewardType = GFunc.getRewardType(reward) local rewardType = GFunc.getRewardType(reward)
newReward.type = rewardType newReward.type = rewardType
if rewardType == GConst.ServerDataConst.REWARD_TYPE.ITEM then 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 rewardId = GFunc.getRewardId(reward)
local rewardNum = GFunc.getRewardNum(reward) local rewardNum = GFunc.getRewardNum(reward)
if rewardId == GConst.ItemConst.ITEM_ID_EXP then if rewardId == GConst.ItemConst.ITEM_ID_EXP then
@ -104,42 +148,6 @@ function ServerGameData:addRewards(cfgRewards, getType)
return rewards return rewards
end 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() function ServerGameData:getNewReward()
local rewards = { local rewards = {
type = 0, type = 0,

View File

@ -11,12 +11,14 @@ BagData.RECOVERY_TYPE = {
function BagData:ctor() function BagData:ctor()
self.ItemData = require("app/userdata/bag/item_data"):create() self.ItemData = require("app/userdata/bag/item_data"):create()
self.EquipData = require("app/userdata/bag/equip_data"):create()
end end
function BagData:init(data) function BagData:init(data)
self.ItemData:init(data.items) if data then
self.EquipData:init(data.equips) self.ItemData:init(data.ItemData)
else
self.ItemData:init()
end
self.recoveries = data.recoveries or {} self.recoveries = data.recoveries or {}
-- ts在此处做转换对每日回复来说ts指下次回复时间对时间回复来说ts仍指上次回复时间 -- ts在此处做转换对每日回复来说ts指下次回复时间对时间回复来说ts仍指上次回复时间
@ -32,7 +34,6 @@ end
function BagData:clear() function BagData:clear()
self.ItemData:clear() self.ItemData:clear()
self.EquipData:clear()
self.recoveries = {} self.recoveries = {}
DataManager:unregisterDataCd("BagData") DataManager:unregisterDataCd("BagData")
end end
@ -65,7 +66,6 @@ function BagData:getTimelyItemRecoveryTime(itemId)
-- data.ts = Time:getServerTime() -- data.ts = Time:getServerTime()
-- return 1000 -- 需要持续重置,保持时间更新 -- return 1000 -- 需要持续重置,保持时间更新
-- end -- end
-- -- 计算时间 -- -- 计算时间
-- local intervalTime = cfg.time -- local intervalTime = cfg.time
-- if itemId == GConst.ItemConst.ITEM_ID_MINING_PICK then -- if itemId == GConst.ItemConst.ITEM_ID_MINING_PICK then
@ -90,7 +90,6 @@ function BagData:getDailyItemRecoveryMaxTime(itemId)
if data then if data then
return data.ts - Time:getServerTime() return data.ts - Time:getServerTime()
end end
return -1 return -1
end end
@ -123,10 +122,10 @@ function BagData:getTimelyItemRecoveryMaxTime(itemId)
-- return curTime -- return curTime
end end
-- 按时间回复的在此回复 -- 按时间回复的在此回复
function BagData:recoveryItem(data, maxBigNum) function BagData:recoveryItem(data, maxNum)
-- 计算已经达到上限 -- 计算已经达到上限
local curBigNum = self.ItemData:getItemBigNumById(data.id) local curBigNum = self.ItemData:getItemNumById(data.id)
if BigNumOpt.bigNumCompare(curBigNum, maxBigNum) >= 0 then if curBigNum >= maxNum then
return return
end end
-- 计算恢复间隔 -- 计算恢复间隔

View File

@ -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

View File

@ -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

View File

@ -19,24 +19,23 @@ function ItemData:init(data)
self.items = {} self.items = {}
data = data or {} data = data or {}
for _, info in pairs(data) do for _, info in pairs(data) do
if info.id == GConst.ItemConst.ITEM_ID_GEM then -- if info.id == GConst.ItemConst.ITEM_ID_GEM then
local parmas = {} -- local parmas = {}
parmas.gem = BigNumOpt.bigNum2Num(info.count) -- parmas.gem = BigNumOpt.bigNum2Num(info.count)
CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(parmas) -- CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(parmas)
elseif info.id == GConst.ItemConst.ITEM_ID_GOLD then -- elseif info.id == GConst.ItemConst.ITEM_ID_GOLD then
local parmas = {} -- local parmas = {}
parmas.gold_value = info.count.value -- parmas.gold_value = info.count.value
parmas.gold_unit = info.count.unit -- parmas.gold_unit = info.count.unit
CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(parmas) -- CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(parmas)
end -- end
self:_add(info.id, info.count) self:_add(info.cfg_id, info.count)
end end
self.data.dirty = false self.data.dirty = false
end end
function ItemData:_add(id, bigNum) function ItemData:_add(id, num)
self.items[id] = ItemEntity:create(id, bigNum) self.items[id] = ItemEntity:create(id, num)
end end
function ItemData:clear() function ItemData:clear()
@ -48,7 +47,7 @@ function ItemData:getItemById(id)
if self.items[id] then if self.items[id] then
return self.items[id] return self.items[id]
end end
local item = ItemEntity:create(id, BigNumOpt.num2BigNum(0)) local item = ItemEntity:create(id, 0)
self.items[id] = item self.items[id] = item
return self.items[id] return self.items[id]
end end
@ -61,32 +60,22 @@ end
function ItemData:getItemBigNumById(id) function ItemData:getItemBigNumById(id)
local num local num
if self.items[id] then if self.items[id] then
num = self.items[id]:getBigNum() num = self.items[id]:getNum()
else else
num = BigNumOpt.num2BigNum(0) num = 0
end
return num
end
function ItemData:getItemBigNumStrById(id)
local num = 0
if self.items[id] then
num = self.items[id]:getBigNumStr()
end end
return num return num
end end
function ItemData:addItemReward(item, itemGetType) function ItemData:addItemReward(item, itemGetType)
CACHE_ITEM.id = item.id CACHE_ITEM.cfg_id = GFunc.getRewardId(item)
CACHE_ITEM.count.unit = item.count.unit CACHE_ITEM.count = GFunc.getRewardNum(item)
CACHE_ITEM.count.value = item.count.value
self:addItem(CACHE_ITEM, itemGetType) self:addItem(CACHE_ITEM, itemGetType)
end end
function ItemData:addItemCost(cost, itemGetType) function ItemData:addItemCost(cost, itemGetType)
CACHE_ITEM.id = cost.id CACHE_ITEM.cfg_id = GFunc.getRewardId(cost)
CACHE_ITEM.count.unit = cost.count.unit CACHE_ITEM.count = -GFunc.getRewardNum(cost)
CACHE_ITEM.count.value = -cost.count.value
self:addItem(CACHE_ITEM, itemGetType) self:addItem(CACHE_ITEM, itemGetType)
end end
@ -94,8 +83,8 @@ function ItemData:addItemCosts(costs, itemGetType)
if not costs then if not costs then
return return
end end
for _, unitCost in ipairs(costs) do for _, cost in ipairs(costs) do
self:addItemCost(unitCost, itemGetType) self:addItemCost(cost, itemGetType)
end end
end end
@ -116,72 +105,49 @@ function ItemData:addItem(data, itemGetType)
end end
end end
local itemCfg = ConfigManager:getConfig("item")[data.id] self:_addItemNumById(data.cfg_id, data.count)
self:_addItemNumById(data.id, data.count) if data.cfg_id == GConst.ItemConst.ITEM_ID_GEM or data.cfg_id == GConst.ItemConst.ITEM_ID_GOLD then
if data.id == GConst.ItemConst.ITEM_ID_GEM or data.id == GConst.ItemConst.ITEM_ID_GOLD then
if data.count.value < 0 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 else
BIReport:postGemUse(data.count, itemGetType, data.id) BIReport:postGemUse(data.count, itemGetType, data.cfg_id)
if data.id == GConst.ItemConst.ITEM_ID_GEM then if data.cfg_id == GConst.ItemConst.ITEM_ID_GEM then
CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserAdd("gem", BigNumOpt.bigNum2Num(data.count)) CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserAdd("gem", data.count)
elseif data.id == GConst.ItemConst.ITEM_ID_GOLD then elseif data.cfg_id == GConst.ItemConst.ITEM_ID_GOLD then
local goldBigNum = DataManager.BagData.ItemData:getItemBigNumById(GConst.ItemConst.ITEM_ID_GOLD) local goldNum = DataManager.BagData.ItemData:getItemNumById(GConst.ItemConst.ITEM_ID_GOLD)
local parmas = {} local parmas = {}
parmas.gold_value = goldBigNum.value parmas.gold = goldNum
parmas.gold_unit = goldBigNum.unit
CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(parmas) CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(parmas)
end end
end end
else 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 else
BIReport:postGemGet(data.count, itemGetType, data.id) BIReport:postGemGet(data.count, itemGetType, data.cfg_id)
if data.id == GConst.ItemConst.ITEM_ID_GEM then if data.cfg_id == GConst.ItemConst.ITEM_ID_GEM then
CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserAdd("gem", BigNumOpt.bigNum2Num(data.count)) CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserAdd("gem", data.count)
elseif data.id == GConst.ItemConst.ITEM_ID_GOLD then elseif data.cfg_id == GConst.ItemConst.ITEM_ID_GOLD then
local goldBigNum = DataManager.BagData.ItemData:getItemBigNumById(GConst.ItemConst.ITEM_ID_GOLD) local goldNum = DataManager.BagData.ItemData:getItemNumById(GConst.ItemConst.ITEM_ID_GOLD)
local parmas = {} local parmas = {}
parmas.gold_value = goldBigNum.value parmas.gold = goldNum
parmas.gold_unit = goldBigNum.unit
CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(parmas) CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(parmas)
end end
end end
end end
else else
if data.count.value < 0 then if data.count.value < 0 then
BIReport:postItemUse(data.count, data.id, itemGetType) BIReport:postItemUse(data.count, data.cfg_id, itemGetType)
else else
BIReport:postItemGet(data.count, data.id, itemGetType) BIReport:postItemGet(data.count, data.cfg_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})
end end
end end
end end
function ItemData:addItemNumById(id, num, itemGetType) function ItemData:addItemNumById(id, num, itemGetType)
local data = {id = id, count = num} CACHE_ITEM.cfg_id = id
self:addItem(data, itemGetType) CACHE_ITEM.count = num
self:addItem(CACHE_ITEM, itemGetType)
end end
function ItemData:_addItemNumById(id, bigNum) function ItemData:_addItemNumById(id, bigNum)
@ -195,7 +161,7 @@ function ItemData:_addItemNumById(id, bigNum)
-- isFull = currentCount >= maxVit -- isFull = currentCount >= maxVit
-- end -- end
if self.items[id] then if self.items[id] then
self.items[id]:addBigNum(bigNum) self.items[id]:addNum(bigNum)
else else
self:_add(id, bigNum) self:_add(id, bigNum)
end end

View File

@ -34,12 +34,8 @@ function ItemEntity:getBigNum()
return self.data.bigNum return self.data.bigNum
end 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.data.bigNum = BigNumOpt.bigNumAdd(self.data.bigNum, bigNum)
self:setDirty() self:setDirty()
end end

View File

@ -1,3 +1,5 @@
local BattleTeamEntity = require "app/userdata/battle/team/battle_team_entity"
local BattleData = class("BattleData", BaseData) local BattleData = class("BattleData", BaseData)
local SKILL_HERO_CFG = ConfigManager:getConfig("skill_hero") 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) function BattleData:init(board, skillIds)
self:clear() self:clear()
self.atkTeam = self:initTeam(BattleConst.SIDE_ATK)
self.defTeam = self:initTeam(BattleConst.SIDE_DEF)
for i, info in ipairs(board) do for i, info in ipairs(board) do
local r = 1 local r = 1
@ -237,4 +241,10 @@ function BattleData:addSkillEnergy(elementMap)
end end
end end
function BattleData:initTeam(side)
local team = BattleTeamEntity:create()
team:init(side)
return team
end
return BattleData return BattleData

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 589f4571d71430d4e8c91ff45291e5c4
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 4b8e39bcbd3e7764cab23eeb28728ba0 guid: 2338db9a689f0bb43a3a28739268ea4e
ScriptedImporter: ScriptedImporter:
internalIDToNameTable: [] internalIDToNameTable: []
externalObjects: {} externalObjects: {}

View File

@ -0,0 +1,9 @@
local BattleUnitEntity = class("BattleUnitEntity", BaseData)
function BattleUnitEntity:ctor()
end
function BattleUnitEntity:init()
end
return BattleUnitEntity

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: d87717a1e70e9c443afefb650cd9105f
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -12,14 +12,20 @@ end
function HeroData:init(data) function HeroData:init(data)
self.heroes = {} self.heroes = {}
local heroCfg = ConfigManager:getConfig("hero") if data then
for heroId, heroInfo in pairs(heroCfg) do for _, heroInfo in pairs(data.heroes) do
self:createHeroById(heroId, heroInfo) self:addHero(heroInfo.cfg_id, heroInfo.lv)
end
end end
end end
function HeroData:createHeroById(heroId, heroInfo) function HeroData:addHero(cfgId, lv)
self.heroes[heroId] = HeroEntity:create(heroId, heroInfo) 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 end
function HeroData:getAllHeroes() function HeroData:getAllHeroes()

View File

@ -1,11 +1,11 @@
local HeroEntity = class("HeroEntity", BaseData) local HeroEntity = class("HeroEntity", BaseData)
function HeroEntity:ctor(cfgId, config) function HeroEntity:ctor(cfgId, lv)
self.id = cfgId self.id = cfgId
self.config = config
self.cfgId = cfgId self.cfgId = cfgId
self.data.lv = 0 self.data.lv = lv
self.attrDirty = false self.attrDirty = false
self.config = ConfigManager:getConfig("hero")[self.cfgId]
self.baseAttrOriginal = {} self.baseAttrOriginal = {}
self.allAttr = {} self.allAttr = {}