|  |  | 
 |  |  | import PlayerSuccess
 | 
 |  |  | import EventShell
 | 
 |  |  | import PassiveBuffEffMng
 | 
 |  |  | import OpenServerCampaign
 | 
 |  |  | import ItemControler
 | 
 |  |  | import PlayerActivity
 | 
 |  |  | import ChEquip
 | 
 |  |  | 
 |  |  | 
 | 
 |  |  |     #解锁技能
 | 
 |  |  |     upIpyData = IpyGameDataPY.GetIpyGameData('TreasureUp', mwID, mwLV)
 | 
 |  |  |     if upIpyData:
 | 
 |  |  |         skillIDList = upIpyData.GetUnLockSkill()
 | 
 |  |  |         for skillID in skillIDList:
 | 
 |  |  |             GiveSkill(curPlayer, skillID, GameWorld.GetGameWorld().GetTick())
 | 
 |  |  |         if upIpyData.GetPrivilegeID():
 | 
 |  |  |             PlayerControl.WorldNotify(0, 'TreasureSoulWakeUp', [curPlayer.GetName(), upIpyData.GetPrivilegeID()])
 | 
 |  |  |      | 
 |  |  |     if not upIpyData:
 | 
 |  |  |         return
 | 
 |  |  |     skillIDList = upIpyData.GetUnLockSkill()
 | 
 |  |  |     for skillID in skillIDList:
 | 
 |  |  |         GiveSkill(curPlayer, skillID, GameWorld.GetGameWorld().GetTick())
 | 
 |  |  |     #物品奖励
 | 
 |  |  |     itemAward = upIpyData.GetItemAward()
 | 
 |  |  |     if itemAward:
 | 
 |  |  |         itemID, itemCnt, isBind = itemAward
 | 
 |  |  |         packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, 1)
 | 
 |  |  |         if 1 > packSpace:
 | 
 |  |  |             PlayerControl.SendMailByKey('TreasureWakeUp', [curPlayer.GetID()], [itemAward])
 | 
 |  |  |         else:
 | 
 |  |  |             ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, isBind,
 | 
 |  |  |                                              [IPY_GameWorld.rptItem], True, showSysInfo=True, event=["MWAward", False, {"mwID":mwID}])
 | 
 |  |  |     activeMWID = upIpyData.GetActiveMWID()
 | 
 |  |  |     if activeMWID == mwID:
 | 
 |  |  |         GameWorld.ErrLog('    TreasureUp.txt 配置异常 不可激活自身法宝 mwID=%s'%mwID)
 | 
 |  |  |     elif activeMWID:
 | 
 |  |  |         DoActiveMW(curPlayer, activeMWID)
 | 
 |  |  |     
 | 
 |  |  |     CalcMagicWeaponAttr(curPlayer)
 | 
 |  |  |     PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
 | 
 |  |  | 
 |  |  |             activeCnt += 1
 | 
 |  |  |     return activeCnt
 | 
 |  |  | 
 | 
 |  |  | def GetMWIDByPotentialsSkillID(skillID):
 | 
 |  |  |     #通过潜力技能ID获取对应的法宝ID
 | 
 |  |  | def GetPotentialsNextSkillID(skillID):
 | 
 |  |  |     #通过潜力技能ID获取对应的下一个技能ID
 | 
 |  |  |     global g_potentialsSkillDict
 | 
 |  |  |     if not g_potentialsSkillDict:
 | 
 |  |  |         g_potentialsSkillDict = {}
 | 
 |  |  | 
 |  |  |             ipyData = ipyDataMgr.GetTreasureByIndex(i)
 | 
 |  |  |             mwID = ipyData.GetID()
 | 
 |  |  |             skillIDList = ipyData.GetPotentials()
 | 
 |  |  |             for curSkillID in skillIDList:
 | 
 |  |  |                 g_potentialsSkillDict[curSkillID] = mwID   | 
 |  |  |             for i, curSkillID in enumerate(skillIDList):
 | 
 |  |  |                 nextSkillID = skillIDList[i+1] if i+1 < len(skillIDList) else 0
 | 
 |  |  |                 g_potentialsSkillDict[curSkillID] = nextSkillID
 | 
 |  |  |     return g_potentialsSkillDict.get(skillID, 0)
 | 
 |  |  | 
 | 
 |  |  | ## 给技能
 | 
 |  |  | 
 |  |  |                 if newSkill:
 | 
 |  |  |                     skillManager.LVUPSkillByID(newSkillID)
 | 
 |  |  |                     GameWorld.DebugLog('    法宝技能升级 skillTypeID=%s, upSkillLv=%s, 触发学习技能%s' % (skillTypeID, upSkillLv, newSkillID))
 | 
 |  |  |                     curControl.RefreshSkillFightPowerEx(newSkillID, beforeFightPower)
 | 
 |  |  |                     curControl.RefreshSkillFightPowerEx(newSkillID, 0)
 | 
 |  |  |                     PassiveBuffEffMng.GetPassiveEffManager().RegistPassiveEff(curPlayer, newSkillID)
 | 
 |  |  |                     if SkillCommon.isPassiveAttr(newSkill):
 | 
 |  |  |                         newSkillIsPassive = True
 | 
 |  |  |                     PlayerControl.WorldNotify(0, 'SkillPotential2', [curPlayer.GetName(), skillTypeID, upSkillLv, newSkillID])
 | 
 |  |  |             
 | 
 |  |  |     
 | 
 |  |  |     if SkillCommon.isPassiveAttr(upSkill) or newSkillIsPassive:
 | 
 |  |  | 
 |  |  |     curControl.RefreshSkillFightPowerEx(upSkill.GetSkillID(), beforeFightPower)
 | 
 |  |  |     PassiveBuffEffMng.GetPassiveEffManager().RegistPassiveEff(curPlayer, upSkill.GetSkillID())
 | 
 |  |  |     
 | 
 |  |  |     #通知技能已升级成功 GeRen_admin_31379
 | 
 |  |  |     #<n color="255,255,0" BKCOLOR="0,0,0">恭喜您将</n><n color="0,190,255" BKCOLOR="0,0,0"><Info Type="Skill" Name="Name" ID="{%S1%}"/></n><n color="255,255,0" BKCOLOR="0,0,0">升至</n><n color="0,190,255" BKCOLOR="0,0,0">{%S2%}</n><n color="255,255,0" BKCOLOR="0,0,0">级!</n>
 | 
 |  |  |     #PlayerControl.NotifyCode(curPlayer, "GeRen_admin_31379", [skillTypeID, upSkillLv])
 | 
 |  |  |     #通知技能已升级成功
 | 
 |  |  |     nextSkillID = GetPotentialsNextSkillID(skillTypeID)
 | 
 |  |  |     if nextSkillID:
 | 
 |  |  |         nextSkill = GameWorld.GetGameData().FindSkillByType(nextSkillID, 1)
 | 
 |  |  |         if nextSkill and nextSkill.GetLearnSkillReq() == skillTypeID and upSkillLv == nextSkill.GetLearnSkillLV():
 | 
 |  |  |             PlayerControl.WorldNotify(0, 'SkillPotential1', [curPlayer.GetName(), skillTypeID, upSkillLv, nextSkillID])
 | 
 |  |  |                  | 
 |  |  |     maxLV = upSkill.GetSkillMaxLV()
 | 
 |  |  |     if upSkillLv == maxLV:
 | 
 |  |  |         PlayerControl.WorldNotify(0, 'SkillPotential3', [curPlayer.GetName(), skillTypeID, maxLV])
 | 
 |  |  |     
 | 
 |  |  |     #获得技能等级
 | 
 |  |  |     #curSkillLV = curSkill.GetSkillLV()
 | 
 |  |  | 
 |  |  |     
 | 
 |  |  |     curPlayer.Sync_MakeItemAnswer(ShareDefine.Def_mitMagicWeaponSkillUp, 1)
 | 
 |  |  |     
 | 
 |  |  | 
 | 
 |  |  |     SetMWPrivilegeData(curPlayer, ChConfig.MWPrivilege_MWSkillUp, 1, True)
 | 
 |  |  |     PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_MWSkillUp, 1, [skillTypeID])
 | 
 |  |  |     EventShell.EventRespons_MWSkillUp(curPlayer)
 | 
 |  |  |     return
 | 
 |  |  | 
 |  |  | 
 | 
 |  |  | def CalcMagicWeaponAttr(curPlayer):
 | 
 |  |  |     ## 计算法宝属性
 | 
 |  |  |      | 
 |  |  |     allAttrList1 = [{} for _ in range(4)] #人族法宝
 | 
 |  |  |     allAttrList2 = [{} for _ in range(4)] #魔族法宝
 | 
 |  |  |     allAttrList3 = [{} for _ in range(4)] #仙族法宝
 | 
 |  |  |      | 
 |  |  |     signDayMWID = IpyGameDataPY.GetFuncCfg('MWSignDayAttr', 2)
 | 
 |  |  |     ipyDataMgr = IpyGameDataPY.IPY_Data()
 | 
 |  |  |     for i in xrange(ipyDataMgr.GetTreasureCount()):
 | 
 |  |  |         treasureIpyData = ipyDataMgr.GetTreasureByIndex(i)
 | 
 |  |  | 
 |  |  |             if upIpyData:
 | 
 |  |  |                 attrDict = upIpyData.GetAddAttr()
 | 
 |  |  |                 GameWorld.AddDictValue(allAttrDict, attrDict)
 | 
 |  |  | 
 | 
 |  |  |                 privilegeID = upIpyData.GetPrivilegeID()
 | 
 |  |  |                 if privilegeID:
 | 
 |  |  |                     # 法宝之魂
 | 
 |  |  |                     attrDict = GetMagicWeaponPrivilegeAttr(curPlayer, privilegeID)
 | 
 |  |  |                     GameWorld.AddDictValue(allAttrDict, attrDict)
 | 
 |  |  |         if magicWeaponID == signDayMWID:
 | 
 |  |  |             #签到属性
 | 
 |  |  |             totalSignNum = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalSignNum) # 总签到天数
 | 
 |  |  |             addAttr = {}
 | 
 |  |  |             for attid, attnum in IpyGameDataPY.GetFuncEvalCfg('MWSignDayAttr', 1, {}).items():
 | 
 |  |  |                 addAttr[int(attid)] = attnum * totalSignNum
 | 
 |  |  |             GameWorld.AddDictValue(allAttrDict, addAttr)
 | 
 |  |  |         
 | 
 |  |  |         treasureType = treasureIpyData.GetTreasureType()
 | 
 |  |  |         for effID, value in allAttrDict.items():
 | 
 |  |  | 
 |  |  |     
 | 
 |  |  |     DoActiveMW(curPlayer, mwID, nextMWLV)
 | 
 |  |  |     
 | 
 |  |  |     # 每日活动
 | 
 |  |  |     PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_MagicWeapon)
 | 
 |  |  |     return
 | 
 |  |  | 
 | 
 |  |  | def AddMagicWeaponUpExp(curPlayer, mwID, addExp):
 | 
 |  |  | 
 |  |  |     curUpExp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MagicWeaponUpExp % mwID)
 | 
 |  |  |     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MagicWeaponUpExp % mwID, curUpExp+addExp)
 | 
 |  |  |     Sycn_MagicWeaponLV(curPlayer, mwID)
 | 
 |  |  |     # 每日活动
 | 
 |  |  |     PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_MagicWeapon)
 | 
 |  |  |     return
 | 
 |  |  | 
 | 
 |  |  | def Sycn_MagicWeaponLV(curPlayer, mwID= -1):
 | 
 |  |  | 
 |  |  | 
 | 
 |  |  | def GetMagicWeaponPrivilege(curPlayer, privilege):
 | 
 |  |  |     #法宝等级权限
 | 
 |  |  |     ipyData = IpyGameDataPY.GetIpyGameDataByCondition('TreasureUp', {'PrivilegeID':privilege}, False, False)
 | 
 |  |  |     if not ipyData:
 | 
 |  |  |         return 0
 | 
 |  |  | 
 | 
 |  |  |     mwID = ipyData.GetMWID()
 | 
 |  |  |     mwLV = ipyData.GetLV()
 | 
 |  |  |     curMWLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MagicWeaponLV % mwID)
 | 
 |  |  |     if curMWLV < mwLV:
 | 
 |  |  |     if not GetIsActiveMWSoul(curPlayer, privilege):
 | 
 |  |  |         return 0
 | 
 |  |  |     privilegeIpyData = IpyGameDataPY.GetIpyGameDataNotLog('TreasurePrivilege', privilege)
 | 
 |  |  |     if not privilegeIpyData:
 | 
 |  |  | 
 |  |  |         attrInfo = {}
 | 
 |  |  |     singleValue = privilegeIpyData.GetSingleValue()
 | 
 |  |  |     
 | 
 |  |  |     if privilege == ChConfig.MWPrivilege_SignDayAddAttr:
 | 
 |  |  |         totalSignNum = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalSignNum) # 总签到天数
 | 
 |  |  |         for attid, attnum in attrInfo.items():
 | 
 |  |  |             addAttr[int(attid)] = attnum * totalSignNum
 | 
 |  |  |     elif privilege == ChConfig.MWPrivilege_EquipPlus:
 | 
 |  |  |     if privilege == ChConfig.MWPrivilege_EquipPlus:
 | 
 |  |  |         #强化加成
 | 
 |  |  |         addAttr = ChEquip.CalcAllEquipAllPlusLVAttr(curPlayer)
 | 
 |  |  |     else: 
 | 
 |  |  | 
 |  |  |         if canGetCnt <= 0:
 | 
 |  |  |             return
 | 
 |  |  |         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MWSoulGotValue % privilege, gotValue+canGetCnt*singleValue)
 | 
 |  |  |         CalcMagicWeaponAttr(curPlayer)
 | 
 |  |  |         CalcMagicWeaponSoulAttr(curPlayer)
 | 
 |  |  |         PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
 | 
 |  |  |         
 | 
 |  |  |         
 | 
 |  |  | 
 |  |  |         pack.CurValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MWSoulCurValue % priID)
 | 
 |  |  |         pack.GotValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MWSoulGotValue % priID)
 | 
 |  |  |         pack.ItemAwardState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MWSoulGotItemState % priID)
 | 
 |  |  |         if not isForce and max([pack.CurValue, pack.GotValue, pack.ItemAwardState]) == 0:
 | 
 |  |  |         pack.State = GetIsActiveMWSoul(curPlayer, priID)
 | 
 |  |  |         if not isForce and max([pack.CurValue, pack.GotValue, pack.ItemAwardState, pack.State]) == 0:
 | 
 |  |  |             continue
 | 
 |  |  |         pack.PriID = priID
 | 
 |  |  |         sendPack.InfoList.append(pack)
 | 
 |  |  | 
 |  |  | def SetMagicWeaponClickState(curPlayer, mwID, state=1):
 | 
 |  |  |     #设置法宝是否点击认主状态
 | 
 |  |  |     GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_MagicWeaponIsClick, mwID % 100, state, True, [mwID / 100])
 | 
 |  |  |     return
 | 
 |  |  | 
 | 
 |  |  | 
 | 
 |  |  | #// A5 12 激活法宝之魂 #tagCMActiveMWSoul
 | 
 |  |  | #
 | 
 |  |  | #struct    tagCMActiveMWSoul
 | 
 |  |  | #
 | 
 |  |  | #{
 | 
 |  |  | #    tagHead        Head;
 | 
 |  |  | #    BYTE        ID;    //编号
 | 
 |  |  | #};
 | 
 |  |  | def OnActiveMWSoul(index, clientData, tick):
 | 
 |  |  |     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
 | 
 |  |  |     soulID = clientData.ID
 | 
 |  |  |     ipyData = IpyGameDataPY.GetIpyGameData('TreasurePrivilege', soulID)
 | 
 |  |  |     if not ipyData:
 | 
 |  |  |         return
 | 
 |  |  |     if GetIsActiveMWSoul(curPlayer, soulID):
 | 
 |  |  |         GameWorld.Log('    该法宝之魂已经激活!! soulID=%s'%soulID)
 | 
 |  |  |         return
 | 
 |  |  |     #检查成就
 | 
 |  |  |     succList = ipyData.GetSuccessList()
 | 
 |  |  |     for succID in succList:
 | 
 |  |  |         if not PlayerSuccess.GetSuccHasGot(curPlayer, succID):
 | 
 |  |  |             GameWorld.DebugLog('    激活法宝之魂 成就未完成  soulID=%s,succID=%s'%(soulID, succID))
 | 
 |  |  |             return
 | 
 |  |  |      | 
 |  |  |     GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_MWSoulActiveState, soulID, 1, True)
 | 
 |  |  |     #任务
 | 
 |  |  |     EventShell.EventRespons_MWSoulActive(curPlayer, soulID)
 | 
 |  |  |      | 
 |  |  |     CalcMagicWeaponSoulAttr(curPlayer)
 | 
 |  |  |     PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
 | 
 |  |  |      | 
 |  |  |     #֪ͨ
 | 
 |  |  |     Sycn_MWPrivilegeData(curPlayer, soulID)
 | 
 |  |  |     return
 | 
 |  |  | 
 | 
 |  |  | def GetIsActiveMWSoul(curPlayer, soulID):
 | 
 |  |  |     #获取法宝之魂是否已激活
 | 
 |  |  |     return GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_MWSoulActiveState, soulID)
 | 
 |  |  | 
 | 
 |  |  | def CalcMagicWeaponSoulAttr(curPlayer):
 | 
 |  |  |     #法宝之魂属性刷新
 | 
 |  |  |     allAttrList = [{} for _ in range(4)]
 | 
 |  |  |     allAttrDict = {}
 | 
 |  |  |     ipyMgr = IpyGameDataPY.IPY_Data()
 | 
 |  |  |     for i in xrange(ipyMgr.GetTreasurePrivilegeCount()):
 | 
 |  |  |         ipyData = ipyMgr.GetTreasurePrivilegeByIndex(i)
 | 
 |  |  |         soulID = ipyData.GetPrivilegeID()
 | 
 |  |  |         if not GetIsActiveMWSoul(curPlayer, soulID):
 | 
 |  |  |             continue
 | 
 |  |  |         attrDict = GetMagicWeaponPrivilegeAttr(curPlayer, soulID)
 | 
 |  |  |         GameWorld.AddDictValue(allAttrDict, attrDict)
 | 
 |  |  |          | 
 |  |  |     for attrID, attrValue in allAttrDict.items():
 | 
 |  |  |         PlayerControl.CalcAttrDict_Type(attrID, attrValue, allAttrList)
 | 
 |  |  |     PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_MagicWeaponSoul, allAttrList)
 | 
 |  |  |     return |