| | |
| | | import PlayerControl
|
| | | import IpyGameDataPY
|
| | | import FormulaControl
|
| | | import PlayerPrestigeSys
|
| | | import PlayerFamily
|
| | | import PlayerHorse
|
| | | import PlayerGubao
|
| | | import PlayerHero
|
| | | import PlayerHJG
|
| | | import GameWorld
|
| | | import ChConfig
|
| | | import ChEquip
|
| | |
| | | self.__refreshState = 0 # 刷属性标记, 0-不需要刷新了,1-需要刷新
|
| | |
|
| | | self.__freeLineupHeroObjs = [] # 释放的空闲对象[LineupHero, ...]
|
| | | self.lineupHeroDict = {} # 阵容武将 {posNum:LineupHero, ...}
|
| | | self.__lineupHeroDict = {} # 刷新阵容后的武将信息 {posNum:LineupHero, ...}
|
| | | self.fightPower = 0 # 阵容总战力
|
| | | return
|
| | |
|
| | | def UpdLineup(self, heroItemDict, shapeType=0, refreshForce=False, syncLineup=True):
|
| | | def UpdLineup(self, heroItemDict, shapeType=0, refreshForce=False, isReload=False):
|
| | | '''变更阵容时更新
|
| | | @param heroItemDict: 武将背包索引信息 {itemIndex:posNum, ...}
|
| | | @param shapeType: 阵型
|
| | | @param refreshForce: 是否强制刷属性
|
| | | '''
|
| | | self.lineupChange = True
|
| | | if not isReload: # 非重读阵容的视为变更
|
| | | self.lineupChange = True
|
| | | self.shapeType = shapeType
|
| | | self.heroItemDict = heroItemDict
|
| | | GameWorld.DebugLog("更新阵容: lineupID=%s,%s" % (self.lineupID, heroItemDict), self.playerID)
|
| | | self.RefreshLineupAttr(refreshForce)
|
| | | if syncLineup and self.olPlayer.curPlayer:
|
| | | if not isReload and self.olPlayer.curPlayer:
|
| | | PlayerHero.Sync_Lineup(self.olPlayer.curPlayer, self.lineupID)
|
| | | return
|
| | |
|
| | | def IsEmpty(self): return (not self.__lineupHeroDict or not self.heroItemDict)
|
| | | |
| | | def GetPosNumList(self): return self.__lineupHeroDict.keys()
|
| | | |
| | | def FreeLineupHero(self):
|
| | | ## 释放阵容武将对象,重新计算
|
| | | for freeObj in self.lineupHeroDict.values():
|
| | | for freeObj in self.__lineupHeroDict.values():
|
| | | if freeObj not in self.__freeLineupHeroObjs:
|
| | | self.__freeLineupHeroObjs.append(freeObj)
|
| | | self.lineupHeroDict = {}
|
| | | self.__lineupHeroDict = {}
|
| | | self.fightPower = 0
|
| | | return
|
| | |
|
| | | def GetLineupHero(self, posNum):
|
| | | lineupHero = None
|
| | | if posNum in self.lineupHeroDict:
|
| | | lineupHero = self.lineupHeroDict[posNum]
|
| | | if posNum in self.__lineupHeroDict:
|
| | | lineupHero = self.__lineupHeroDict[posNum]
|
| | | elif self.__freeLineupHeroObjs:
|
| | | lineupHero = self.__freeLineupHeroObjs.pop(0)
|
| | | lineupHero.Clear()
|
| | | self.lineupHeroDict[posNum] = lineupHero
|
| | | self.__lineupHeroDict[posNum] = lineupHero
|
| | | else:
|
| | | lineupHero = LineupHero()
|
| | | self.lineupHeroDict[posNum] = lineupHero
|
| | | self.__lineupHeroDict[posNum] = lineupHero
|
| | | return lineupHero
|
| | |
|
| | | def GetLineupHeroByID(self, heroID):
|
| | | lineupHero = None
|
| | | for posNum in self.lineupHeroDict.keys():
|
| | | for posNum in self.__lineupHeroDict.keys():
|
| | | lineupHero = self.GetLineupHero(posNum)
|
| | | if lineupHero.heroID == heroID:
|
| | | return lineupHero
|
| | | if False:
|
| | | lineupHero = LineupHero()
|
| | | return lineupHero
|
| | | |
| | | def GetLineupInfo(self):
|
| | | ## 获取阵容信息,即要用到该阵容了,如战斗或者保存缓存信息等
|
| | | self.DoRefreshLineupAttr() # 取阵容时先检查
|
| | | return
|
| | |
|
| | | def SetNeedRefreshState(self):
|
| | | ## 设置需要刷属性
|
| | |
| | | def RefreshLineupAttr(self, refreshForce=False):
|
| | | self.__refreshState = 1 # 标记要刷新
|
| | | if refreshForce:
|
| | | self.DoRefreshLineupAttr()
|
| | | self.CheckRefreshLineupAttr()
|
| | | return
|
| | |
|
| | | def DoRefreshLineupAttr(self):
|
| | | def CheckRefreshLineupAttr(self):
|
| | | ## 检查刷新阵容属性
|
| | | if not self.__refreshState:
|
| | | return False
|
| | | self.__refreshState = 0
|
| | | doRefreshLineupAttr(self.olPlayer.curPlayer, self.olPlayer, self)
|
| | | self.lineupChange = False
|
| | | self.__refreshState = 0
|
| | | return True
|
| | |
|
| | | def CheckHeroItemUpdate(self, itemIndex):
|
| | |
| | |
|
| | | # 主线战斗
|
| | | self.mainFight = TurnAttack.MainFight(playerID)
|
| | | |
| | | self._lastBatBufferInfo = [] # 最后一场战斗临时回放 ["guid", "buffer"]
|
| | | return
|
| | |
|
| | | def OnClear(self):
|
| | |
| | | ## 是否真的在线
|
| | | return self.curPlayer != None
|
| | |
|
| | | def GetLineup(self, lineupID):
|
| | | def GetLineup(self, lineupID, checkAttr=True):
|
| | | # @param checkAttr: 检查刷新到最新阵容属性
|
| | | lineup = None
|
| | | if lineupID in self.lineupDict:
|
| | | lineup = self.lineupDict[lineupID]
|
| | |
| | | lineup = Lineup(self.playerID, lineupID)
|
| | | self.lineupDict[lineupID] = lineup
|
| | | lineup.olPlayer = self
|
| | | if checkAttr:
|
| | | lineup.CheckRefreshLineupAttr()
|
| | | return lineup
|
| | |
|
| | | def GetCalcAttr(self, calcIndex): return self.calcAttrDict.get(calcIndex, {})
|
| | |
| | | for lineupID, lineup in self.lineupDict.items():
|
| | | if not isAllLineup and lineupID != ShareDefine.Lineup_Main:
|
| | | continue
|
| | | if lineup.DoRefreshLineupAttr():
|
| | | if lineup.CheckRefreshLineupAttr():
|
| | | isRefresh = True
|
| | |
|
| | | return isRefresh
|
| | |
| | |
|
| | | GameWorld.DebugLog("武将物品养成更新索引: %s, 影响阵容:%s" % (itemIndexList, effLineupIDList), self.playerID)
|
| | | return effLineupIDList
|
| | | |
| | | def GetLastBatBuffer(self): return self._lastBatBufferInfo
|
| | | def SetLastBatBuffer(self, guid, batBuffer):
|
| | | self._lastBatBufferInfo = [guid, batBuffer]
|
| | | return
|
| | |
|
| | | class OnlineMgr():
|
| | | ## 准在线玩家管理
|
| | |
| | |
|
| | | GameWorld.DebugLog("重载阵容: %s" % lineupDict, curPlayer.GetPlayerID())
|
| | | for lineupID, heroItemDict in lineupDict.items():
|
| | | lineup = olPlayer.GetLineup(lineupID)
|
| | | lineup = olPlayer.GetLineup(lineupID, False)
|
| | |
|
| | | # 获取其他绑定该阵容的功能,如红颜、灵兽等
|
| | |
|
| | | shapeType = lineShapeTypeDict.get(lineupID, 0)
|
| | | lineup.UpdLineup(heroItemDict, shapeType, syncLineup=False)
|
| | | lineup.UpdLineup(heroItemDict, shapeType, isReload=True)
|
| | |
|
| | | PlayerHero.Sync_Lineup(curPlayer)
|
| | | return
|
| | |
| | | CalcRoleBase(curPlayer)
|
| | | ChEquip.CalcRoleEquipAttr(curPlayer)
|
| | | PlayerHero.CalcHeroAddAttr(curPlayer)
|
| | | PlayerPrestigeSys.CalcOfficialRankAttr(curPlayer)
|
| | | PlayerGubao.CalcGubaoAttr(curPlayer)
|
| | | PlayerHJG.CalcHJGAttr(curPlayer)
|
| | | PlayerHorse.CalcHorseAttr(curPlayer)
|
| | | return
|
| | |
|
| | | def doRefreshLineupAttr(curPlayer, olPlayer, lineup):
|
| | |
| | | elif skinIDList:
|
| | | skinID = skinIDList[0]
|
| | |
|
| | | starMax = PlayerHero.GetHeroStarMax(heroItem)
|
| | | InitAddPer += qualityIpyData.GetInitAddPer()
|
| | | LVAddPer += qualityIpyData.GetLVAddPer() * heroLV
|
| | | LVAddPer += qualityIpyData.GetLVAddPer() * max(0, heroLV - 1)
|
| | | BreakLVAddPer += qualityIpyData.GetBreakLVAddPer() * breakLV
|
| | | StarAddPer += qualityIpyData.GetStarAddPer() * star
|
| | | StarAddPer += qualityIpyData.GetStarAddPer() * min(star, starMax)
|
| | |
|
| | | lineupHero = lineup.GetLineupHero(posNum)
|
| | | #if False:
|
| | |
| | | selfAttrDict[int(k)] = v
|
| | | heroSelfAttrInfo[heroID] = selfAttrDict
|
| | |
|
| | | # 星级天赋
|
| | | starTalentAttrDict = {}
|
| | | idCount = heroItem.GetUserAttrCount(ShareDefine.Def_IudetHeroTalentID)
|
| | | lvCount = heroItem.GetUserAttrCount(ShareDefine.Def_IudetHeroTalentIDLV)
|
| | | for aIndex in range(min(idCount, lvCount)):
|
| | | talentID = heroItem.GetUserAttrByIndex(ShareDefine.Def_IudetHeroTalentID, aIndex)
|
| | | talentLV = heroItem.GetUserAttrByIndex(ShareDefine.Def_IudetHeroTalentIDLV, aIndex)
|
| | | stIpyData = IpyGameDataPY.GetIpyGameData("HeroTalent", talentID)
|
| | | if not stIpyData:
|
| | | continue
|
| | | attrID = stIpyData.GetAttrID()
|
| | | attrValue = stIpyData.GetAttrValue() * talentLV
|
| | | starTalentAttrDict[attrID] = starTalentAttrDict.get(attrID, 0) + attrValue
|
| | | heroStarTalentInfo[heroID] = starTalentAttrDict
|
| | | |
| | | # 突破潜能
|
| | | breakAttrDict = {}
|
| | | breakIpyDataList = IpyGameDataPY.GetIpyGameDataList("HeroBreak", heroID)
|
| | |
| | | heroBreakAttrInfo[heroID] = breakAttrDict
|
| | |
|
| | | # 觉醒天赋
|
| | | maxUnlockSlot = IpyGameDataPY.GetFuncCfg("HeroStarTalent", 1) # 常规天赋槽个数
|
| | | awakeTalentAttrDict = {}
|
| | | awakeIpyDataList = IpyGameDataPY.GetIpyGameDataList("HeroAwake", heroID)
|
| | | awakeIpyDataList = IpyGameDataPY.GetIpyGameDataListNotLog("HeroAwake", heroID)
|
| | | if awakeIpyDataList:
|
| | | for awakeIpyData in awakeIpyDataList:
|
| | | if awakeIpyData.GetAwakeLV() > awakeLV:
|
| | | break
|
| | | unlockTalentSlot = awakeIpyData.GetUnlockTalentSlot()
|
| | | maxUnlockSlot = max(maxUnlockSlot, unlockTalentSlot)
|
| | | attrIDList = awakeIpyData.GetAttrIDList()
|
| | | attrValueList = awakeIpyData.GetAttrValueList()
|
| | | for aIndex in range(min(len(attrIDList), len(attrValueList))):
|
| | |
| | | if skillID:
|
| | | lineupHero.heroSkillIDList.append(skillID)
|
| | | heroAwakeTalentInfo[heroID] = awakeTalentAttrDict
|
| | | |
| | | # 星级天赋
|
| | | starTalentAttrDict = {}
|
| | | idCount = heroItem.GetUserAttrCount(ShareDefine.Def_IudetHeroTalentID)
|
| | | lvCount = heroItem.GetUserAttrCount(ShareDefine.Def_IudetHeroTalentIDLV)
|
| | | for aIndex in range(min(idCount, lvCount, maxUnlockSlot)): # 重生导致已觉醒槽位失效时属性也无效
|
| | | talentID = heroItem.GetUserAttrByIndex(ShareDefine.Def_IudetHeroTalentID, aIndex)
|
| | | talentLV = heroItem.GetUserAttrByIndex(ShareDefine.Def_IudetHeroTalentIDLV, aIndex)
|
| | | stIpyData = IpyGameDataPY.GetIpyGameData("HeroTalent", talentID)
|
| | | if not stIpyData:
|
| | | continue
|
| | | attrID = stIpyData.GetAttrID()
|
| | | attrValue = stIpyData.GetAttrValue() * talentLV
|
| | | starTalentAttrDict[attrID] = starTalentAttrDict.get(attrID, 0) + attrValue
|
| | | heroStarTalentInfo[heroID] = starTalentAttrDict
|
| | |
|
| | | # 羁绊统计
|
| | | for fetterID in heroIpyData.GetFetterIDList():
|
| | |
| | | lvAttrDict = olPlayer.GetCalcAttr(ChConfig.Def_CalcAttr_LV)
|
| | | equipAttrDict = olPlayer.GetCalcAttr(ChConfig.Def_CalcAttr_MainEquip)
|
| | | bookAttrDict = olPlayer.GetCalcAttr(ChConfig.Def_CalcAttr_HeroBook)
|
| | |
|
| | | realmAttrDict = olPlayer.GetCalcAttr(ChConfig.Def_CalcAttr_Realm)
|
| | | gubaoAttrDict = olPlayer.GetCalcAttr(ChConfig.Def_CalcAttr_Gubao)
|
| | | hjgAttrDict = olPlayer.GetCalcAttr(ChConfig.Def_CalcAttr_HJG)
|
| | | horseAttrDict = olPlayer.GetCalcAttr(ChConfig.Def_CalcAttr_Horse)
|
| | | |
| | | GameWorld.DebugLog(" 国家武将统计=%s" % countryHeroInfo, playerID)
|
| | | GameWorld.DebugLog(" 羁绊武将统计=%s" % fetterHeroInfo, playerID)
|
| | | GameWorld.DebugLog(" 武将自身属性=%s" % heroSelfAttrInfo, playerID)
|
| | |
| | | GameWorld.DebugLog(" 主公等级属性=%s" % lvAttrDict, playerID)
|
| | | GameWorld.DebugLog(" 主公装备属性=%s" % equipAttrDict, playerID)
|
| | | GameWorld.DebugLog(" 主公图鉴属性=%s" % bookAttrDict, playerID)
|
| | | GameWorld.DebugLog(" 主公官职属性=%s" % realmAttrDict, playerID)
|
| | | GameWorld.DebugLog(" 主公古宝属性=%s" % gubaoAttrDict, playerID)
|
| | | GameWorld.DebugLog(" 主幻境阁属性=%s" % hjgAttrDict, playerID)
|
| | | GameWorld.DebugLog(" 主公坐骑属性=%s" % horseAttrDict, playerID)
|
| | |
|
| | | PlayerLV = curPlayer.GetLV()
|
| | | OfficialLV = curPlayer.GetOfficialRank()
|
| | |
| | | bookValue = bookAttrDict.get(attrID, 0)
|
| | | bookPer = bookAttrDict.get(attrPerID, 0) / 10000.0 if attrPerID else 0
|
| | |
|
| | | realmValue = realmAttrDict.get(attrID, 0)
|
| | | realmPer = realmAttrDict.get(attrPerID, 0) / 10000.0 if attrPerID else 0
|
| | | |
| | | gubaoValue = gubaoAttrDict.get(attrID, 0)
|
| | | gubaoPer = gubaoAttrDict.get(attrPerID, 0) / 10000.0 if attrPerID else 0
|
| | | |
| | | hjgValue = hjgAttrDict.get(attrID, 0)
|
| | | hjgPer = hjgAttrDict.get(attrPerID, 0) / 10000.0 if attrPerID else 0
|
| | | |
| | | horseValue = horseAttrDict.get(attrID, 0)
|
| | | horsePer = horseAttrDict.get(attrPerID, 0) / 10000.0 if attrPerID else 0
|
| | | |
| | | lineupInitAddPer, lineupLVAddPer, lineupBreakLVAddPer, lineupStarAddPer = 0, 0, 0, 0
|
| | | if attrID in ChConfig.BaseAttrIDList:
|
| | | lineupInitAddPer, lineupLVAddPer, lineupBreakLVAddPer, lineupStarAddPer = InitAddPer, LVAddPer, BreakLVAddPer, StarAddPer
|
| | |
| | | awakeTalentPer = awakeTalentAttrDict.get(attrPerID, 0) / 10000.0
|
| | |
|
| | | # 计算
|
| | | attrParamDict = {"lvValue":lvValue, "equipValue":equipValue, "bookValue":bookValue, "bookPer":bookPer, |
| | | attrParamDict = {"lvValue":lvValue, "equipValue":equipValue, "bookValue":bookValue, "bookPer":bookPer, "realmValue":realmValue, "realmPer":realmPer, |
| | | "gubaoValue":gubaoValue, "gubaoPer":gubaoPer, "hjgValue":hjgValue, "hjgPer":hjgPer, "horseValue":horseValue, "horsePer":horsePer,
|
| | | "lineupInitAddPer":lineupInitAddPer, "lineupLVAddPer":lineupLVAddPer, "lineupBreakLVAddPer":lineupBreakLVAddPer, "lineupStarAddPer":lineupStarAddPer,
|
| | | "heroSelfValue":heroSelfValue, "heroSelfPer":heroSelfPer, "inheritPer":inheritPer,
|
| | | "lineupHaloValue":lineupHaloValue, "lineupHaloPer":lineupHaloPer, "fetterValue":fetterValue, "fetterPer":fetterPer,
|
| | |
| | | }
|
| | |
|
| | | if attrID in ChConfig.BaseAttrIDList:
|
| | | attrValue = FormulaControl.Eval("baseAttrFormula", baseAttrFormula, attrParamDict)
|
| | | attrValue = FormulaControl.Eval("baseAttrFormula", baseAttrFormula, attrParamDict, toInt=False, ndigits=3)
|
| | | else:
|
| | | attrValue = FormulaControl.Eval("otherAttrFormula", otherAttrFormula, attrParamDict)
|
| | | attrValue = FormulaControl.Eval("otherAttrFormula", otherAttrFormula, attrParamDict, toInt=False, ndigits=3)
|
| | | #GameWorld.DebugLog(" attrID=%s,attrValue=%s,attrParamDict=%s" % (attrID, attrValue, attrParamDict))
|
| | |
|
| | | attrIpyData = IpyGameDataPY.GetIpyGameData("PlayerAttr", attrID)
|
| | |
| | | logAttrDict["%s-%s" % (attrID, attrName)] = attrValue
|
| | |
|
| | | # 计算战力
|
| | | fightPower = FormulaControl.Eval("fightPowerFormula", fightPowerFormula, fightPowerParamDict)
|
| | | fightPower = FormulaControl.Eval("fightPowerFormula", fightPowerFormula, fightPowerParamDict, toInt=True)
|
| | |
|
| | | GameWorld.DebugLog(" heroID=%s,fightPower=%s,heroSkillIDList=%s" % (heroID, fightPower, lineupHero.heroSkillIDList), playerID)
|
| | | skillTypeIDDict = {}
|
| | |
| | | skillID = skillData.GetSkillID()
|
| | | lineupHero.heroSkillIDList.append(skillID)
|
| | | paramDict = {"SkillPower":skillData.GetFightPower(), "PlayerLV":PlayerLV, "OfficialLV":OfficialLV}
|
| | | sFightPower = FormulaControl.Eval("skillFPFormula", skillFPFormula, paramDict)
|
| | | sFightPower = FormulaControl.Eval("skillFPFormula", skillFPFormula, paramDict, toInt=True)
|
| | | skillFightPower += sFightPower
|
| | | GameWorld.DebugLog(" skillFightPower=%s,heroSkillIDList=%s" % (skillFightPower, lineupHero.heroSkillIDList), playerID)
|
| | |
|
| | |
| | | GameWorld.DebugLog("主阵容变化,重新开始战斗", playerID)
|
| | | if mainTurnFight.mapID == ChConfig.Def_FBMapID_Main:
|
| | | TurnAttack.__doMainLevelWave(curPlayer, True)
|
| | | elif mainTurnFight.mapID == ChConfig.Def_FBMapID_MainBoss:
|
| | | TurnAttack.__doMainBossStart(curPlayer)
|
| | |
|
| | | # 否则只重新设置战斗属性
|
| | | else:
|
| | |
| | | else:
|
| | | GameWorld.DebugLog("主阵容没有在战斗中,不需要处理", playerID)
|
| | |
|
| | | PlayerFamily.RefreshFamilyMember(curPlayer) # 更新公会
|
| | | # 更新排行榜
|
| | |
|
| | | return
|