Merge branch 'dev' of git.juzugame.com:b6-client/b6-lua into dev

This commit is contained in:
chenxi 2023-04-26 18:27:52 +08:00
commit 799b6c531d
22 changed files with 435 additions and 860 deletions

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,6 @@ local LOCAL_DATA_KEY = {
LAST_LOGIN_NAME = "LAST_LOGIN_NAME",
LAST_LOGIN_IP = "LAST_LOGIN_IP",
ACCOUNT_INFO = "ACCOUNT_INFO",
SEND_QUEUE = "SEND_QUEUE",
SDK_LOGIN_TYPE = "SDK_LOGIN_TYPE",
NEED_UPDATE = "NEED_UPDATE", -- 需要更新
@ -25,6 +24,7 @@ local LOCAL_DATA_KEY = {
LAST_MAIL_ID = "LAST_MAIL_ID",
IS_NEW_PLAYER = "IS_NEW_PLAYER",
DISTINCT_ID = "DISTINCT_ID",
LAST_LOGIN_TIME = "LAST_LOGIN_TIME",
}
LocalData.KEYS = LOCAL_DATA_KEY
@ -211,21 +211,6 @@ function LocalData:getLastLoginName()
return self:getString(LOCAL_DATA_KEY.LAST_LOGIN_NAME, "")
end
function LocalData:saveSendQueue(sendQueue)
local str = json.encode(sendQueue)
if EDITOR_MODE then
Logger.log("---------------------剩余消息队列缓存---------------------------------")
--Logger.logHighlight(str)
print(str)
end
self:setString(LOCAL_DATA_KEY.SEND_QUEUE, str)
end
function LocalData:getSendQueue()
local sendQueue = json.decode(self:getString(LOCAL_DATA_KEY.SEND_QUEUE, "{}"))
return sendQueue
end
function LocalData:setShakeMode(value) -- 0-close 1-open
self:setInt(self:getString(LOCAL_DATA_KEY.SHAKE_MODE), value)
end
@ -291,4 +276,8 @@ function LocalData:getDistinctId()
return self:getString(LOCAL_DATA_KEY.DISTINCT_ID, "")
end
function LocalData:setLastLoginTime()
end
return LocalData

View File

@ -90,7 +90,7 @@ function PayManager:requestRewards(purchaseToken, orderId, originOrderId, giftTy
if msgData.rewards and table.nums(msgData.rewards) > 0 then -- 奖励改到邮件领取
GFunc.showRewardBox(msgData.rewards)
end
BIReport:postPayGet(giftType, id, rechargeId, orderId, originOrderId, 1, msgData.rewards or {})
-- BIReport:postPayGet(giftType, id, rechargeId, orderId, originOrderId, 1, msgData.rewards or {})
local rechargeCfg = ConfigManager:getConfig("recharge")[rechargeId]
if rechargeCfg then
BIReport:postPurchase(rechargeCfg.price, rechargeCfg.payId, originOrderId, orderId)
@ -135,7 +135,7 @@ function PayManager:checkAndPay(productId, id, purchaseType, rechargeId)
if msgData.status == 0 then
if msgData.uuid and msgData.uuid ~= GConst.EMPTY_STRING then
local giftType = PayManager:getGiftType(purchaseType, id)
BIReport:postPayTurn(giftType, id, rechargeId)
-- BIReport:postPayTurn(giftType, id, rechargeId)
SDKManager:pay(productId, msgData.uuid, rechargeId, giftType, function(purchaseToken, orderId, originOrderId)
if purchaseToken and orderId then
self:requestRewards(purchaseToken, orderId, originOrderId, giftType, id, rechargeId)

View File

@ -1,5 +1,6 @@
local LocalizationGlobalConst =
{
CHAPTER_DESC_1 = "CHAPTER_DESC_1",
MAIN_BTN_1 = "MAIN_BTN_1",
QLT_DESC_1 = "QLT_DESC_1",
QLT_DESC_2 = "QLT_DESC_2",

View File

@ -55,6 +55,7 @@ local localization_global =
["LOADING_DESC"] = "加载中.......",
["CLICK_COPY_ACOUNT_DESC"] = "点击复制用户ID",
["APP"] = "版本号:",
["CHAPTER_DESC_1"] = "最高纪录{0}",
}
return localization_global

View File

@ -774,26 +774,22 @@ function GFunc.getRandomIndex(weightArr)
return idx
end
-- function GFunc.getRewardsStr(rewards)
-- if rewards == nil then
-- return
-- end
function GFunc.getRewardsStr(rewards)
if rewards == nil then
return
end
-- local itemStr = ""
-- for k, v in ipairs(rewards) do
-- if v.type == GConst.REWARD_TYPE.ITEM then
-- itemStr = itemStr .. v.type .. "." .. v.item.cfg_id .. "." .. v.item.count
-- elseif v.type == GConst.REWARD_TYPE.EQUIP then
-- itemStr = itemStr .. v.type .. "." .. v.equip.id .. "." .. v.equip.eid
-- elseif v.type == GConst.REWARD_TYPE.JEWELRY then
-- itemStr = itemStr .. v.type .. "." .. v.jewelry.cfg_id .. "." .. v.jewelry.count
-- end
-- if k ~= #rewards then
-- itemStr = itemStr.. "|"
-- end
-- end
-- return itemStr
-- end
local itemStr = ""
for k, v in ipairs(rewards) do
if v.type == GConst.REWARD_TYPE.ITEM then
itemStr = itemStr .. v.type .. "." .. v.item.cfg_id .. "." .. v.item.count
end
if k ~= #rewards then
itemStr = itemStr.. "|"
end
end
return itemStr
end
function GFunc.copyStr(str)
CS.UnityEngine.GUIUtility.systemCopyBuffer = str

View File

@ -19,6 +19,7 @@ function BattleManager:showBattleResultUI(rewards, combatReport)
end
function BattleManager:playBattle(battleType, params, returnFunc)
params = params or {}
if self.battleController then -- 同一时间只能有一场战斗
self:clear()
end
@ -28,6 +29,7 @@ function BattleManager:playBattle(battleType, params, returnFunc)
end
function BattleManager:_play(battleType, params)
params.battleType = battleType
local controllerPath = BATTLE_CONTROLLER[battleType] or BATTLE_CONTROLLER_BASE
self.battleController = require(controllerPath):create()
self.battleController:init(params)
@ -41,8 +43,11 @@ function BattleManager:onSelectSkill(skillId, value, pos)
self.battleController:onSelectSkill(skillId, value, pos)
end
function BattleManager:endBattleAndExit()
function BattleManager:endBattleAndExit(proactivelyExit)
if self.battleController then
if proactivelyExit then
self.battleController:postWaveOver(false, true)
end
self.battleController:endBattleAndExit()
else
self:exitBattle()

View File

@ -153,7 +153,11 @@ function BattleController:onLinkChange()
end
end
function BattleController:onRoundBegin()
function BattleController:postWaveOver(atkDead, isQuit)
end
function BattleController:postFightStart()
end
@ -178,6 +182,13 @@ end
function BattleController:init(params)
params = params or {}
self.battleType = params.battleType or GConst.BattleConst.BATTLE_TYPE.STAGE
self.battleStartTime = Time:getServerTime()
self.waveStartTime = Time:getServerTime()
self.eliminateCount = 0
self.eliminateTotalCount = 0
self.realTime = 0
self.chapterId = self:getChapterId()
self.waveIndex = 0
self.maxWaveIndex = self:getMaxWave()
@ -378,16 +389,22 @@ function BattleController:enterNextWave()
local atkTeam = self.battleData:getAtkTeam()
if not atkTeam or atkTeam:getIsDead() then
self.victory = false
self:postWaveOver(true)
self:battleEnd()
return
end
if self.waveIndex >= self.maxWaveIndex then
self.victory = true
self:postWaveOver(false)
self:battleEnd()
return
end
if self.waveIndex ~= 0 then -- 第一波
self:postWaveOver(false)
end
self.waveIndex = self.waveIndex + 1
if self.battleUI then
self.battleUI:refreshWave(self.waveIndex)
@ -395,15 +412,20 @@ function BattleController:enterNextWave()
if self.waveIndex == 1 then -- 第一波
self:generateBoard(true)
else
-- 上报关卡结束
self.defTeam:prepare()
end
self:enterRoundBegin()
self.waveStartTime = Time:getServerTime()
self.eliminateCount = 0
self.isBossWave = self.defTeam:getMainUnit().unitEntity:getIsBoss()
self:postFightStart()
self:enterRoundBegin()
end
function BattleController:enterRoundBegin()
self.roundStep = BattleConst.BATTLE_ROUND_STEP.ON_BEGIN
self:onRoundBegin()
self:enterEliminationBegin()
end
@ -422,14 +444,18 @@ function BattleController:enterElimination(needDelay)
end
if self.battleData:useAddlvCount() then
local skillList = self:getRandomSkillList()
if needDelay then
self.showSelectSkillSid = ModuleManager.BattleManager:performWithDelayGlobal(function()
self.battleUI:showSelectSkillComp(self:getRandomSkillList())
self.battleUI:showSelectSkillComp(skillList)
self.showSelectSkillSid = nil
end, 0.3)
else
self.battleUI:showSelectSkillComp(self:getRandomSkillList())
self.battleUI:showSelectSkillComp(skillList)
end
local totalTime = Time:getServerTime() - self.battleStartTime
BIReport:postShowFightSkillSelect(self.battleType, skillList, self.chapterId, totalTime, self.waveIndex)
else
self.battleUI:hideAllBoardSfxs()
@ -918,6 +944,9 @@ function BattleController:onLinkOver()
self:generateInstructions(skillEntity, linkElementType, lineCount, influenceElementType, elementTypeMap)
self:enterAtkStep()
end)
self.eliminateCount = self.eliminateCount + 1
self.eliminateTotalCount = self.eliminateTotalCount + 1
end
function BattleController:fillBoard()
@ -1597,6 +1626,9 @@ function BattleController:onSelectSkill(skillId, value, pos)
entity:gotUpSKill(skillId)
end
local totalTime = Time:getServerTime() - self.battleStartTime
BIReport:postFightSkillSelect(self.battleType, {skillId}, self.chapterId, totalTime, self.waveIndex)
local elementType = ModuleManager.HeroManager:getSkillRoguePosition(skillId)
if elementType then
if self.battleUI then
@ -1960,6 +1992,7 @@ function BattleController:addBattleExp(exp)
end
function BattleController:_tick(dt)
self.realTime = self.realTime + dt
if self.isPause then
return
end

View File

@ -181,4 +181,38 @@ function BattleControllerStage:controllBattleEnd()
ModuleManager.ChapterManager:endFight(self.chapterId, self.combatReport)
end
function BattleController:postWaveOver(atkDead, isQuit)
local deathType = BIReport.FIGHT_DEATH_TYPE.SURVIVE
local waveEndType = BIReport.FIGHT_WAVE_END_TYPE.WIN
if atkDead then
if self.isBossWave then
deathType = BIReport.FIGHT_DEATH_TYPE.BOSS_FAIL
else
deathType = BIReport.FIGHT_DEATH_TYPE.NORMAL_FAIL
end
waveEndType = BIReport.FIGHT_WAVE_END_TYPE.FAIL
end
if isQuit then
waveEndType = BIReport.FIGHT_WAVE_END_TYPE.QUIT
end
local duration = Time:getServerTime() - self.waveStartTime
local totalTime = Time:getServerTime() - self.battleStartTime
local startTimes = DataManager.ChapterData:getChapterFightCount(self.chapterId)
local isFirstWin = false
if not DataManager.ChapterData:getChapterPassed(self.chapterId) and self.victory then
isFirstWin = true
end
local isFianlStep = self.waveIndex >= self.maxWaveIndex
BIReport:postFightEnd(GConst.BattleConst.BATTLE_TYPE.STAGE, self.chapterId, self.waveIndex, duration, totalTime, self.eliminateCount, self.eliminateTotalCount, waveEndType, deathType, startTimes, isFirstWin, isFianlStep)
end
function BattleControllerStage:postFightStart()
local unlockMaxChapter = DataManager.ChapterData:getNewChapterId()
BIReport:postFightBegin(GConst.BattleConst.BATTLE_TYPE.STAGE, self.waveIndex, self.chapterId, unlockMaxChapter, DataManager.ChapterData:getChapterFightCount(self.chapterId))
end
return BattleControllerStage

View File

@ -15,6 +15,8 @@ function ChapterManager:openBox(chapterId, index)
GFunc.showRewardBox(result.rewards)
DataManager.ChapterData:init(result.chapterData, true)
DataManager.ChapterData:setDirty()
BIReport:postChapterOpenBox(chapterId, DataManager.ChapterData:getChapterBoxNum(chapterId, index), result.rewards)
end
end)
end
@ -68,6 +70,7 @@ function ChapterManager:endFight(id, combatReport)
}
ServerDataManager:dataOperate(GConst.ServerDataConst.DATA_OP_BEHAVIOR.END_FIGHT, parmas, function(result)
if result.status == 0 then
local maxChapter = DataManager.ChapterData:getNewChapterId()
if combatReport.victory and DataManager.ChapterData:getChapterId() == DataManager.ChapterData:getMaxChapterId() + 1 then
DataManager.ChapterData:goNextChapter()
end
@ -79,6 +82,13 @@ function ChapterManager:endFight(id, combatReport)
ModuleManager.BattleManager:showBattleResultUI(newRewards, combatReport)
DataManager.ChapterData:init(result.chapterData, true)
DataManager.ChapterData:setDirty()
local newMaxChapter = DataManager.ChapterData:getNewChapterId()
if maxChapter ~= newMaxChapter then
local data = {}
data.max_chapter = newMaxChapter
CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(data)
end
end
end)
end

View File

@ -21,18 +21,23 @@ function LoginManager:loginGame()
-- adjust 打开应用事件识别码
BIReport:postAdjustSimpleTrackEvent("xbszrl", {})
local serverTime = Time:getServerTime()
local todayBeginTime = serverTime - serverTime%86400
local now = os.date('!*t', serverTime)
Time:updateByServer(serverTime, todayBeginTime)
CS.BF.BFMain.IsGotServerTime = true
ServerDataManager:dataOperate(GConst.ServerDataConst.DATA_OP_BEHAVIOR.SYNC_DATA, GConst.EMPTY_TABLE, function(msgData)
DataManager:initWithServerData(msgData)
ConfigManager:preLoadConfig()
ModuleManager.MaincityManager:firstEnterMainCity()
-- local data = {}
-- data.max_chapter = DataManager.StageData:getNewChapterId()
local data = {}
data.max_chapter = DataManager.ChapterData:getNewChapterId()
-- data.ads_num = DataManager.PlayerData:getAdCount()
-- data.pay_money = DataManager.PlayerData:getPaymentCount()
-- data.play_days = DataManager:getLoginCount()
-- data.now_version = Platform:getClientVersion()
-- CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(data)
data.play_days = DataManager.PlayerData:getLoginDay()
data.now_version = Platform:getClientVersion()
CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(data)
end)
end

View File

@ -38,6 +38,10 @@ function LoginUI:onLoadRootComplete()
BIReport:postGameLogin(false)
end
local data = {}
data.open_num = 1
CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserAdd(data)
local copyTx = uiMap["login_ui.copy_account_tx"]
copyTx:setText(I18N:getGlobalText(I18N.GlobalConst.CLICK_COPY_ACOUNT_DESC))
copyTx:setVisible(true)

View File

@ -10,9 +10,9 @@ function MaincityManager:firstEnterMainCity()
DataManager.ChapterData:setChapterId(DataManager.ChapterData.MIN_CHAPTER_ID)
ModuleManager.BattleManager:playBattle(GConst.BattleConst.BATTLE_TYPE.STAGE)
else
BIReport:postGameLoginFinish()
self:showMainCityUI(true)
-- SDKManager:doUncompletePay()
-- BIReport:postFightBegin(ModuleManager.BattleManager.BATTLE_TYPE.STAGE, DataManager.ChapterData:getCurChapterId(), DataManager.ChapterData:getHistoryChapterId())
end
end

View File

@ -8,12 +8,26 @@ function ServerChapterData:init(data)
self.data.chapterFightInfo = data and data.chapterFightInfo or {}
end
function ServerChapterData:enterFight(id)
local idStr = tostring(id)
if not self.data.chapterFightInfo[idStr] then
self.data.chapterFightInfo[idStr] = {
victory = false,
maxWave = 0,
fightCount = 0
}
end
self.data.chapterFightInfo[idStr].fightCount = (self.data.chapterFightInfo[idStr].fightCount or 0) + 1
end
function ServerChapterData:fightChapter(id, victory, wave)
local idStr = tostring(id)
if not self.data.chapterFightInfo[idStr] then
self.data.chapterFightInfo[idStr] = {
victory = false,
maxWave = 0
maxWave = 0,
fightCount = 0
}
end

View File

@ -1,5 +1,15 @@
local ServerPlayerData = class("ServerPlayerData", ServerBaseData)
function ServerPlayerData:init(data)
self.data.loginDay = data and data.loginDay or 0
self.data.lastLoginTime = data and data.lastLoginTime or 0
Logger.logHighlight(Time:getServerTime())
if self.data.lastLoginTime < Time:getBeginningOfServerToday() then
self.data.lastLoginTime = Time:getBeginningOfServerToday()
self.data.loginDay = self.data.loginDay + 1
end
end
function ServerPlayerData:setVit(vit)
self.vit = tonumber(vit) or 0
end

View File

@ -50,6 +50,7 @@ function ServerChapterManager:startFight(params, callback)
end
return
end
ServerGameData.ChapterData:enterFight(params.id)
result.cost = ServerGameData:addCosts({cost})
result.status = 0
if callback then

View File

@ -153,6 +153,13 @@ function ServerDataManager:dealGM(params, callback)
if not id then
return
end
local cfg = ConfigManager:getConfig("chapter")
for id, info in ipairs(cfg) do
local maxWave = info.box_num[#info.box_num]
if maxWave then
ServerGameData.ChapterData:fightChapter(id, true, maxWave)
end
end
ServerGameData.ChapterData.data.maxChapterId = id
end

View File

@ -42,7 +42,7 @@ function BattlePauseUI:_addListeners()
okText = I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_OK),
cancelText = I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_CANCEL),
okFunc = function()
ModuleManager.BattleManager:endBattleAndExit()
ModuleManager.BattleManager:endBattleAndExit(true)
end,
}
GFunc.showMessageBox(params)

View File

@ -16,6 +16,7 @@ end
function MainComp:initChapter()
self.chapterImg = self.uiMap["main_comp.chapter.img"]
self.chapterNameTx = self.uiMap["main_comp.chapter.name_tx"]
self.chapterWavetx = self.uiMap["main_comp.chapter.record_tx"]
self.leftArrow = self.uiMap["main_comp.chapter.left_arrow"]
local leftArrowBtn = self.uiMap["main_comp.chapter.left_arrow.btn"]
leftArrowBtn:addClickListener(function()
@ -88,6 +89,7 @@ function MainComp:refreshChapter(force)
if chapterI18NInfo then
self.chapterNameTx:setText(chapterI18NInfo.name)
end
self.chapterWavetx:setText(I18N:getGlobalText(I18N.GlobalConst.CHAPTER_DESC_1, DataManager.ChapterData:getChapterMaxWave()))
local slider = self.uiMap["main_comp.chapter.progress_bg.slider"]
if not self.boxObjs then

View File

@ -21,16 +21,15 @@ function ItemData:init(data)
data = data or {}
if data.items then
for _, info in pairs(data.items) do
-- if info.id == GConst.ItemConst.ITEM_ID_GEM then
-- local parmas = {}
-- parmas.gem = BigNumOpt.bigNum2Num(info.count)
-- CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(parmas)
-- elseif info.id == GConst.ItemConst.ITEM_ID_GOLD then
-- local parmas = {}
-- parmas.gold_value = info.count
-- parmas.gold_unit = info.count
-- CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(parmas)
-- end
if info.id == GConst.ItemConst.ITEM_ID_GEM then
local parmas = {}
parmas.gem = info.count
CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(parmas)
elseif info.id == GConst.ItemConst.ITEM_ID_GOLD then
local parmas = {}
parmas.gold = info.count
CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(parmas)
end
if info.cfg_id == GConst.ItemConst.ITEM_ID_VIT then
DataManager.PlayerData:setVit(info.count)
end
@ -146,41 +145,46 @@ function ItemData:addItem(data, itemGetType)
self:_addItemNumById(data.cfg_id, data.count)
-- if data.cfg_id == GConst.ItemConst.ITEM_ID_GEM or data.cfg_id == GConst.ItemConst.ITEM_ID_GOLD then
-- if data.count < 0 then
-- if data.cfg_id == GConst.ItemConst.ITEM_ID_GOLD and itemGetType == BIReport.ITEM_GET_TYPE.TRAIN_UP then
-- else
-- BIReport:postGemUse(data.count, itemGetType, data.cfg_id)
-- if data.cfg_id == GConst.ItemConst.ITEM_ID_GEM then
-- CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserAdd("gem", data.count)
-- elseif data.cfg_id == GConst.ItemConst.ITEM_ID_GOLD then
-- local goldNum = DataManager.BagData.ItemData:getItemNumById(GConst.ItemConst.ITEM_ID_GOLD)
-- local parmas = {}
-- parmas.gold = goldNum
-- CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(parmas)
-- end
-- end
-- else
-- if data.cfg_id == GConst.ItemConst.ITEM_ID_GOLD and itemGetType == BIReport.ITEM_GET_TYPE.CHAPTER_DROP then
-- else
-- BIReport:postGemGet(data.count, itemGetType, data.cfg_id)
-- if data.cfg_id == GConst.ItemConst.ITEM_ID_GEM then
-- CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserAdd("gem", data.count)
-- elseif data.cfg_id == GConst.ItemConst.ITEM_ID_GOLD then
-- local goldNum = DataManager.BagData.ItemData:getItemNumById(GConst.ItemConst.ITEM_ID_GOLD)
-- local parmas = {}
-- parmas.gold = goldNum
-- CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(parmas)
-- end
-- end
-- end
-- else
-- if data.count < 0 then
-- BIReport:postItemUse(data.count, data.cfg_id, itemGetType)
-- else
-- BIReport:postItemGet(data.count, data.cfg_id, itemGetType)
-- end
-- end
if data.cfg_id == GConst.ItemConst.ITEM_ID_GEM or data.cfg_id == GConst.ItemConst.ITEM_ID_GOLD then
if data.count < 0 then
BIReport:postGemUse(data.count, itemGetType, data.cfg_id)
if data.cfg_id == GConst.ItemConst.ITEM_ID_GEM then
CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserAdd("gem", data.count)
elseif data.cfg_id == GConst.ItemConst.ITEM_ID_GOLD then
local goldNum = DataManager.BagData.ItemData:getItemNumById(GConst.ItemConst.ITEM_ID_GOLD)
local parmas = {}
parmas.gold = goldNum
CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(parmas)
end
else
BIReport:postGemGet(data.count, itemGetType, data.cfg_id)
if data.cfg_id == GConst.ItemConst.ITEM_ID_GEM then
CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserAdd("gem", data.count)
elseif data.cfg_id == GConst.ItemConst.ITEM_ID_GOLD then
local goldNum = DataManager.BagData.ItemData:getItemNumById(GConst.ItemConst.ITEM_ID_GOLD)
local parmas = {}
parmas.gold = goldNum
CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(parmas)
end
end
if data.cfg_id == GConst.ItemConst.ITEM_ID_GEM then
CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserAdd("user_gem", data.count)
elseif data.cfg_id == GConst.ItemConst.ITEM_ID_GOLD then
CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserAdd("user_gold", data.count)
end
elseif data.cfg_id == GConst.ItemConst.ITEM_ID_VIT then
if data.count < 0 then
BIReport:postVitUse(data.count)
else
BIReport:postVitGet(data.count, itemGetType)
end
else
if data.count < 0 then
BIReport:postItemUse(data.count, data.cfg_id, itemGetType)
else
BIReport:postItemGet(data.count, data.cfg_id, itemGetType)
end
end
end
function ItemData:addItemNumById(id, num, itemGetType)

View File

@ -66,6 +66,10 @@ function ChapterData:getNextChapter(chapterId)
return chapterInfo.next_chapter
end
function ChapterData:getNewChapterId()
return self:getNextChapter(self:getMaxChapterId())
end
function ChapterData:isFinalChapter(chapterId)
local chapterInfo = self:getChapterCfg()[chapterId]
if chapterInfo == nil then
@ -170,6 +174,15 @@ function ChapterData:getChapterMaxWave(chapterId)
return 0
end
function ChapterData:getChapterFightCount(chapterId)
chapterId = tostring(chapterId or self:getChapterId())
if self.data.chapterFightInfo[chapterId] then
return self.data.chapterFightInfo[chapterId].fightCount or 0
end
return 0
end
function ChapterData:getFightCost()
return GFunc.getConstReward("chapter_cost")
end
@ -233,4 +246,13 @@ function ChapterData:getIsHaveRewards(chapterId)
return false
end
function ChapterData:getChapterPassed(chapterId)
chapterId = tostring(chapterId or self:getChapterId())
if self.data.chapterFightInfo[chapterId] then
return self.data.chapterFightInfo[chapterId].victory or false
end
return false
end
return ChapterData

View File

@ -1,6 +1,9 @@
local PlayerData = class("PlayerData", BaseData)
function PlayerData:init(data)
data = data or {}
self.loginDay = data.loginDay or 1
self.lastLoginTime = data.lastLoginTime or Time:getBeginningOfServerToday()
end
function PlayerData:setVit(vit)
@ -18,4 +21,8 @@ function PlayerData:getMaxVit()
return self.maxVit
end
function PlayerData:getLoginDay()
return self.loginDay
end
return PlayerData