diff --git a/lua/app/ui/hero/cell/attr_cell.lua b/lua/app/ui/hero/cell/attr_cell.lua index 0095f2b5..c5fc838a 100644 --- a/lua/app/ui/hero/cell/attr_cell.lua +++ b/lua/app/ui/hero/cell/attr_cell.lua @@ -10,6 +10,7 @@ end function AttrCell:refresh(heroEntity, nodeType, attrType) self.heroEntity = heroEntity + self.runesEntity = self.heroEntity:getRunes() self.nodeType = nodeType self.attrName = attrType[self.heroEntity:getMatchType()] @@ -62,7 +63,7 @@ function AttrCell:showHp() 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 - value = value + self.heroEntity:getRunes():getAttrValue(self.attrName) + value = value + (self.runesEntity and self.runesEntity:getAttrValue(self.attrName) or 0) end self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value)) @@ -96,7 +97,7 @@ function AttrCell:showAtk() 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 - value = value + self.heroEntity:getRunes():getAttrValue(self.attrName) + value = value + (self.runesEntity and self.runesEntity:getAttrValue(self.attrName) or 0) end self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value)) @@ -120,7 +121,7 @@ function AttrCell:showNormalHurt() 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 - value = value + self.heroEntity:getRunes():getAttrValue(self.attrName) + value = value + (self.runesEntity and self.runesEntity:getAttrValue(self.attrName) or 0) end self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value)) @@ -144,7 +145,7 @@ function AttrCell:showSkillHurt() 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 - value = value + self.heroEntity:getRunes():getAttrValue(self.attrName) + value = value + (self.runesEntity and self.runesEntity:getAttrValue(self.attrName) or 0) end self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value)) @@ -165,7 +166,7 @@ function AttrCell:showCrit() elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then value = value + DataManager.SkinData:getCritPercent(self.heroEntity) elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_RUNES then - value = value + self.heroEntity:getRunes():getAttrValue(self.attrName) + value = value + (self.runesEntity and self.runesEntity:getAttrValue(self.attrName) or 0) end self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value)) @@ -186,7 +187,7 @@ function AttrCell:showCritAtk() elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then value = value + DataManager.SkinData:getCritHurtPercent(self.heroEntity) elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_RUNES then - value = value + self.heroEntity:getRunes():getAttrValue(self.attrName) + value = value + (self.runesEntity and self.runesEntity:getAttrValue(self.attrName) or 0) end self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value)) @@ -213,7 +214,7 @@ function AttrCell:showNormalHurtp() 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 - value = value + self.heroEntity:getRunes():getAttrValue(self.attrName) + value = value + (self.runesEntity and self.runesEntity:getAttrValue(self.attrName) or 0) end self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value)) @@ -240,7 +241,7 @@ function AttrCell:showSkillHurtp() 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 - value = value + self.heroEntity:getRunes():getAttrValue(self.attrName) + value = value + (self.runesEntity and self.runesEntity:getAttrValue(self.attrName) or 0) end self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value)) @@ -261,7 +262,7 @@ function AttrCell:showCured() elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then value = value + DataManager.SkinData:getHealPercent(self.heroEntity) elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_RUNES then - value = value + self.heroEntity:getRunes():getAttrValue(self.attrName) + value = value + (self.runesEntity and self.runesEntity:getAttrValue(self.attrName) or 0) end self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value)) diff --git a/lua/app/ui/hero/cell/attr_node_cell.lua b/lua/app/ui/hero/cell/attr_node_cell.lua index 8053e6ea..23bddfa1 100644 --- a/lua/app/ui/hero/cell/attr_node_cell.lua +++ b/lua/app/ui/hero/cell/attr_node_cell.lua @@ -41,7 +41,8 @@ function AttrNodeCell:isShowAttr(heroEntity, node, attr) return DataManager.SkinData:hasAttr(heroEntity, attr[heroEntity:getMatchType()]) end if node == GConst.HeroConst.ATTR_SHOW_RUNES then - return heroEntity:getRunes():hasAttr(attr[heroEntity:getMatchType()]) + local runesEntity = heroEntity:getRunes() + return runesEntity and runesEntity:hasAttr(attr[heroEntity:getMatchType()]) or false end return true diff --git a/lua/app/ui/hero/hero_attr_ui.lua b/lua/app/ui/hero/hero_attr_ui.lua index eb9d93bb..5218a4f0 100644 --- a/lua/app/ui/hero/hero_attr_ui.lua +++ b/lua/app/ui/hero/hero_attr_ui.lua @@ -66,8 +66,8 @@ function HeroAttrUI:isShowAttr(node) return #DataManager.SkinData:getOwnAllAttr(self.heroEntity) > 0 end if node == GConst.HeroConst.ATTR_SHOW_RUNES then - local all = self.heroEntity:getRunes():getAllAttr() - return all and #all > 0 + local runesEntity = self.heroEntity:getRunes() + return runesEntity and runesEntity:getAllAttr() and #runesEntity:getAllAttr() > 0 or false end return true diff --git a/lua/app/userdata/hero/hero_entity.lua b/lua/app/userdata/hero/hero_entity.lua index f8fb0cf1..eb12703d 100644 --- a/lua/app/userdata/hero/hero_entity.lua +++ b/lua/app/userdata/hero/hero_entity.lua @@ -205,16 +205,21 @@ end function HeroEntity:updateRunesAttr() self.runesAttr = {} - local hp = self:getRunes():getAttrValue(GConst.MATCH_HP_FIX_NAME[self:getMatchType()]) - local atk = self:getRunes():getAttrValue(GConst.MATCH_ATTACK_NAME[self:getMatchType()]) - local normalHurt = self:getRunes():getAttrValue(GConst.MATCH_NORMAL_HURT_NAME[self:getMatchType()]) - local skillHurt = self:getRunes():getAttrValue(GConst.MATCH_SKILL_HURT_NAME[self:getMatchType()]) - local critPer = self:getRunes():getAttrValue(GConst.MATCH_CRIT_NAME[self:getMatchType()]) - local critHurtPer = self:getRunes():getAttrValue(GConst.MATCH_CRIT_TIME_NAME[self:getMatchType()]) - local normalHurtPer = self:getRunes():getAttrValue(GConst.MATCH_NORMAL_HURTP_NAME[self:getMatchType()], true) - local skillHurtPer = self:getRunes():getAttrValue(GConst.MATCH_SKILL_HURTP_NAME[self:getMatchType()], true) - local healPer = self:getRunes():getAttrValue(GConst.MATCH_CURED_NAME[self:getMatchType()]) - local allHurtp = self:getRunes():getAttrValue(GConst.MATCH_ALL_HURTP_NAME[self:getMatchType()]) + local runesEntity = self:getRunes() + if runesEntity == nil then + return + end + + local hp = runesEntity:getAttrValue(GConst.MATCH_HP_FIX_NAME[self:getMatchType()]) + local atk = runesEntity:getAttrValue(GConst.MATCH_ATTACK_NAME[self:getMatchType()]) + local normalHurt = runesEntity:getAttrValue(GConst.MATCH_NORMAL_HURT_NAME[self:getMatchType()]) + local skillHurt = runesEntity:getAttrValue(GConst.MATCH_SKILL_HURT_NAME[self:getMatchType()]) + local critPer = runesEntity:getAttrValue(GConst.MATCH_CRIT_NAME[self:getMatchType()]) + local critHurtPer = runesEntity:getAttrValue(GConst.MATCH_CRIT_TIME_NAME[self:getMatchType()]) + local normalHurtPer = runesEntity:getAttrValue(GConst.MATCH_NORMAL_HURTP_NAME[self:getMatchType()], true) + local skillHurtPer = runesEntity:getAttrValue(GConst.MATCH_SKILL_HURTP_NAME[self:getMatchType()], true) + local healPer = runesEntity:getAttrValue(GConst.MATCH_CURED_NAME[self:getMatchType()]) + local allHurtp = runesEntity:getAttrValue(GConst.MATCH_ALL_HURTP_NAME[self:getMatchType()]) self.runesAttr[GConst.MATCH_HP_NAME[self:getMatchType()]] = hp self.runesAttr[GConst.MATCH_ATTACK_NAME[self:getMatchType()]] = atk @@ -556,7 +561,12 @@ function HeroEntity:getTotalBaseHp() end end result = result + DataManager.SkinData:getBaseHp(self) - result = result + self:getRunes():getAttrValue(GConst.MATCH_HP_FIX_NAME[self:getMatchType()], true) + + local runesEntity = self:getRunes() + if runesEntity then + result = result + runesEntity:getAttrValue(GConst.MATCH_HP_FIX_NAME[self:getMatchType()], true) + end + return result end @@ -574,8 +584,11 @@ function HeroEntity:getTotalBaseAtk() end -- logStr = logStr .. "\nSKIN:" .. DataManager.SkinData:getBaseAttack(self) result = result + DataManager.SkinData:getBaseAttack(self) - -- logStr = logStr .. "\nRUNES:" .. self:getRunes():getAttrValue(GConst.MATCH_ATTACK_NAME[self:getMatchType()], true) - result = result + self:getRunes():getAttrValue(GConst.MATCH_ATTACK_NAME[self:getMatchType()], true) + local runesEntity = self:getRunes() + if runesEntity then + -- logStr = logStr .. "\nRUNES:" .. self:getRunes():getAttrValue(GConst.MATCH_ATTACK_NAME[self:getMatchType()], true) + result = result + runesEntity:getAttrValue(GConst.MATCH_ATTACK_NAME[self:getMatchType()], true) + end -- Logger.logHighlight(logStr) return result end @@ -612,11 +625,7 @@ function HeroEntity:setRunes(runesEntity) end function HeroEntity:getRunes() - if self.runesEntity then - return self.runesEntity - end - - return DataManager.RunesData:getRunes(self:getCfgId()) + return self.runesEntity end return HeroEntity \ No newline at end of file diff --git a/lua/app/userdata/runes/runes_entity.lua b/lua/app/userdata/runes/runes_entity.lua index b2b5d225..2e59f078 100644 --- a/lua/app/userdata/runes/runes_entity.lua +++ b/lua/app/userdata/runes/runes_entity.lua @@ -12,7 +12,7 @@ end function RunesEntity:updateGrids(grids) self.grids = grids or GConst.EMPTY_TABLE - self:getHeroEntity():onRunesAttrChange() + self:getHeroEntity():setRunes(self) self:setDirty() end