| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| ##@package Player.PlayerMagicWeapon  | 
| #  | 
| # @todo:·¨±¦ÏµÍ³  | 
| # @author xdh  | 
| # @date 2017-05-18  | 
| # @version 1.0  | 
| #  | 
| # ÏêϸÃèÊö: ·¨±¦ÏµÍ³ Ä¿Ç°¼¤»î·½Ê½£º1.ÈÎÎñ½Ó¿Ú¼¤»î 2.ͨ¹Ø¸±±¾ 3.»ñµÃijÎïÆ· 4.Ïɱ¦Ñ°Ö÷  | 
| #  | 
| #-------------------------------------------------------------------------------  | 
| #"""Version = 2017-05-18 12:00"""  | 
| #-------------------------------------------------------------------------------  | 
|   | 
| import ItemCommon  | 
| import ShareDefine  | 
| import NetPackCommon  | 
| import DataRecordPack  | 
| import ChPyNetSendPack  | 
| import PlayerControl  | 
| import IPY_GameWorld  | 
| import SkillCommon  | 
| import GameWorld  | 
| import ChConfig  | 
| import IpyGameDataPY  | 
| import SkillShell  | 
| import GameFuncComm  | 
| import PlayerSuccess  | 
| import EventShell  | 
| import PassiveBuffEffMng  | 
| import ItemControler  | 
| import PlayerActivity  | 
| import FBCommon  | 
| import PlayerVip  | 
|   | 
| import random  | 
|   | 
| ##µÇ¼´¦Àí  | 
| # @param curPlayer Íæ¼Ò  | 
| # @return None  | 
| def PlayerMagicWeaponLogin(curPlayer):  | 
|     SyncXBXZAwardRecord(curPlayer)  | 
|     Sycn_MagicWeaponLV(curPlayer)  | 
|     return  | 
|   | 
|   | 
| def OnDay(curPlayer):  | 
|   | 
|     return  | 
|   | 
|   | 
| def DoMagicWeaponOpen(curPlayer):  | 
|     ## ·¨±¦¹¦ÄÜ¿ªÆô ¼¤»îµÚÒ»¸ö·¨±¦  | 
| #    ipyData = IpyGameDataPY.IPY_Data().GetTreasureByIndex(0)  | 
| #    mwID = ipyData.GetID()  | 
| #    GameWorld.DebugLog("·¨±¦¹¦ÄÜ¿ªÆô ¼¤»îµÚÒ»¸ö·¨±¦ mwID=%s"%mwID)  | 
| #    DoActiveMW(curPlayer, mwID)  | 
|   | 
|     return True  | 
|   | 
|   | 
| def GetIsActiveMagicWeapon(curPlayer, mwID, lv=1):  | 
|     #»ñÈ¡·¨±¦ÊÇ·ñ´ïµ½X¼¶  | 
|     curMWLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MagicWeaponLV % mwID)  | 
|     return curMWLV >= lv  | 
|   | 
|   | 
|   | 
| def ActiveMagicWeaponByFB(curPlayer, mapID, lineID, passLV=0):  | 
|     ##ͨ¹Ø¸±±¾¼¤»î·¨±¦£¨ÈË×塢ħ×å·¨±¦£©  | 
|     ipyData = IpyGameDataPY.GetIpyGameDataByCondition('MagicWeaponFB', {'LineID':lineID, 'Level':passLV}, isLogNone=False)  | 
|     if ipyData:  | 
|         mwID = ipyData.GetMWID()  | 
|         GameWorld.Log('¸üÐÂħ×帱±¾¹Ø¿¨ mwID=%s,level=%s' % (mwID, passLV), curPlayer.GetID())  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MWFBPassLevel % mwID, passLV)  | 
|         Sycn_MagicWeaponLV(curPlayer, mwID)  | 
|         EventShell.EventRespons_MagicWeaponFBPassLV(curPlayer, mwID, passLV)  | 
|         ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition('MagicWeaponFB', {'LineID':lineID}, True)  | 
|         maxLevel = ipyDataList[-1].GetLevel()  | 
|         if passLV >= maxLevel:  | 
|             DoActiveMW(curPlayer, mwID)  | 
|         else:  | 
|             CalcMagicWeaponAttr(curPlayer)  | 
|             PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()  | 
|     else:  | 
|         ipyData = IpyGameDataPY.GetIpyGameDataByCondition('Treasure', {'FBMapID':mapID, 'FBLineID':lineID})  | 
|         if not ipyData:  | 
|             return  | 
|         mwID = ipyData.GetID()  | 
|         if curPlayer.GetLV() < ipyData.GetNeedLV():  | 
|             GameWorld.Log('ͨ¹Ø¸±±¾¼¤»î·¨±¦ ,µÈ¼¶²»×㣡£¡£¡mwID=%s, needLV=%s' % (mwID, ipyData.GetNeedLV()))  | 
|             return  | 
|   | 
|         DoActiveMW(curPlayer, mwID)  | 
|     return  | 
|   | 
|   | 
| def DoActiveMW(curPlayer, mwID, mwLV=1):  | 
|     if not GetWMIpyData(mwID):  | 
|         return  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MagicWeaponLV % mwID, mwLV)  | 
|     if mwLV == 1:  | 
|   | 
|         if mwID in IpyGameDataPY.GetFuncEvalCfg('UnblockTreasure'):  | 
|             PlayerControl.NotifyCode(curPlayer, 'UnblockTreasure', [curPlayer.GetName(), mwID])  | 
|         else:  | 
|             sysMark = IpyGameDataPY.GetFuncEvalCfg('UnblockTreasure', 2, {}).get(mwID, 'UnblockTreasure')  | 
|             PlayerControl.WorldNotify(0, sysMark, [curPlayer.GetName(), mwID])  | 
|         if mwID == IpyGameDataPY.GetFuncCfg('FabaoAddPoint', 1):  | 
|             __DoFabaoAddPoint(curPlayer)  | 
|               | 
|   | 
|     EventShell.EventRespons_MagicWeaponLV(curPlayer, mwID, mwLV)  | 
|     #֪ͨ¿Í»§¶ËµÈ¼¶  | 
|     Sycn_MagicWeaponLV(curPlayer, mwID)  | 
|     #³É¾Í  | 
|     PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_GetMagicWeapon, 1, [mwID, mwLV])  | 
|   | 
|     #½âËø¼¼ÄÜ  | 
|     upIpyData = IpyGameDataPY.GetIpyGameData('TreasureUp', mwID, mwLV)  | 
|     if not upIpyData:  | 
|         return  | 
|     skillIDList = upIpyData.GetUnLockSkill()  | 
|     for skillID in skillIDList:  | 
|         GiveSkill(curPlayer, skillID, GameWorld.GetGameWorld().GetTick())  | 
|           | 
|       | 
|     CalcMagicWeaponAttr(curPlayer)  | 
|     PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()  | 
|       | 
|     GameWorld.DebugLog('    ¼¤»î·¨±¦ mwID=%s,mwLV=%s' % (mwID, mwLV))  | 
|       | 
|     vipAddAtkMWID = IpyGameDataPY.GetFuncCfg("VIPAddAtkEXP", 2)  # VIPɱ¹Ö¼ÓÊôÐÔËùÐ輤»î·¨±¦  | 
|     if mwID == vipAddAtkMWID:  | 
|         PlayerVip.RefreshVIPAttr(curPlayer)  | 
|           | 
|     #½âËø¹¦ÄÜ  | 
|     GameFuncComm.DoFuncOpenLogic(curPlayer)  | 
|     DataRecordPack.DR_MagicWeaponActive(curPlayer, mwID, mwLV)  | 
|     return True  | 
|   | 
| # »ñµÃ·¨±¦¼Óµã  | 
| def __DoFabaoAddPoint(curPlayer):  | 
|     if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_AddPoint):  | 
|         # Î´¿ªÆôǰ²»¿É¼Óµã£¬ÒòΪDoAddPointOpen»áÒ»´ÎÐÔ²¹Æë£¬±ÜÃâÒâÍâÇé¿ö¶à¼ÓÁ˵ãÊý  | 
|         return  | 
|     addPointDict = IpyGameDataPY.GetFuncEvalCfg("LVUPAddPoint", 1, {})  | 
|     fabaoAddPoint = PlayerControl.GetFabaoAddPoint(curPlayer)  | 
|   | 
|     curLV = curPlayer.GetLV()  | 
|     addFreePoint = 0  | 
|     for rangLVs, point in addPointDict.items():  | 
|         if curLV < rangLVs[0]:  | 
|             continue  | 
|         addFreePoint += fabaoAddPoint * (min(curLV, rangLVs[1]) - rangLVs[0] + 1)  | 
|     freePoint = curPlayer.GetFreePoint()  | 
|     updFreePoint = freePoint + addFreePoint  | 
|     curPlayer.SetFreePoint(updFreePoint)  | 
|     GameWorld.DebugLog("»ñµÃ·¨±¦Ôö¼Ó×ÔÓÉÊôÐÔµã: freePoint=%s,addFreePoint=%s,curLV=%s,updFreePoint=%s"   | 
|                        % (freePoint, addFreePoint, curLV, updFreePoint))  | 
|       | 
|     return  | 
| def GetWMIpyData(mwID):return IpyGameDataPY.GetIpyGameData('Treasure', mwID)  | 
|   | 
|   | 
| def GetMWActiveCntTotal(curPlayer):  | 
|     ## »ñÈ¡¼¤»îµÄ·¨±¦×ܸöÊý  | 
|     activeCnt = 0  | 
|     ipyDataMgr = IpyGameDataPY.IPY_Data()  | 
|     for i in xrange(ipyDataMgr.GetTreasureCount()):  | 
|         ipyData = ipyDataMgr.GetTreasureByIndex(i)  | 
|         magicWeaponID = ipyData.GetID()  | 
|         if GetIsActiveMagicWeapon(curPlayer, magicWeaponID):  | 
|             activeCnt += 1  | 
|     return activeCnt  | 
|   | 
|   | 
| def GetMWActiveCntByType(curPlayer, mwType):  | 
|     ## ¸ù¾Ý·¨±¦ÀàÐÍ»ñÈ¡ÒѼ¤»îÊýÁ¿  | 
|     dataList = IpyGameDataPY.GetIpyGameDataByCondition('Treasure', {'TreasureType':mwType}, True, False)  | 
|     if not dataList:  | 
|         return 0  | 
|     activeCnt = 0  | 
|     for ipydata in dataList:  | 
|         isActive = GetIsActiveMagicWeapon(curPlayer, ipydata.GetID())  | 
|         if isActive:  | 
|             activeCnt += 1  | 
|     return activeCnt  | 
|   | 
|   | 
| ## ¸ø¼¼ÄÜ  | 
| #  @param curPlayer  | 
| #  @param skillResID ¼¼ÄÜÔ´ID  | 
| #  @param tick Ê±¼ä´Á  | 
| #  @return None  | 
| def GiveSkill(curPlayer, skillResID, tick, isShowSys=True):  | 
|       | 
|     skillData = GameWorld.GetGameData().FindSkillByType(skillResID, 1)  | 
|     if skillData == None:  | 
|         GameWorld.DebugLog("__GiveSkill() hasn't find skill(%s)" % skillResID)  | 
|         return  | 
|     if not SkillCommon.CheckSkillJob(curPlayer, skillData):  | 
|         return  | 
|     if not SkillShell.CheckLearnSkillCondition(curPlayer, skillData):  | 
|         GameWorld.DebugLog("__GiveSkill() learn skill(%s) condition isn't enough" % skillResID)  | 
|         return  | 
|     skillManager = curPlayer.GetSkillManager()  | 
|     if skillManager.FindSkillBySkillTypeID(skillResID):  | 
|         GameWorld.DebugLog("__GiveSkill() have learned skill(%s)" % skillResID)  | 
|         return  | 
|     GameWorld.DebugLog('    ¼¤»î·¨±¦ ¼¤»î¼¼ÄÜ skillResID=%s' % (skillResID))  | 
|     skillManager.LVUpSkillBySkillTypeID(skillResID)  | 
|     if isShowSys:  | 
|         PlayerControl.NotifyCode(curPlayer, "GetSkillInfo", [skillResID])  | 
|       | 
|     DataRecordPack.DR_LearnORUPSkill(curPlayer, skillResID, 0)  | 
|     #·¨±¦±»¶¯¼¼ÄÜÐè×°±¸²ÅÉúЧ  | 
|     if skillData.GetFuncType() != ChConfig.Def_SkillFuncType_FbPassiveSkill:  | 
|         PassiveBuffEffMng.GetPassiveEffManager().RegistPassiveEff(curPlayer, skillResID)      | 
|         if SkillCommon.isPassiveAttr(skillData):  | 
|             curControl = PlayerControl.PlayerControl(curPlayer)  | 
|             curControl.RefreshPlayerAttrState()  | 
|       | 
|     PlayerControl.PlayerControl(curPlayer).RefreshSkillFightPowerEx(skillResID, 0)  | 
|     return  | 
|   | 
|   | 
| ##--------------------------------------------------------------------------------------------------  | 
|   | 
|   | 
| def CalcMagicWeaponAttr(curPlayer):  | 
|     ## ¼ÆËã·¨±¦ÊôÐÔ  | 
|     allAttrList1 = [{} for _ in range(4)]  #ÈË×å·¨±¦  | 
|     allAttrList2 = [{} for _ in range(4)]  #ħ×å·¨±¦  | 
|     allAttrList3 = [{} for _ in range(4)]  #ÏÉ×å·¨±¦  | 
|     allAttrList4 = [{} for _ in range(4)]  #ÍõÕß·¨±¦  | 
|     mwTypeMfpTypeDict = {1:ShareDefine.Def_MFPType_MagicWeapon1,  | 
|                          2:ShareDefine.Def_MFPType_MagicWeapon2,  | 
|                          3:ShareDefine.Def_MFPType_MagicWeapon3,  | 
|                          4:ShareDefine.Def_MFPType_MagicWeapon4}  | 
|     addPowerDict = {}  #¶îÍâÕ½Á¦  | 
|     signDayMWID = IpyGameDataPY.GetFuncCfg('MWSignDayAttr', 2)  | 
|     ipyDataMgr = IpyGameDataPY.IPY_Data()  | 
|     for i in xrange(ipyDataMgr.GetTreasureCount()):  | 
|         treasureIpyData = ipyDataMgr.GetTreasureByIndex(i)  | 
|         magicWeaponID = treasureIpyData.GetID()  | 
|         isActive = GetIsActiveMagicWeapon(curPlayer, magicWeaponID)  | 
| #        if not isActive:  | 
| #            continue  | 
|         allAttrDict = {}  | 
|          | 
|         treasureType = treasureIpyData.GetTreasureType()  | 
|         if isActive:  | 
|             mfpType = mwTypeMfpTypeDict.get(treasureType, ShareDefine.Def_MFPType_Role)  | 
|             #µÈ¼¶ÊôÐÔ  | 
|             curMWLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MagicWeaponLV % magicWeaponID)  | 
|             for lv in xrange(curMWLV + 1):  | 
|                 upIpyData = IpyGameDataPY.GetIpyGameDataNotLog('TreasureUp', magicWeaponID, lv)  | 
|                 if upIpyData:  | 
|                     attrDict = upIpyData.GetAddAttr()  | 
|                     GameWorld.AddDictValue(allAttrDict, attrDict)  | 
|                     addPowerDict[mfpType] = addPowerDict.get(mfpType, 0) + upIpyData.GetPowerEx()  | 
|                       | 
|             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)  | 
|             #ÍõÕß·¨±¦ÊôÐÔ  | 
|             seasonID = IpyGameDataPY.GetFuncEvalCfg('MagicWeaponOfKing', 1, {}).get(magicWeaponID, 0)  | 
|             kingAwardLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_CrossPK_SeasonAwardLV % seasonID)  | 
|             kingMWIpyData = IpyGameDataPY.GetIpyGameDataNotLog('MagicWeaponOfKing', magicWeaponID, kingAwardLV)  | 
|             if kingMWIpyData and GetIsWearMagicWeapon(curPlayer, magicWeaponID):  | 
|                 attrDict = kingMWIpyData.GetAddAttr()  | 
|                 GameWorld.AddDictValue(allAttrDict, attrDict)  | 
|           | 
|         fbpasslv = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MWFBPassLevel % magicWeaponID)  | 
|         if fbpasslv:  #¸±±¾¹Ø¿¨ÊôÐÔ  | 
|             fbipyData = IpyGameDataPY.GetIpyGameData('MagicWeaponFB', magicWeaponID, fbpasslv)  | 
|             if fbipyData:  | 
|                 attrDict = fbipyData.GetAttrDict()  | 
|                 for effID, value in attrDict.items():  | 
|                     effID = int(effID)  | 
|                     allAttrDict[effID] = allAttrDict.get(effID, 0) + value  | 
|                   | 
|         for effID, value in allAttrDict.items():  | 
|             if treasureType == 1:  | 
|                 PlayerControl.CalcAttrDict_Type(effID, value, allAttrList1)  | 
|             elif treasureType == 2:  | 
|                 PlayerControl.CalcAttrDict_Type(effID, value, allAttrList2)  | 
|             elif treasureType == 3:  | 
|                 PlayerControl.CalcAttrDict_Type(effID, value, allAttrList3)  | 
|             elif treasureType == 4:  | 
|                 PlayerControl.CalcAttrDict_Type(effID, value, allAttrList4)  | 
|             else:  | 
|                 GameWorld.ErrLog("δ֪·¨±¦ÊôÐÔ, magicWeaponID=%s,treasureType=%s,effID=%s,value=%s"   | 
|                                  % (magicWeaponID, treasureType, effID, value), curPlayer.GetPlayerID())  | 
|       | 
|     PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_MagicWeapon1, allAttrList1)  | 
|     PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_MagicWeapon2, allAttrList2)  | 
|     PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_MagicWeapon3, allAttrList3)  | 
|     PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_MagicWeapon4, allAttrList4)  | 
|     return  | 
|   | 
|   | 
| #// A5 0E ¿ªÆô·¨±¦ #tagCMOpenMagicWeapon  | 
| #  | 
| #struct    tagCMOpenMagicWeapon  | 
| #  | 
| #{  | 
| #    tagHead        Head;  | 
| #    DWORD        MWID;  | 
| #};  | 
| def OnOpenMagicWeapon(index, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     mwID = clientData.MWID  | 
|     isActive = GetIsActiveMagicWeapon(curPlayer, mwID)  | 
|     if isActive:  | 
|         GameWorld.DebugLog('    ¸Ã·¨±¦ÒÑ¿ªÆô£¡ mwID=%s' % mwID)  | 
|         return  | 
|     ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition('XBXZ', {'MWID':mwID}, True, False)  | 
|               | 
|     #ÏûºÄÎïÆ·ÅÐ¶Ï  | 
|     ipyData = GetWMIpyData(mwID)  | 
|     needItemDict = ipyData.GetNeedItem()  | 
|     if needItemDict:  | 
|         #ͨ¹ý´Ë;¾¶½âËø·¨±¦ ±ØÐëÒªÅäÏûºÄÎïÆ·  | 
|           | 
|         itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)  | 
|         lackItemDict, delInfoDict = ItemCommon.GetCostItemIndexList(needItemDict, itemPack, False)  | 
|         if lackItemDict:  | 
|             GameWorld.DebugLog("    ¿ªÆô·¨±¦ ²ÄÁϲ»×㣡mwID=%s,needItemDict=%s,lackItemDict=%s,delInfoDict=%s"   | 
|                                % (mwID, needItemDict, lackItemDict, delInfoDict))  | 
|             return  | 
|           | 
|         #¿ÛÏûºÄ  | 
|         ItemCommon.DelCostItem(curPlayer, itemPack, delInfoDict, ChConfig.ItemDel_MagicWeapon)  | 
|     elif ipyDataList:  | 
|         for ipyData in ipyDataList:  | 
|             if not GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_XBXZAwardRecord, ipyData.GetID()):  | 
|                 GameWorld.DebugLog("δÁìÈ¡¸ÃÏɱ¦Ñ°Ö÷½±Àø£¬ÎÞ·¨¼¤»î! ID=%s" % ipyData.GetID())  | 
|                 return  | 
|     elif mwID == 101: #¶¨º£ÉñÕëÌØÊâ ¿ÉÖ±½Ó»ñµÃ  | 
|         FBCommon.Notify_FB_Over(curPlayer, {FBCommon.Over_dataMapID:ChConfig.Def_FBMapID_MagicWeapon,FBCommon.Over_isPass:1})  | 
|         PlayerControl.SetCustomMap(curPlayer, 0, 0)  | 
|     else:  | 
|         return  | 
|     DoActiveMW(curPlayer, mwID)  | 
|     return  | 
|   | 
| def OnGetXBXZAward(curPlayer, index):  | 
|     ##Ïɱ¦Ñ°Ö÷Áì½±  | 
|     ipyData = IpyGameDataPY.GetIpyGameData('XBXZ', index)  | 
|     if not ipyData:  | 
|         return  | 
|     if GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_XBXZAwardRecord, index):  | 
|         GameWorld.DebugLog('    Ïɱ¦Ñ°Ö÷Áì½± ÒÑÁìÈ¡£¡ index=%s' % index)  | 
|         return  | 
|       | 
|     curType = ipyData.GetType()  | 
|     conditionList = ipyData.GetCondition()  | 
|     cnt = 0  | 
|     if curType == 1:  | 
|         #´©´÷X½×XÑÕÉ«ÊÇ·ñÌ××°X²¿Î»×°±¸  | 
|         cnt = 0  | 
|         playerEquip = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip)  | 
|         for classlv, color, suite, place in conditionList:  | 
|             equipIpyData = IpyGameDataPY.GetIpyGameData('EquipPlaceIndexMap',classlv,place)  | 
|             if not equipIpyData:  | 
|                 continue  | 
|             gridIndex = equipIpyData.GetGridIndex()  | 
|             curEquip = playerEquip.GetAt(gridIndex)  | 
|             if curEquip.IsEmpty():  | 
|                 continue  | 
|             curItemColor = curEquip.GetItemColor()  | 
|             curIsSuite = curEquip.GetSuiteID()  | 
|             if curItemColor >= color and curIsSuite >= suite:  | 
|                 cnt = 1  | 
|                 break  | 
|               | 
|     #2    ´©´÷X¼þX¼ÛXÆ·ÖÊ×°±¸    ¼þÊý    x½×|xÆ·ÖÊ  | 
|     elif curType == 2:  | 
|         playerEquip = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptEquip)  | 
|         classLV, color = conditionList  | 
|         ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition('EquipPlaceIndexMap', {'ClassLV':classLV}, True)  | 
|         if ipyDataList:  | 
|             for iData in ipyDataList:  | 
|                 gridIndex = iData.GetGridIndex()  | 
|                 curEquip = playerEquip.GetAt(gridIndex)  | 
|                 if curEquip.IsEmpty():  | 
|                     continue  | 
|                 curItemColor = curEquip.GetItemColor()  | 
|                 if curItemColor >= color:  | 
|                     cnt += 1  | 
|                       | 
|     #3    X½××°±¸×ÜÇ¿»¯µÈ¼¶    Ç¿»¯µÈ¼¶    x½×  | 
|     elif curType == 3:  | 
|         classLV = conditionList[0]  | 
|         customAttrDictPlus = PlayerControl.GetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_Plus)[2]  | 
|         classPlusLVDict = customAttrDictPlus.get("classPlusLVDict", {})  | 
|         #GameWorld.DebugLog("    curType=%s,classLV=%s,classPlusLVDict=%s" % (curType, classLV, classPlusLVDict))  | 
|         if classLV not in classPlusLVDict:  | 
|             return  | 
|         cnt = classPlusLVDict[classLV]  | 
|           | 
|     #4    X½××°±¸×ÜÉýÐǵȼ¶    ÉýÐǵȼ¶    x½×  | 
|     elif curType == 4:  | 
|         classLV = conditionList[0]  | 
|         customAttrDictStar = PlayerControl.GetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_Star)[2]  | 
|         classStarLVDict = customAttrDictStar.get("classStarLVDict", {})  | 
|         #GameWorld.DebugLog("    curType=%s,classLV=%s,classStarLVDict=%s" % (curType, classLV, classStarLVDict))  | 
|         if classLV not in classStarLVDict:  | 
|             return  | 
|         cnt = classStarLVDict[classLV]  | 
|           | 
|     #5    X½××°±¸×ÜÏ´Á¶µÈ¼¶    Ï´Á¶µÈ¼¶    x½×  | 
|     elif curType == 5:  | 
|         classLV = conditionList[0]  | 
|         customAttrDictWash = PlayerControl.GetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_Wash)[2]  | 
|         classWashLVDict = customAttrDictWash.get("classWashLVDict", {})  | 
|         #GameWorld.DebugLog("    curType=%s,classLV=%s,classWashLVDict=%s" % (curType, classLV, classWashLVDict))  | 
|         if classLV not in classWashLVDict:  | 
|             return  | 
|         cnt = classWashLVDict[classLV]  | 
|           | 
|     #6    X½××°±¸×ܱ¦Ê¯µÈ¼¶    ±¦Ê¯µÈ¼¶    x½×  | 
|     elif curType == 6:  | 
|         classLV = conditionList[0]  | 
|         customAttrDictStone = PlayerControl.GetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_Stone)[2]  | 
|         classStoneLVDict = customAttrDictStone.get("classStoneLVDict", {})  | 
|         #GameWorld.DebugLog("    curType=%s,classLV=%s,classStoneLVDict=%s" % (curType, classLV, classStoneLVDict))  | 
|         if classLV not in classStoneLVDict:  | 
|             return  | 
|         cnt = classStoneLVDict[classLV]  | 
|           | 
|     #7    ×øÆï´ïµ½X½×    ½×    ÎÞ  | 
|     elif curType == 7:  | 
|         cnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_HorserLV)  | 
|           | 
|     #8    ÌìÐÇËþ´ïµ½X²ã    ²ã    ÎÞ  | 
|     elif curType == 8:  | 
|         cnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_SkyTowerFloor)  | 
|           | 
|     #9    ·ûÓ¡Ëþ´ïµ½X²ã    ²ã    ÎÞ  | 
|     elif curType == 9:  | 
|         cnt = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_TrialTower_PassLV)  | 
|           | 
|     #10    »÷ɱXÖ»BOSS    Ö»Êý    boss¹éÀàË÷Òý  | 
|     elif curType == 10:  | 
|         bossIndex = conditionList[0]  | 
|         cnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_Boss_KillCntTotal % bossIndex)  | 
|           | 
|     #11    Éñ±ø´ïµ½X¼¶    µÈ¼¶    xÀàÐÍ  | 
|     elif curType == 11:  | 
|         gwType = conditionList[0]  | 
|         cnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponLV % gwType)  | 
|           | 
|     #12    Íæ¼ÒµÈ¼¶´ïµ½X¼¶    µÈ¼¶    ÎÞ  | 
|     elif curType == 12:  | 
|         cnt = curPlayer.GetLV()  | 
|           | 
|     #13    »ñµÃ·¨±¦XXX    ¸öÊý    ·¨±¦ID  | 
|     elif curType == 13:  | 
|         mwID = conditionList[0]  | 
|         cnt = 1 if GetIsActiveMagicWeapon(curPlayer, mwID) else 0  | 
|           | 
|     #14    ¾³½ç´ïµ½XXX    ¾³½ç    ÎÞ  | 
|     elif curType == 14:  | 
|         cnt = curPlayer.GetOfficialRank()  | 
|           | 
|     else:  | 
|         return  | 
|       | 
|     GameWorld.DebugLog("Ïɱ¦Ñ°Ö÷Áì½± ID=%s,curType=%s,cnt=%s,GetNeedCnt=%s" % (index, curType, cnt, ipyData.GetNeedCnt()))  | 
|     if cnt < ipyData.GetNeedCnt():  | 
|         GameWorld.DebugLog('    Ïɱ¦Ñ°Ö÷Áì½± , Ìõ¼þ²»Âú×ã ID=%s, cnt=%s,NeedCnt=%s' % (index, cnt, ipyData.GetNeedCnt()))  | 
|         return  | 
|       | 
|     # ¼ì²é±³°ü  | 
|     awardItemList = ipyData.GetAwardItem()  | 
|     if awardItemList:  | 
|         packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem)  | 
|         needSpace = len(awardItemList)  | 
|         if needSpace > packSpace:  | 
|             PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_998371")  | 
|             return  | 
|       | 
|     # ¸üÐÂÁì½±¼Ç¼  | 
|     GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_XBXZAwardRecord, index, 1)  | 
|       | 
|     # ¸øÎïÆ·  | 
|     if awardItemList:  | 
|         for itemID, itemCnt in awardItemList:  | 
|             ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 0, [IPY_GameWorld.rptItem])  | 
|          | 
|     #¸øÇ®  | 
|     for moneyType, value in ipyData.GetMoney():  | 
|         PlayerControl.GiveMoney(curPlayer, moneyType, value)  | 
|     SyncXBXZAwardRecord(curPlayer, [index])  | 
|     #³É¾Í  | 
|     PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_XBXZ, 1, [ipyData.GetMWID()])  | 
|     EventShell.EventRespons_XBXZ(curPlayer, ipyData.GetMWID())  | 
|     GameWorld.DebugLog('    Ïɱ¦Ñ°Ö÷Áì½±OK, ID=%s, cnt=%s' % (index, cnt))  | 
|     return  | 
|   | 
| ## Í¨ÖªÏɱ¦Ñ°Ö÷¶ÔÓ¦½±ÀøÁì½±¼Ç¼  | 
| #  @param None  | 
| #  @return  | 
| def SyncXBXZAwardRecord(curPlayer, syncIDList=[]):  | 
|     if syncIDList:  | 
|         recordIndexList = []  | 
|         for succID in syncIDList:  | 
|             recordIndexList.append(succID / 31)  | 
|     else:  | 
|         ipyDataMgr = IpyGameDataPY.IPY_Data()  | 
|         succCnt = ipyDataMgr.GetXBXZCount()  | 
|         if not succCnt:  | 
|             return  | 
|         maxSuccid = ipyDataMgr.GetXBXZByIndex(succCnt - 1).GetID()  | 
|         recordIndexList = range(maxSuccid / 31 + 1)  | 
|               | 
|     succFARPack = ChPyNetSendPack.tagMCXBXZAwardRecordList()  | 
|     succFARPack.Clear()  | 
|     succFARPack.RecordList = []  | 
|     for i in recordIndexList:  | 
|         awardRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XBXZAwardRecord % i)  | 
|         if not awardRecord:  | 
|             continue  | 
|         recordInfo = ChPyNetSendPack.tagMCXBXZAwardRecord()  | 
|         recordInfo.RecordIndex = i  | 
|         recordInfo.Record = awardRecord  | 
|         succFARPack.RecordList.append(recordInfo)  | 
|      | 
|     succFARPack.RecordCnt = len(succFARPack.RecordList)  | 
|     NetPackCommon.SendFakePack(curPlayer, succFARPack)  | 
|     return  | 
|   | 
|   | 
| #-------------------------------------------------------------------------------  | 
| #// A5 15 ÌáÉý·¨±¦µÈ¼¶ #tagCMMagicWeaponUp  | 
| #  | 
| #struct    tagCMMagicWeaponUp  | 
| #  | 
| #{  | 
| #    tagHead        Head;  | 
| #    DWORD        WMID;    //·¨±¦ID  | 
| #};  | 
| def OnMagicWeaponUp(index, clientData, tick):  | 
|     #·¨±¦Éý¼¶  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     mwID = clientData.MWID  | 
|     curMWLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MagicWeaponLV % mwID)  | 
|     nextMWLV = curMWLV + 1  | 
|     nextIpyData = IpyGameDataPY.GetIpyGameData('TreasureUp', mwID, nextMWLV)  | 
|     if not nextIpyData:  | 
|         return  | 
|     needExp = nextIpyData.GetNeedExp()  | 
|     curUpExp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MagicWeaponUpExp % mwID)  | 
|     if curUpExp < needExp:  | 
|         GameWorld.DebugLog('·¨±¦Éý¼¶¾Ñé²»×ã%s' % needExp)  | 
|         return  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MagicWeaponUpExp % mwID, curUpExp - needExp)  | 
|       | 
|     DoActiveMW(curPlayer, mwID, nextMWLV)  | 
|       | 
|     return  | 
|   | 
|   | 
| def AddMagicWeaponUpExp(curPlayer, mwID, addExp):  | 
|     #Ôö¼Ó·¨±¦Éý¼¶¾Ñé  | 
|     GameWorld.DebugLog('Ôö¼Ó·¨±¦Éý¼¶¾Ñé mwID=%s,addExp=%s' % (mwID, addExp))  | 
|     curUpExp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MagicWeaponUpExp % mwID)  | 
|     PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_MagicWeaponUpExp % mwID, curUpExp + addExp)  | 
|     Sycn_MagicWeaponLV(curPlayer, mwID)  | 
|     # Ã¿Èջ  | 
|     ipyData = GetWMIpyData(mwID)  | 
|     mwType = ipyData.GetTreasureType() if ipyData else 0  | 
|     if mwType == 1:  | 
|         PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_MagicWeapon)  | 
|     return  | 
|   | 
|   | 
| def Sycn_MagicWeaponLV(curPlayer, mwID=-1):  | 
|     #֪ͨ·¨±¦µÈ¼¶ÐÅÏ¢  | 
|     if mwID == -1:  | 
|         isAll = True  | 
|         needCalList = []  | 
|         ipyDataMgr = IpyGameDataPY.IPY_Data()  | 
|         for i in xrange(ipyDataMgr.GetTreasureCount()):  | 
|             ipyData = ipyDataMgr.GetTreasureByIndex(i)  | 
|             needCalList.append(ipyData.GetID())  | 
|     else:  | 
|         isAll = False  | 
|         needCalList = [mwID]  | 
|     sendPack = ChPyNetSendPack.tagMCMagicWeaponLVInfo()  | 
|     sendPack.InfoList = []  | 
|     for mwID in needCalList:  | 
|         mwLv = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MagicWeaponLV % mwID)  | 
|         curUpExp = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MagicWeaponUpExp % mwID)  | 
|           | 
|         FBPassLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_MWFBPassLevel % mwID)  | 
|         isWear = GetIsWearMagicWeapon(curPlayer, mwID)  | 
|         if isAll and not mwLv and not curUpExp and not FBPassLV and not isWear:  | 
|             continue  | 
|         pack = ChPyNetSendPack.tagMCMagicWeaponInfo()  | 
|         pack.MWID = mwID  | 
|         pack.LV = mwLv  | 
|         pack.Exp = curUpExp  | 
|         pack.FBPassLV = FBPassLV  | 
|         pack.IsWear = isWear  | 
|         sendPack.InfoList.append(pack)  | 
|     sendPack.Count = len(sendPack.InfoList)  | 
|     if sendPack.Count:  | 
|         NetPackCommon.SendFakePack(curPlayer, sendPack)  | 
|     return  | 
|   | 
|   | 
|   | 
| #// A5 1D ·¨±¦Åå´÷ #tagCMWearMagicWeapon  | 
| #  | 
| #struct    tagCMWearMagicWeapon  | 
| #  | 
| #{  | 
| #    tagHead        Head;  | 
| #    DWORD        MWID;    //·¨±¦ID  | 
| #    BYTE        State;        //0-жÏ 1-Åå´÷  | 
| #};  | 
| def OnWearMagicWeapon(index, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     mwID = clientData.MWID  | 
|     if not GetIsActiveMagicWeapon(curPlayer, mwID):  | 
|         return  | 
|     isWear = clientData.State  | 
|     if isWear:  | 
|         maxCnt = IpyGameDataPY.GetFuncCfg('MagicWeaponOfKing', 2)  | 
|         hasWearCnt = 0  | 
|         for mid in IpyGameDataPY.GetFuncEvalCfg('MagicWeaponOfKing', 1, {}):  | 
|             if hasWearCnt >= maxCnt:  | 
|                 return  | 
|             if GetIsWearMagicWeapon(curPlayer, mid):  | 
|                 hasWearCnt += 1  | 
|                   | 
|     SetMagicWeaponWearState(curPlayer, mwID, isWear)  | 
|     CalcMagicWeaponAttr(curPlayer)  | 
|     PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()  | 
|     Sycn_MagicWeaponLV(curPlayer, mwID)  | 
|     return  | 
|   | 
|   | 
| def GetIsWearMagicWeapon(curPlayer, mwID):  | 
|     #»ñÈ¡·¨±¦ÊÇ·ñÅå´÷  | 
|     return GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_MagicWeaponIsWear, mwID, True)  | 
|   | 
|   | 
| def SetMagicWeaponWearState(curPlayer, mwID, state):  | 
|     #ÉèÖ÷¨±¦ÊÇ·ñÅå´÷  | 
|     GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_MagicWeaponIsWear, mwID, state, True)  | 
|     return  | 
|   | 
| #// A5 12 ¸ÐÓ¦·¨±¦ #tagCMThinkMagicWeapon  | 
| #  | 
| #struct    tagCMThinkMagicWeapon  | 
| #{  | 
| #    tagHead        Head;  | 
| #    DWORD        MWID;  | 
| #};  | 
| def OnThinkMagicWeapon(index, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     mwID = clientData.MWID  | 
|     #Ö»´¥·¢ÈÎÎñ½Ó¿Ú  | 
|     EventShell.EventRespons_ThinkMagicWeapon(curPlayer)  | 
|     return |