限时pvp数据层

This commit is contained in:
xiekaidong 2023-09-13 17:01:17 +08:00
parent 577d7392e2
commit 1e30641b76
15 changed files with 882 additions and 5 deletions

View File

@ -154,6 +154,14 @@ BIReport.ITEM_GET_TYPE = {
DUNGEON_RUNE_SETTLEMENT = "DungeonRuneSettlement",
DUNGEON_RUNE_SWEEP = "DungeonRuneSweep",
DUNGEON_RUNE_BUY_WING = "DungeonRunebuyWing",
ACT_PVP_ENTER = "ActPvpEnter",
ACT_PVP_REFRESH_HERO = "ActPvpRefreshHero",
ACT_PVP_FIGHT_END = "ActPvpFightEnd",
ACT_PVP_OVER_CD = "ActPvpOverCd",
ACT_PVP_DAILY_REWARD = "ActPvpDailyReward",
ACT_PVP_BOUNTY = "ActPvpBounty",
ACT_PVP_RANK_REWARD = "ActPvpRankReward",
ACT_PVP_BUY_BOUNTY_LEVEL = "ActPvpBuyBountyLevel",
}
BIReport.ADS_CLICK_TYPE = {
@ -205,6 +213,7 @@ BIReport.BATTLE_TYPE = {
["7"] = "DungeonArmor",
["8"] = "ActBossRush",
["9"] = "DungeonRune",
["10"] = "ActPvp",
}
BIReport.GIFT_TYPE = {

View File

@ -36,6 +36,7 @@ function DataManager:init()
self:initManager("HeroFundData", "app/userdata/activity/hero_fund/hero_fund_data")
self:initManager("ActBossRushData", "app/userdata/activity/act_boss_rush/act_boss_rush_data")
self:initManager("FourteenDayData", "app/userdata/activity/fourteen_day/fourteen_day_data")
self:initManager("ActPvpData", "app/userdata/activity/act_pvp/act_pvp_data")
end
function DataManager:initManager(name, path)
@ -124,6 +125,7 @@ function DataManager:clear()
self.HeroFundData:clear()
self.ActBossRushData:clear()
self.FourteenDayData:clear()
self.ActPvpData:clear()
ModuleManager.TaskManager:clear()
self:clearTryOpenFunc()
self.activityBountyLevelMap = nil
@ -482,14 +484,24 @@ DataManager.activityOpenFunc = {
[2] = function(params)
ModuleManager.ActBossRushManager:reqActData()
DataManager.ActBossRushData:setActivityInfo(params)
end
end,
[3] = function(params)
ModuleManager.ActPvpManager:reqActData()
DataManager.ActPvpData:setActivityId(params.id)
DataManager.ActPvpData:setActivityInfo(params)
end,
}
DataManager.waitOpenActivity = {
[2] = function(params)
DataManager.ActBossRushData:init({activity_id = params.id}) -- 默认初始化
DataManager.ActBossRushData:setActivityInfo(params)
end
end,
[3] = function(params)
DataManager.ActPvpData:init({}) -- 默认初始化
DataManager.ActPvpData:setActivityId(params.id)
DataManager.ActPvpData:setActivityInfo(params)
end,
}
return DataManager

View File

@ -77,6 +77,8 @@ local MODULE_PATHS = {
FourteenDayManager = "app/module/activity/fourteen_day/fourteen_day_manager",
-- 符文副本
DungeonRuneManager = "app/module/dungeon_rune/dungeon_rune_manager",
-- 梦魇酒馆
ActPvpManager = "app/module/activity/act_pvp/act_pvp_manager",
}
-- 这里的key对应func_open里的id

View File

@ -539,6 +539,9 @@ local localization_global =
["DUNGEON_RUNE_DESC_9"] = "上赛季",
["DUNGEON_RUNE_DESC_10"] = "最高:{0}",
["DUNGEON_RUNE_DESC_11"] = "回合数:{0}",
["ACT_PVP_DESC_1"] = "是否消耗{0}钻石进入酒馆",
}
return localization_global

View File

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

View File

@ -0,0 +1,244 @@
local ActPvpManager = class("ActPvpManager", BaseModule)
function ActPvpManager:showMainUI()
if DataManager.ActPVPData:getNeedUpdateData() then
self:reqActData()
end
UIManager:showUI("")
end
function ActPvpManager:reqActData()
self:sendMessage(ProtoMsgType.FromMsgEnum.ActivityPVPDataReq, {}, {}, self.rspActData)
end
function ActPvpManager:rspActData(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
DataManager.ActPVPData:updateData(result.activity_pvp)
end
end
function ActPvpManager:reqEnter()
if DataManager.ActPvpData:getFreeEnterCount() <= 0 then
local cost = DataManager.ActivityData:getEnterCost()
if not GFunc.checkCost(cost.id, cost.num, true) then
return
end
local params ={
content = I18N:getGlobalText(I18N.GlobalConst.ACT_PVP_DESC_1, cost.num),
boxType = GConst.MESSAGE_BOX_TYPE.MB_OK_CANCEL,
costId = cost.id,
costNum = cost.num,
okFunc = function()
self:sendMessage(ProtoMsgType.FromMsgEnum.ActivityPVPBeginReq, {}, {}, self.rspEnter, BIReport.ITEM_GET_TYPE.ACT_PVP_ENTER)
end,
}
GFunc.showMessageBox(params)
end
self:sendMessage(ProtoMsgType.FromMsgEnum.ActivityPVPBeginReq, {}, {}, self.rspEnter, BIReport.ITEM_GET_TYPE.ACT_PVP_ENTER)
end
function ActPvpManager:rspEnter(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
DataManager.ActPVPData:updateData(result.activity_pvp)
end
end
function ActPvpManager:reqDecideHero(index)
--int32 index = 1; // 0. 左边的、1.右边的
local params = {
index = index
}
self:sendMessage(ProtoMsgType.FromMsgEnum.ActivityPVPDecideHeroReq, params, {}, self.rspDecideHero)
end
function ActPvpManager:rspDecideHero(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
DataManager.ActPvpData:updateHerosInfo(result.heroes, result.pair_id, result.next_select_four_id)
end
end
function ActPvpManager:reqRefreshHero()
self:sendMessage(ProtoMsgType.FromMsgEnum.ActivityPVPFlushHeroesReq, {}, {}, self.rspRefreshHero, BIReport.ITEM_GET_TYPE.ACT_PVP_REFRESH_HERO)
end
function ActPvpManager:rspRefreshHero(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
DataManager.ActPvpData:updateSelectInfo(result.pair_id, result.next_select_four_id)
end
end
function ActPvpManager:reqMatch()
self:sendMessage(ProtoMsgType.FromMsgEnum.ActivityPVPMatchReq, {}, {}, self.rspMatch)
end
function ActPvpManager:rspMatch(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
DataManager.ActPvpData:updateRivalInfo(result.rival, result.match_cd_end_at)
end
end
function ActPvpManager:reqOverCD(isAd)
if not isAd then
local cost = DataManager.ActPvpData:getRematchConstGem()
if not GFunc.checkCost(GConst.ItemConst.ITEM_ID_GEM, cost, true) then
return
end
local params ={
content = I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_25, cost),
boxType = GConst.MESSAGE_BOX_TYPE.MB_OK_CANCEL,
costId = GConst.ItemConst.ITEM_ID_GEM,
costNum = cost,
okFunc = function()
self:sendMessage(ProtoMsgType.FromMsgEnum.ActivityPVPOverCDReq, {ad = isAd}, {}, self.rspOverCD, BIReport.ITEM_GET_TYPE.ACT_PVP_OVER_CD)
end,
}
GFunc.showMessageBox(params)
return
end
self:sendMessage(ProtoMsgType.FromMsgEnum.ActivityPVPOverCDReq, {ad = isAd}, {}, self.rspOverCD, BIReport.ITEM_GET_TYPE.ACT_PVP_OVER_CD)
end
function ActPvpManager:rspOverCD(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
DataManager.ActPvpData:setMatchCdEndAt()
self:reqMatch()
end
end
function ActPvpManager:reqFight()
self:sendMessage(ProtoMsgType.FromMsgEnum.ActivityPVPStartReq, {}, {}, self.rspFight)
end
function ActPvpManager:rspFight(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
local atkFormation = {}
local defFormation
-- if result.reqData and result.reqData.defInfo then
-- defFormation = GFunc.formatPlayerFormationInfo(result.reqData.defInfo)
-- else
-- return
-- end
-- for idx, id in pairs(DataManager.FormationData:getArenaAttackFormation()) do
-- local hero = DataManager.HeroData:getHeroById(id)
-- if hero then
-- atkFormation[idx] = hero
-- end
-- end
local params = {
defInfo = result.reqData.defInfo,
atkFormation = atkFormation,
defFormation = defFormation
}
ModuleManager.BattleManager:playBattle(GConst.BattleConst.BATTLE_TYPE.ACT_PVP, params)
end
end
function ActPvpManager:reqFightEnd(win, battleReport, taskProgress)
local parmas = {
win = win,
task_stat = taskProgress,
battleReport = battleReport,
}
self:sendMessage(ProtoMsgType.FromMsgEnum.ActivityPVPSettlementReq, parmas, {}, self.rspFightEnd, BIReport.ITEM_GET_TYPE.ACT_PVP_FIGHT_END)
end
function ActPvpManager:rspFightEnd(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
DataManager.ActPVPData:updateData(result.activity_pvp)
-- 展示结算界面
-- ModuleManager.BattleManager:showArenaBattleResultUI(result.settlement, result.rewards, checkCount)
if result.reqData then
local taskStat = result.reqData.task_stat
if taskStat then
taskStat[GConst.BattleConst.BATTLE_TASK_FIELD.KILL_BOSS] = 0 -- boss不算
taskStat[GConst.BattleConst.BATTLE_TASK_FIELD.KILL_NORMAL_MONSTER] = 0 -- 击杀小怪数量不算
taskStat[GConst.BattleConst.BATTLE_TASK_FIELD.PASS_WAVE] = 0 -- 通关波数不算
ModuleManager.TaskManager:addFightTaskProgress(taskStat)
end
end
end
end
function ActPvpManager:reqDailyReward(index)
local params = {
id = index
}
self:sendMessage(ProtoMsgType.FromMsgEnum.ActivityPVPDailyRewardsReq, params, {}, self.rspDailyReward, BIReport.ITEM_GET_TYPE.ACT_PVP_DAILY_REWARD)
end
function ActPvpManager:rspDailyReward(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
if result.reqData then
DataManager.ActPvpData:setDailyReward(result.reqData.id)
end
GFunc.showRewardBox(result.rewards)
end
end
function ActPvpManager:reqRank()
self:sendMessage(ProtoMsgType.FromMsgEnum.ActivityPVPRankReq, {}, {}, self.rspRank)
end
function ActPvpManager:rspRank(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
DataManager.ActPvpData:updateRankInfo(result.ranks, result.own_rank)
end
end
function ActPvpManager:reqRankReward()
self:sendMessage(ProtoMsgType.FromMsgEnum.ActivityPVPRankRewardsReq, {}, {}, self.rspRankReward, BIReport.ITEM_GET_TYPE.ACT_PVP_RANK_REWARD)
end
function ActPvpManager:rspRankReward(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
DataManager.ActPvpData:setGotRankReward()
GFunc.showRewardBox(result.rewards)
end
end
function ActPvpManager:reqBountyReward(id, bountyType)
local typeNum = DataManager.ActPvpData.FUND_TYPE_TO_NUM[bountyType]
if not typeNum then
return
end
local params = {
id = id,
grade = typeNum
}
self:sendMessage(ProtoMsgType.FromMsgEnum.ActivityPVPBountyClaimReq, params, {}, self.rspBountyReward, BIReport.ITEM_GET_TYPE.ACT_PVP_BOUNTY)
end
function ActPvpManager:rspBountyReward(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
if result.reqData then
DataManager.ActPvpData:gotSingleFundReward(result.reqData.id, result.reqData.grade)
end
GFunc.showRewardBox(result.rewards)
end
end
function ActPvpManager:reqBuyBountyLevel()
local level = DataManager.ActPvpData:getFundLevel()
if level + 1 > DataManager.ActPvpData:getMaxFundLevel() then
return
end
local params = {
id = level
}
self:sendMessage(ProtoMsgType.FromMsgEnum.ActivityPVPBountyClaimByDiamondReq, params, {}, self.rspBuyBountyLevel, BIReport.ITEM_GET_TYPE.ACT_PVP_BUY_BOUNTY_LEVEL)
end
function ActPvpManager:rspBuyBountyLevel(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
DataManager.ActPvpData:setFundLevel(result.reqData.id)
end
end
return ActPvpManager

View File

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

View File

@ -90,6 +90,7 @@ BattleConst.BATTLE_TYPE = {
DUNGEON_ARMOR = "7",
ACT_BOSS_RUSH = "8",
DUNGEON_RUNE = "9",
ACT_PVP = "10",
}
BattleConst.IS_PVP_BATTLE = {

View File

@ -1177,6 +1177,7 @@ function BattleBaseController:checkTeamIsDead(callback, falseCallback)
local defTeam = self.battleData:getDefTeam()
local atkTeam = self.battleData:getAtkTeam()
if atkTeam:getIsDead() and defTeam:getIsDead() then -- 都死了,直接结算
self.curWaveMonsterDead = true
self:enterNextWave()
return true
end

View File

@ -0,0 +1,199 @@
local BattleControllerPVP = require "app/module/battle/controller/battle_controller_pvp"
local BattleControllerActpvp = class("BattleControllerActpvp", BattleControllerPVP)
local BattleBuffEntity = require "app/userdata/battle/skill/battle_buff_entity"
function BattleControllerActpvp:getBoardConfig()
return ConfigManager:getConfig("actvity_pvp_board")
end
function BattleControllerActpvp:getChapterConfig()
return ConfigManager:getConfig("actvity_pvp_board")
end
function BattleControllerActpvp:getChapterId()
return 1
end
function BattleControllerActpvp:getBlockIcon()
return "battle_hinder_4"
end
function BattleControllerActpvp:getChessBoardBgName()
return "chessboard_1"
end
function BattleControllerActpvp:getScene()
return "bg_1"
end
function BattleControllerActpvp:getBuffs()
if not self.initBuffs then
self.initBuffs = {}
local buffList = {}
local effect = {
{
["type"]="hpp_add",
["num"]=10000,
["ratio"]=10000,
["round"]=0
},
{
["type"]="end_dmg_dec_all_add",
["num"]=8000,
["ratio"]=10000,
["round"]=0
}
}
for _, effect in ipairs(effect) do
local atkBuffInfo = {
buff = GFunc.getTable(effect),
obj = GConst.BattleConst.SIDE_ATK
}
local defBuffInfo = {
buff = GFunc.getTable(effect),
obj = GConst.BattleConst.SIDE_DEF
}
table.insert(buffList, atkBuffInfo)
table.insert(buffList, defBuffInfo)
end
for _, info in ipairs(buffList) do
local buffEntity = BattleBuffEntity:create()
buffEntity:init(info.buff)
buffEntity:setTargetSide(info.obj)
buffEntity:setIsCantRemove(true)
buffEntity:setNotShowIcon(true)
table.insert(self.initBuffs, {buffEntity = buffEntity, effect = info.buff})
end
end
return self.initBuffs
end
-- 战斗结束
function BattleControllerActpvp:controllBattleEnd()
self.combatReport = {
battleType = GConst.BattleConst.BATTLE_TYPE.ACT_PVP,
wave = self:getWaveIndex(),
victory = self.victory,
round = self.waveRoundCount[self:getWaveIndex()] or 0
}
local atkReport = {}
local teamEntity = self.battleData:getAtkTeam()
local members = teamEntity:getAllMembers()
for k, v in pairs(members) do
local report = {
heroId = v:getId(),
dmg = v:getDamageCount(),
}
table.insert(atkReport, report)
end
self.combatReport.atkReport = atkReport
local defReport = {}
local teamEntity = self.battleData:getDefTeam()
local members = teamEntity:getAllMembers()
for k, v in pairs(members) do
local report = {
heroId = v:getId(),
dmg = v:getDamageCount(),
}
table.insert(defReport, report)
end
self.combatReport.defReport = defReport
local win = self.victory
ModuleManager.ArenaManager:reqSettlement(win, self.combatReport, self.taskProgress)
end
-- 一共有多少波
function BattleControllerActpvp:getMaxWave()
return 1
end
function BattleControllerActpvp:getMaxRoundCount()
if not self.arenaMaxRound then
self.arenaMaxRound = GFunc.getConstIntValue("arena_max_round")
end
return self.arenaMaxRound
end
function BattleControllerActpvp:findNextDefUnit()
self:enterRoundEnd(true)
end
function BattleControllerActpvp: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 = self.waveDurationTime
local totalTime = self.totalDurationTime
local startTimes = DataManager.ActPvpData:getTotalFightCount()
local isFirstWin = false
local isFianlStep = self:getWaveIndex() >= self.maxWaveIndex
BIReport:postFightEnd(GConst.BattleConst.BATTLE_TYPE.ACT_PVP, self.battleData, self.chapterId, self:getWaveIndex(), duration, totalTime, self.eliminateCount, self.eliminateTotalCount, waveEndType, deathType, startTimes, isFirstWin, isFianlStep, self.maxLinkCount)
end
function BattleControllerActpvp:postFightStart()
local startTimes = DataManager.ActPvpData:getTotalFightCount()
BIReport:postFightBegin(GConst.BattleConst.BATTLE_TYPE.ACT_PVP, self:getWaveIndex(), self.chapterId, self.chapterId, startTimes)
end
function BattleControllerActpvp:getAtkMinRow()
return GConst.BattleConst.PVP_ROW_COUNT // 2
end
function BattleControllerActpvp:getInitBoard()
if not self.boradList then
self.boradList = {}
self.fixedRandomGrid = {}
self.mysteryBoxIndexMap = {}
local boardCfg = self:getBoardConfig()
local num = #boardCfg
local boardId = math.random(1, num)
local cfg = boardCfg[boardId]
if cfg then
local board = GFunc.getTable(cfg.board)
for index, info in ipairs(board) do
if info[2] == GConst.BattleConst.ELEMENT_TYPE.NONE then
board[index][2] = math.random(1, GConst.BattleConst.ELEMENT_TYPE_COUNT)
end
end
table.insert(self.boradList, {board = board, mysteryBoard = GFunc.getTable(cfg.mystery_box_board), gridEdge = GFunc.getTable(cfg.grid_edge)})
table.insert(self.fixedRandomGrid, GFunc.getTable(cfg.control_element))
end
end
return self.boradList, self.fixedRandomGrid, self.mysteryBoxIndexMap
end
function BattleControllerActpvp:onTouchEvent(eventType, posId, isVirtual)
local isAtkAction = self.curActionSide == GConst.BattleConst.SIDE_ATK
local r = ModuleManager.BattleManager:getPosRC(posId).r
if isAtkAction then
if r <= self:getAtkMinRow() then
return
end
else
if r > self:getAtkMinRow() then
return
end
end
BattleControllerPVP.onTouchEvent(self, eventType, posId, isVirtual)
end
return BattleControllerActpvp

View File

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

View File

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

View File

@ -0,0 +1,358 @@
local ACT_ID = 306
local ActPvpData = class("ActPvpData", BaseData)
ActPvpData.FUND_TYPE = {
NORMAL = "normal",
SUPERIOR = "superior",
SUPERIOR_MAX = "superior_max"
}
ActPvpData.FUND_TYPE_TO_NUM = {
[ActPvpData.FUND_TYPE.NORMAL] = 0,
[ActPvpData.FUND_TYPE.SUPERIOR] = 1,
[ActPvpData.FUND_TYPE.SUPERIOR_MAX] = 2
}
function ActPvpData:ctor()
self.data.isDirty = false
self.playing = false
self.enterCountDaily = 0
self.totalFightCount = 0
self.totalWinCount = 0
self.winCount = 0
self.loseCount = 0
self.heroeAndSkins = {}
self.currentSelectPairId = {}
self.nextSelectFourId = {}
self.matchCdEndAt = 0
self.rivalInfo = {}
self.dailyRewards = {}
self.gotRankRewards = false
self.exp = 0
self.level = 0
self.collected = {}
end
function ActPvpData:setActivityInfo(activity)
self.startTime = GFunc.formatTimeStep(activity.start_at)
self.endTime = GFunc.formatTimeStep(activity.end_at)
end
function ActPvpData:setActivityId(actId)
self.activity_id = actId
end
function ActPvpData:setDirty()
self.data.isDirty = not self.data.isDirty
end
function ActPvpData:clear()
DataManager:unregisterCrossDayFunc("ActPvpData")
end
function ActPvpData:init(data)
if not data.enter_count_daily then -- 没数据
self:setNeedUpdate(false)
else
self:updateData(data)
end
DataManager:registerCrossDayFunc("ActPvpData", function()
self.playing = false
self.enterCountDaily = 0
self.winCount = 0
self.loseCount = 0
self.heroeAndSkins = {}
self.currentSelectPairId = {}
self.nextSelectFourId = {}
self.matchCdEndAt = 0
self.rivalInfo = {}
self.dailyRewards = {}
self:setDirty()
end)
end
function ActPvpData:updateData(data)
self:setNeedUpdate(false)
self.playing = data.playing
self.enterCountDaily = data.enter_count_daily
self.totalWinCount = data.total_win_count
self.winCount = data.win_count
self.loseCount = data.lose_count
self.matchCdEndAt = GFunc.formatTimeStep(data.match_cd_end_at)
self.rivalInfo = data.rival_info
self.dailyRewards = data.daily_rewards
self.gotRankRewards = data.rank_rewards
self.exp = data.exp
self.level = data.level
self.collected = data.collected
self:updateHerosInfo(data.heroes, data.current_select_pair_id, data.next_select_four_id)
self:setDirty()
end
function ActPvpData:getConditionDay()
if not self.conditionDay then
self.conditionDay = GFunc.getConstIntValue('activity_recurring_day')
self.conditionDay = (self.conditionDay - 1) * 86400
end
return self.conditionDay
end
function ActPvpData:getIsOpen()
if not ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.ACTIVITY, true) then
return false
end
if Time:getServerTime() <= DataManager:getRegisterTs() + self:getConditionDay() then -- 前14天的号看不到
return false
end
local time = Time:getServerTime()
return self.endTime > time and time > self.startTime
end
function ActPvpData:isPlaying()
return self.playing
end
function ActPvpData:getEnterCount()
return self.enterCountDaily
end
function ActPvpData:getFreeEnterLimit()
if not self.freeEnterLimit then
self.freeEnterLimit = GFunc.getConstIntValue("activity_pvp_time")
end
return self.freeEnterLimit
end
function ActPvpData:getFreeEnterCount()
return self:getFreeEnterLimit() - self:getEnterCount()
end
function ActPvpData:getEnterCost()
if not self.enterBaseCost then
self.enterBaseCost = GFunc.getConstReward("activity_pvp_cost")
end
if self.enterAddCost then
self.enterCost = GFunc.getConstReward("activity_pvp_costadd")
end
if not self.enterCost then
self.enterCost = GFunc.getTable(self.enterBaseCost)
end
local count = self:getFreeEnterCount()
if count > 0 then
self.enterCost.num = 0
else
count = 0 - count
self.enterCost.num = self.enterBaseCost.num + self.enterAddCost.num * count
end
return self.enterCost
end
function ActPvpData:getWinCount()
return self.winCount
end
function ActPvpData:getWinLimit()
if not self.winLimit then
self.winLimit = GFunc.getConstIntValue("activity_pvp_win_times")
end
return self.winLimit
end
function ActPvpData:getLoseCount()
return self.loseCount
end
function ActPvpData:getLoseLimit()
if not self.loseLimit then
self.loseLimit = GFunc.getConstIntValue("activity_pvp_lose_times")
end
return self.loseLimit
end
function ActPvpData:updateHerosInfo(heroes, pairIds, nextSelectFourId)
if heroes then
self.heroEntities = {}
local maxlv = ConfigManager:getConfigNum("hero_level")
for heroId, skinId in pairs(heroes) do
if DataManager.HeroData:isExistHeroById(heroId) then
local level = math.min(6 + self.winLimit, maxlv)
local heroEntity = DataManager.HeroData:getEntity({id = heroId, level = level, skin = skinId})
heroEntity:setSkins({skinId})
self.heroEntities[heroEntity:getMatchType()] = heroEntity
end
end
end
self:updateSelectInfo(pairIds, nextSelectFourId)
end
function ActPvpData:updateSelectInfo(pairIds, nextSelectFourId)
self.currentSelectPairId = pairIds
self.nextSelectFourId = nextSelectFourId
self:setDirty()
end
function ActPvpData:getHeros()
return self.heroEntities or {}
end
function ActPvpData:getCurSelectPairId()
return self.currentSelectPairId
end
function ActPvpData:getNextSelectFourId()
return self.nextSelectFourId
end
function ActPvpData:getRematchConstGem()
return GFunc.getConstIntValue("arena_refresh_cost")
end
function ActPvpData:updateRivalInfo(rivalInfo, endCd)
self.rivalInfo = rivalInfo
self.matchCdEndAt = GFunc.formatTimeStep(endCd)
end
function ActPvpData:getRivalInfo()
return self.rivalInfo
end
function ActPvpData:getMatchCdEndAt()
return self.matchCdEndAt
end
function ActPvpData:setMatchCdEndAt()
self.matchCdEndAt = Time:getServerTime()
end
function ActPvpData:getNeedReMatch()
if not self.rivalInfo or not self.rivalInfo.level then
return true
end
return false
end
function ActPvpData:gotDailyReward(id)
for _, gotId in ipairs(self.dailyRewards) do
if gotId == id then
return true
end
end
return false
end
function ActPvpData:setDailyReward(id)
table.insert(self.dailyRewards, id)
end
function ActPvpData:getFundExp()
return self.exp
end
function ActPvpData:getFundLevel()
return self.level
end
function ActPvpData:setFundLevel(level)
self.level = level
self:setDirty()
end
function ActPvpData:getMaxFundLevel()
self:getBountyList()
return self.maxFundLv
end
function ActPvpData:getBountyCfg()
return ConfigManager:getConfig("activity_bounty_level")
end
function ActPvpData:getBountyList()
if not self.bountyList then
self.bountyList = GFunc.getTable(DataManager:getActivityBountyLevelByActId(self.activity_id or ACT_ID) or {})
table.sort(self.bountyList, function(a, b)
return a < b
end)
self.maxFundLv = #self.bountyList
end
return self.bountyList
end
function ActPvpData:getFundCollected(id, fundType)
if not self.collected[id] then
return false
end
return self.collected[id][fundType]
end
function ActPvpData:setFundCollected(idGrades)
if not idGrades then
return
end
for id, grade in ipairs(idGrades) do
if not self.collected[id] then
self.collected[id] = {}
end
if grade == 0 then
self.collected[id][ActPvpData.FUND_TYPE.NORMAL] = true
elseif grade == 1 then
self.collected[id][ActPvpData.FUND_TYPE.SUPERIOR] = true
elseif grade == 2 then
self.collected[id][ActPvpData.FUND_TYPE.SUPERIOR_MAX] = true
end
end
end
function ActPvpData:getTotalFightCount()
return self.totalFightCount
end
function ActPvpData:getTotalWinCount()
return self.totalWinCount
end
function ActPvpData:getNeedUpdateData()
return self.needUpdateData
end
function ActPvpData:setNeedUpdate(need)
self.needUpdateData = need
end
function ActPvpData:updateRankInfo(ranks, selfRank)
self.rankList = ranks
self.selfRank = selfRank
self.lastUpdateRankTs = Time:getServerTime()
end
function ActPvpData:getRankList()
return self.rankList or {}
end
function ActPvpData:getSelfRank()
return self.selfRank or 0
end
function ActPvpData:getNeedUpdateRank()
if not self.lastUpdateRankTs then
return true
end
return (Time:getServerTime() - self.lastUpdateRankTs) > 10 -- 10秒拉一次
end
function ActPvpData:getGotRankReward()
return self.gotRankRewards
end
function ActPvpData:setGotRankReward()
self.gotRankRewards = true
self:setDirty()
end
return ActPvpData

View File

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

View File

@ -230,7 +230,7 @@ function HeroEntity:getTotalAttrValue(name)
return GFunc.decryptNumber(self.allAttr[name])
end
function HeroEntity:setLv(lv)
function HeroEntity:setLv(lv, onlyChangeLv)
if not lv then
return
end
@ -241,8 +241,10 @@ function HeroEntity:setLv(lv)
self:updateAllAttr()
self:setDirty()
ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_HERO_LV_UP, lv)
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.HERO_UPGRADE_SUCCESS, self:getCfgId())
if not onlyChangeLv then
ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_HERO_LV_UP, lv)
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.HERO_UPGRADE_SUCCESS, self:getCfgId())
end
end
function HeroEntity:getCfgId()