diff --git a/lua/app/common/bi_report.lua b/lua/app/common/bi_report.lua index 13705124..c71f98de 100644 --- a/lua/app/common/bi_report.lua +++ b/lua/app/common/bi_report.lua @@ -331,6 +331,10 @@ BIReport.ACTIVITY_SUMMER = { BUY_LEVEL_UP = "BuyLevelUp", } +BIReport.RUNES_FORMATION = { + CHAPTER = "chapter", +} + -- b6 local EVENT_NAME_EXIT = "client_exit" local EVENT_NAME_FIGHT = "client_fight" @@ -362,6 +366,7 @@ local EVENT_NAME_ARENA_OPT = "client_arena_opt"-- 竞技场 local EVENT_NAME_MISCELLANEOUS_OPT = "event_name_miscellaneous_opt" -- 一些杂项 local EVENT_BOX_OPEN = "client_box_open" local EVENT_ACT_OPT = "client_act_opt" +local EVENT_NAME_RUNES = "client_runes" function BIReport:setIsNewPlayer(isNewPlayer) self.isNewPlayer = isNewPlayer @@ -1777,4 +1782,12 @@ function BIReport:postActOpt(event_type, actId, level, exp, buyLevelCost) self:report(EVENT_ACT_OPT, args) end +function BIReport:postRunes(event_type, runes) + local args = { + event_type = event_type, + runes = runes + } + self:report(EVENT_NAME_RUNES, args) +end + return BIReport \ No newline at end of file diff --git a/lua/app/common/data_manager.lua b/lua/app/common/data_manager.lua index c1218cb8..ff1269f5 100644 --- a/lua/app/common/data_manager.lua +++ b/lua/app/common/data_manager.lua @@ -154,6 +154,8 @@ function DataManager:initWithServerData(data) self.DailyChallengeData:init(data.chapter_daily_challenge) self.DungeonData:initDungeonGold(data.chapter_gold_challenge) self.DungeonData:initDungeonShards(data.chapter_shards_challenge) + -- FormationData要在RunesData之前初始化,依赖阵容数据进行上报 + self.FormationData:init(data.fight_info) self.EquipData:init(data.heroes_equips) self.EquipData:initGifts(data.act_weapon_armor_gift) self.SkinData:init(data.bag.skins) @@ -161,7 +163,6 @@ function DataManager:initWithServerData(data) -- HeroData要在EquipData、SkinData、RunesData之后初始化,依赖它们的属性数据 self.HeroData:init(data.bag.heroes) self.BagData:init(data.bag) - self.FormationData:init(data.fight_info) self.DungeonData:initDungeonWeapon(data.chapter_weapon_challenge) self.DungeonData:initDungeonArmor(data.chapter_armor_challenge) self.CollectionData:init(data.collection) diff --git a/lua/app/global/global_func.lua b/lua/app/global/global_func.lua index 5eb4df2f..fd8813b3 100644 --- a/lua/app/global/global_func.lua +++ b/lua/app/global/global_func.lua @@ -1898,17 +1898,16 @@ function GFunc.formatPlayerFormationInfo(info) -- 处理装备 local equipInfo = info.heroes_equips[heroId] - local equips = {} if not equipInfo then equipInfo = {equips = {}} end for partName, partType in pairs(GConst.EquipConst.PART_TYPE) do local level = equipInfo.equips[partType] or 0 local equipEntity = DataManager.EquipData:createEntity(heroId, partType, level) - equips[partType] = equipEntity + equipEntity:setHeroEntity(heroEntity) + heroEntity:setEquips(partType, equipEntity) end - heroEntity:setEquips(equips) -- 处理皮肤 local skinIds = {} diff --git a/lua/app/ui/hero/cell/attr_cell.lua b/lua/app/ui/hero/cell/attr_cell.lua index c5fc838a..dababd7b 100644 --- a/lua/app/ui/hero/cell/attr_cell.lua +++ b/lua/app/ui/hero/cell/attr_cell.lua @@ -11,6 +11,12 @@ end function AttrCell:refresh(heroEntity, nodeType, attrType) self.heroEntity = heroEntity self.runesEntity = self.heroEntity:getRunes() + self.weaponEntity = self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.WEAPON) + self.hatEntity = self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.HAT) + self.clothesEntity = self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.CLOTHES) + self.beltEntity = self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.BELT) + self.handguardEntity = self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.HANDGUARD) + self.nodeType = nodeType self.attrName = attrType[self.heroEntity:getMatchType()] @@ -54,12 +60,12 @@ function AttrCell:showHp() value = self.heroEntity:getCfgHp(self.heroEntity:getBeginLv()) end elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_WEAPON then - value = self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.WEAPON):getHp() + value = (self.weaponEntity and self.weaponEntity:getHp() or 0) elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then - value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.HAT):getHp() - value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.CLOTHES):getHp() - value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.BELT):getHp() - value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.HANDGUARD):getHp() + value = value + (self.hatEntity and self.hatEntity:getHp() or 0) + value = value + (self.clothesEntity and self.clothesEntity:getHp() or 0) + value = value + (self.beltEntity and self.beltEntity:getHp() or 0) + value = value + (self.handguardEntity and self.handguardEntity:getHp() or 0) elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then value = value + DataManager.SkinData:getHp(self.heroEntity) elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_RUNES then @@ -88,12 +94,12 @@ function AttrCell:showAtk() value = self.heroEntity:getCfgAtk(self.heroEntity:getBeginLv()) end elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_WEAPON then - value = self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.WEAPON):getAttack() + value = (self.weaponEntity and self.weaponEntity:getAttack() or 0) elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then - value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.HAT):getAttack() - value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.CLOTHES):getAttack() - value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.BELT):getAttack() - value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.HANDGUARD):getAttack() + value = value + (self.hatEntity and self.hatEntity:getAttack() or 0) + value = value + (self.clothesEntity and self.clothesEntity:getAttack() or 0) + value = value + (self.beltEntity and self.beltEntity:getAttack() or 0) + value = value + (self.handguardEntity and self.handguardEntity:getAttack() or 0) elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then value = value + DataManager.SkinData:getAttack(self.heroEntity) elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_RUNES then @@ -114,10 +120,10 @@ function AttrCell:showNormalHurt() elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_WEAPON then elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then - value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.HAT):getNormalHurt() - value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.CLOTHES):getNormalHurt() - value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.BELT):getNormalHurt() - value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.HANDGUARD):getNormalHurt() + value = value + (self.hatEntity and self.hatEntity:getNormalHurt() or 0) + value = value + (self.clothesEntity and self.clothesEntity:getNormalHurt() or 0) + value = value + (self.beltEntity and self.beltEntity:getNormalHurt() or 0) + value = value + (self.handguardEntity and self.handguardEntity:getNormalHurt() or 0) elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then value = value + DataManager.SkinData:getNormalHurt(self.heroEntity) elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_RUNES then @@ -138,10 +144,10 @@ function AttrCell:showSkillHurt() elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_WEAPON then elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then - value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.HAT):getSkillHurt() - value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.CLOTHES):getSkillHurt() - value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.BELT):getSkillHurt() - value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.HANDGUARD):getSkillHurt() + value = value + (self.hatEntity and self.hatEntity:getSkillHurt() or 0) + value = value + (self.clothesEntity and self.clothesEntity:getSkillHurt() or 0) + value = value + (self.beltEntity and self.beltEntity:getSkillHurt() or 0) + value = value + (self.handguardEntity and self.handguardEntity:getSkillHurt() or 0) elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then value = value + DataManager.SkinData:getSkillHurt(self.heroEntity) elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_RUNES then @@ -161,7 +167,7 @@ function AttrCell:showCrit() value = self.heroEntity:getTotalAttrValue(self.attrName) elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_WEAPON then - value = self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.WEAPON):getCritPercent() + value = (self.weaponEntity and self.weaponEntity:getCritPercent() or 0) elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then value = value + DataManager.SkinData:getCritPercent(self.heroEntity) @@ -182,7 +188,7 @@ function AttrCell:showCritAtk() value = self.heroEntity:getTotalAttrValue(self.attrName) elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_WEAPON then - value = self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.WEAPON):getCritHurtPercent() + value = (self.weaponEntity and self.weaponEntity:getCritHurtPercent() or 0) elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then value = value + DataManager.SkinData:getCritHurtPercent(self.heroEntity) @@ -207,10 +213,7 @@ function AttrCell:showNormalHurtp() elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_WEAPON then elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then -- 套装属性,防具只用计算一次 - value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.HAT):getNormalHurtPercent() - -- value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.CLOTHES):getNormalHurtPercent() - -- value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.BELT):getNormalHurtPercent() - -- value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.HANDGUARD):getNormalHurtPercent() + value = value + (self.hatEntity and self.hatEntity:getNormalHurtPercent() or 0) elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then value = value + DataManager.SkinData:getNormalHurtPercent(self.heroEntity) elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_RUNES then @@ -234,10 +237,7 @@ function AttrCell:showSkillHurtp() elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_WEAPON then elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then -- 套装属性,防具只用计算一次 - value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.HAT):getSkillHurtPercent() - -- value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.CLOTHES):getSkillHurtPercent() - -- value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.BELT):getSkillHurtPercent() - -- value = value + self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.HANDGUARD):getSkillHurtPercent() + value = value + (self.hatEntity and self.hatEntity:getSkillHurtPercent() or 0) elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then value = value + DataManager.SkinData:getSkillHurtPercent(self.heroEntity) elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_RUNES then @@ -257,7 +257,7 @@ function AttrCell:showCured() value = self.heroEntity:getTotalAttrValue(self.attrName) elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_WEAPON then - value = self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.WEAPON):getHealPercent() + value = (self.weaponEntity and self.weaponEntity:getHealPercent() or 0) elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then value = value + DataManager.SkinData:getHealPercent(self.heroEntity) diff --git a/lua/app/userdata/hero/hero_data.lua b/lua/app/userdata/hero/hero_data.lua index 31a9c318..c03ad812 100644 --- a/lua/app/userdata/hero/hero_data.lua +++ b/lua/app/userdata/hero/hero_data.lua @@ -84,10 +84,28 @@ function HeroData:addHero(heroStruct) if self.heroes[heroStruct.id] then return end - self.heroes[heroStruct.id] = self:getEntity(heroStruct) + local entity = self:getEntity(heroStruct) + + self:updateSelfHeroEquipsAndRunes(entity) + self.heroes[heroStruct.id] = entity + self.data.activeCount = self.data.activeCount + 1 end +-- 更新装备、符文数据 +function HeroData:updateSelfHeroEquipsAndRunes(entity) + if EDITOR_MODE then + Logger.logHighlight("更新英雄属性:" .. entity:getCfgId()) + end + + entity:setEquips(GConst.EquipConst.PART_TYPE.WEAPON, DataManager.EquipData:getEquip(entity:getCfgId(), GConst.EquipConst.PART_TYPE.WEAPON)) + entity:setEquips(GConst.EquipConst.PART_TYPE.HAT, DataManager.EquipData:getEquip(entity:getCfgId(), GConst.EquipConst.PART_TYPE.HAT)) + entity:setEquips(GConst.EquipConst.PART_TYPE.CLOTHES, DataManager.EquipData:getEquip(entity:getCfgId(), GConst.EquipConst.PART_TYPE.CLOTHES)) + entity:setEquips(GConst.EquipConst.PART_TYPE.BELT, DataManager.EquipData:getEquip(entity:getCfgId(), GConst.EquipConst.PART_TYPE.BELT)) + entity:setEquips(GConst.EquipConst.PART_TYPE.HANDGUARD, DataManager.EquipData:getEquip(entity:getCfgId(), GConst.EquipConst.PART_TYPE.HANDGUARD)) + entity:setRunes(DataManager.RunesData:getRunes(entity:getCfgId())) +end + function HeroData:getEntity(heroStruct) return HeroEntity:create(heroStruct.id, heroStruct.level, heroStruct.skin) end @@ -142,6 +160,7 @@ function HeroData:setHeroLv(id, lv) local activeBefore = true if not entity:isActived() then self.data.activeCount = self.data.activeCount + 1 + self:updateSelfHeroEquipsAndRunes(entity) ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_NEW_HERO_GOT) ModuleManager.PlayerManager:checkUnlockAvatar(id) activeBefore = false diff --git a/lua/app/userdata/hero/hero_entity.lua b/lua/app/userdata/hero/hero_entity.lua index eb12703d..deb5bcd9 100644 --- a/lua/app/userdata/hero/hero_entity.lua +++ b/lua/app/userdata/hero/hero_entity.lua @@ -594,8 +594,12 @@ function HeroEntity:getTotalBaseAtk() end -- {partType = EquipEntity} -function HeroEntity:setEquips(equipEntities) - self.equipEntities = equipEntities +function HeroEntity:setEquips(partType, equipEntities) + if self.equipEntities == nil then + self.equipEntities = {} + end + self.equipEntities[partType] = equipEntities + self:getTotalAttrValue() -- 防止报错 self:onEquipAttrChange() end @@ -604,8 +608,7 @@ function HeroEntity:getEquips(partType) if self.equipEntities then return self.equipEntities[partType] end - - return DataManager.EquipData:getEquip(self:getCfgId(), partType) + return nil end function HeroEntity:setSkins(skinIds) diff --git a/lua/app/userdata/runes/runes_data.lua b/lua/app/userdata/runes/runes_data.lua index f463cd5f..4557c3aa 100644 --- a/lua/app/userdata/runes/runes_data.lua +++ b/lua/app/userdata/runes/runes_data.lua @@ -20,8 +20,16 @@ function RunesData:init(data) self.exp = data.exp or 0 if data.heroes_grids then for heroId, grids in pairs(data.heroes_grids) do - self:addEquip(heroId, grids.grids) + self:addRunes(heroId, grids.grids) end + + -- 处理上报 + local formation = DataManager.FormationData:getStageFormation() + local runesChapter = {} + for elementType, heroId in pairs(formation) do + runesChapter[heroId] = data.heroes_grids[heroId] + end + BIReport:postRunes(BIReport.RUNES_FORMATION.CHAPTER, runesChapter) end -- 活动开启 @@ -45,7 +53,7 @@ function RunesData:isOpen(showToast) return true end -function RunesData:addEquip(heroId, grids) +function RunesData:addRunes(heroId, grids) if self.runes == nil then self.runes = {} end diff --git a/lua/app/userdata/runes/runes_entity.lua b/lua/app/userdata/runes/runes_entity.lua index 2e59f078..85a8bdeb 100644 --- a/lua/app/userdata/runes/runes_entity.lua +++ b/lua/app/userdata/runes/runes_entity.lua @@ -3,7 +3,7 @@ local DEFAULT_FACTOR = GConst.BattleConst.DEFAULT_FACTOR function RunesEntity:ctor(heroId, grids) self.heroId = heroId - self.grids = grids or GConst.EMPTY_TABLE + self:updateGrids(grids) end function RunesEntity:setDirty() @@ -12,7 +12,6 @@ end function RunesEntity:updateGrids(grids) self.grids = grids or GConst.EMPTY_TABLE - self:getHeroEntity():setRunes(self) self:setDirty() end diff --git a/lua/app/userdata/skin/skin_data.lua b/lua/app/userdata/skin/skin_data.lua index a6f2e45f..872175c4 100644 --- a/lua/app/userdata/skin/skin_data.lua +++ b/lua/app/userdata/skin/skin_data.lua @@ -32,7 +32,11 @@ end -- 获取英雄已解锁的id function SkinData:getUnlockList() - return table.keys(self.unlockList) + if self.unlockList then + return table.keys(self.unlockList) + end + + return nil end -- 是否解锁 @@ -181,23 +185,26 @@ end function SkinData:getOwnAllAttr(heroEntity) local result = {} local unlockList = heroEntity:getSkins() or self:getUnlockList() - for idx, skinId in pairs(unlockList) do - local hero = self:getHeroIdBySkinId(skinId) - local attrs = self:getAttr(skinId) - if attrs and hero == heroEntity:getCfgId() then - for index, attr in ipairs(attrs) do - local temp = table.find(result, function(value) - return value.type == attr.type - end) - - if temp then - temp.num = temp.num + attr.num - else - table.insert(result, attr) + if unlockList then + for idx, skinId in pairs(unlockList) do + local hero = self:getHeroIdBySkinId(skinId) + local attrs = self:getAttr(skinId) + if attrs and hero == heroEntity:getCfgId() then + for index, attr in ipairs(attrs) do + local temp = table.find(result, function(value) + return value.type == attr.type + end) + + if temp then + temp.num = temp.num + attr.num + else + table.insert(result, attr) + end end end end end + return result end