c1_lua/lua/app/userdata/dungeon/dungeon_weapon_entity.lua
2023-07-19 16:52:28 +08:00

160 lines
3.8 KiB
Lua

local DungeonBaseEntity = require "app/userdata/dungeon/dungeon_base_entity"
local DungeonWeaponEntity = class("DungeonWeaponEntity", DungeonBaseEntity)
local GET_PASS_INFO_INTERVAL = 600
-- 支线副本数据
function DungeonWeaponEntity:init(data)
self.maxPassedId = data.max_challenge_id
self.farmCount = data.farm_count
self.heroes = data.heroes
self.giftInfo = data.gift_info
self.totalChallengeCount = data.total_challenge_count
self.data.isDirty = not self.data.isDirty
end
function DungeonWeaponEntity:setDirty()
self.data.isDirty = not self.data.isDirty
end
function DungeonWeaponEntity:getTotalChallengeCount()
return self.totalChallengeCount
end
function DungeonWeaponEntity:getTodayChallengeCount()
return 0
end
function DungeonWeaponEntity:getPassedMaxId()
return self.maxPassedId
end
function DungeonWeaponEntity:getIsAllTimeOpen()
return true
end
function DungeonWeaponEntity:getModuleKey()
return ModuleManager.MODULE_KEY.DUNGEON_WEAPON
end
function DungeonWeaponEntity:getConfigName()
return "chapter_dungeon_equip"
end
function DungeonWeaponEntity:getTitleString()
return I18N:getGlobalText(I18N.GlobalConst.DUNGEON_WEAPON_DESC_1)
end
function DungeonWeaponEntity:getRuleString()
return I18N:getGlobalText(I18N.GlobalConst.DUNGEON_WEAPON_DESC_2)
end
function DungeonWeaponEntity:getOpenWeekString()
return I18N:getGlobalText(I18N.GlobalConst.DUNGEON_WEAPON_DESC_3)
end
function DungeonWeaponEntity:getBanner()
return "assets/arts/textures/background/dungeon/dungeon_bg_3.png"
end
function DungeonWeaponEntity:getOpenTextColor()
return "#FFEDC5"
end
function DungeonWeaponEntity:getChallengeHpCost()
return GFunc.getConstReward("dungeon_armor_limit")
end
function DungeonWeaponEntity:isNoTotalLimit()
return true
end
function DungeonWeaponEntity:onClickFight()
ModuleManager.DungeonWeaponManager:showMainUI()
end
function DungeonWeaponEntity:getDialyFarmLimit()
return GFunc.getConstIntValue("dungeon_equip_limit")
end
function DungeonWeaponEntity:getFarmCount()
return self.farmCount
end
function DungeonWeaponEntity:getRemianFarmCount()
local count = self:getDialyFarmLimit() - self:getFarmCount()
if count < 0 then
count = 0
end
return count
end
function DungeonWeaponEntity:getLevelEnough(chapterId)
local config = ConfigManager:getConfig(self:getConfigName())[chapterId]
if not config then
return false
end
if config.level > DataManager.PlayerData:getLv() then
return false
end
return true
end
function DungeonWeaponEntity:canFightChapter(chapterId)
if not chapterId then
return false
end
if chapterId <= self.maxPassedId + 1 then
if self:getLevelEnough(chapterId) then
return true
end
end
return false
end
function DungeonWeaponEntity:canFarmChapter(chapterId)
if not chapterId then
return false
end
return self.maxPassedId >= chapterId
end
function DungeonWeaponEntity:doCachePassInfo(chapterId, info)
if not self.cachePassInfo then
self.cachePassInfo = {}
end
if not info then
return
end
if not self.cachePassInfo[chapterId] then
self.cachePassInfo[chapterId] = {
info = info,
getTime = Time:getServerTime()
}
else
self.cachePassInfo[chapterId].info = info
self.cachePassInfo[chapterId].getTime = Time:getServerTime()
end
end
function DungeonBaseEntity:getCachePassInfo(chapterId)
if not self.cachePassInfo then
self.cachePassInfo = {}
end
if not self.cachePassInfo[chapterId] then
return
end
if self.cachePassInfo[chapterId].getTime + GET_PASS_INFO_INTERVAL < Time:getServerTime() then -- 过期
return
end
return self.cachePassInfo[chapterId].info
end
return DungeonWeaponEntity