战斗
This commit is contained in:
parent
aacf7bc803
commit
8a19ab4781
@ -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()
|
||||||
|
|||||||
@ -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()
|
||||||
|
|||||||
@ -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,
|
||||||
|
|||||||
8
lua/app/module/battle/component.meta
Normal file
8
lua/app/module/battle/component.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1d2b66c71824629498617879343ea43a
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
36
lua/app/module/battle/component/battle_unit_comp.lua
Normal file
36
lua/app/module/battle/component/battle_unit_comp.lua
Normal 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
|
||||||
@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: e202fd02d78948749809ede46846c300
|
guid: 612a5421ff64f07409a9786ba07c6e59
|
||||||
ScriptedImporter:
|
ScriptedImporter:
|
||||||
internalIDToNameTable: []
|
internalIDToNameTable: []
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
@ -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
|
||||||
@ -4,64 +4,23 @@ 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
|
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
|
||||||
@ -25,11 +25,7 @@ function ServerBaseData:loadLocalData()
|
|||||||
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
|
|
||||||
|
|
||||||
function ServerBaseData:loadNewPlayerData()
|
|
||||||
self:init()
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function ServerBaseData:getCloneData()
|
function ServerBaseData:getCloneData()
|
||||||
|
|||||||
@ -1,3 +1,23 @@
|
|||||||
local ServerHeroData = class("ServerHeroData", ServerBaseData)
|
local ServerHeroData = class("ServerHeroData", ServerBaseData)
|
||||||
|
|
||||||
|
function ServerHeroData:init(data)
|
||||||
|
self.data.heroes = data and data.heroes or {}
|
||||||
|
end
|
||||||
|
|
||||||
|
function ServerHeroData:getHeroByCfgId(id)
|
||||||
|
return self.data.heroes[id]
|
||||||
|
end
|
||||||
|
|
||||||
|
function ServerHeroData:addHero(id, lv)
|
||||||
|
Logger.logHighlight("addHero==11")
|
||||||
|
if self.data.heroes[id] then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
Logger.logHighlight("addHero==22")
|
||||||
|
self.data.heroes[id] = {
|
||||||
|
cfg_id = id,
|
||||||
|
lv = lv,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
return ServerHeroData
|
return ServerHeroData
|
||||||
@ -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
|
||||||
@ -23,20 +23,53 @@ 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
|
||||||
LocalData:setNotNewPlayer()
|
-- LocalData:setNotNewPlayer()
|
||||||
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
|
||||||
@ -87,7 +120,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 +137,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,
|
||||||
|
|||||||
@ -11,17 +11,19 @@ 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仍指上次回复时间
|
||||||
for i,v in pairs(self.recoveries) do
|
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]
|
-- local cfg = RecoveryCfg[v.id]
|
||||||
-- if cfg.type == self.RECOVERY_TYPE.DAILY then
|
-- if cfg.type == self.RECOVERY_TYPE.DAILY then
|
||||||
-- self.recoveries[i].ts = self.recoveries[i].ts + SECONDS_PRE_DAY
|
-- self.recoveries[i].ts = self.recoveries[i].ts + SECONDS_PRE_DAY
|
||||||
@ -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
|
||||||
-- 计算恢复间隔
|
-- 计算恢复间隔
|
||||||
|
|||||||
@ -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
|
|
||||||
@ -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
|
|
||||||
@ -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
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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 BattleConst = GConst.BattleConst
|
local BattleConst = GConst.BattleConst
|
||||||
@ -6,6 +8,8 @@ local BATTLE_CARD_SKILL_ENTITY = require "app/userdata/battle/skill/battle_card_
|
|||||||
|
|
||||||
function BattleData:init(board)
|
function BattleData:init(board)
|
||||||
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
|
||||||
@ -136,4 +140,10 @@ function BattleData:setGridInfo(posId, gridInfo)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleData:initTeam(side)
|
||||||
|
local team = BattleTeamEntity:create()
|
||||||
|
team:init(side)
|
||||||
|
return team
|
||||||
|
end
|
||||||
|
|
||||||
return BattleData
|
return BattleData
|
||||||
8
lua/app/userdata/battle/team.meta
Normal file
8
lua/app/userdata/battle/team.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 589f4571d71430d4e8c91ff45291e5c4
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
13
lua/app/userdata/battle/team/battle_team_entity.lua
Normal file
13
lua/app/userdata/battle/team/battle_team_entity.lua
Normal 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
|
||||||
@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 4b8e39bcbd3e7764cab23eeb28728ba0
|
guid: 2338db9a689f0bb43a3a28739268ea4e
|
||||||
ScriptedImporter:
|
ScriptedImporter:
|
||||||
internalIDToNameTable: []
|
internalIDToNameTable: []
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
9
lua/app/userdata/battle/team/battle_unit_entity.lua
Normal file
9
lua/app/userdata/battle/team/battle_unit_entity.lua
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
local BattleUnitEntity = class("BattleUnitEntity", BaseData)
|
||||||
|
|
||||||
|
function BattleUnitEntity:ctor()
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleUnitEntity:init()
|
||||||
|
end
|
||||||
|
|
||||||
|
return BattleUnitEntity
|
||||||
10
lua/app/userdata/battle/team/battle_unit_entity.lua.meta
Normal file
10
lua/app/userdata/battle/team/battle_unit_entity.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d87717a1e70e9c443afefb650cd9105f
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
Loading…
x
Reference in New Issue
Block a user