| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| #-------------------------------------------------------------------------------  | 
| #  | 
| ##@package SkillDataBoost  | 
| #  | 
| # @todo: ¼¼ÄÜÔöǿЧ¹û¹¦ÄÜ  | 
| # @author Alee  | 
| # @date 2013-10-31 14:45  | 
| # @version 1.3  | 
| #  | 
| # ÏêϸÃèÊö:  | 
| # @change: "2013-11-01 14:45" Alee ÐÞÕýNPCÔöÇ¿ÌØÐ§  | 
| # @change: "2015-03-05 14:30" hxp Ôö¼Ó±»¶¯buffÔöǿЧ¹û  | 
| # @change: "2016-11-16 15:30" hxp Ôö¼Ó±»¶¯buffË¥ÈõЧ¹û  | 
| #---------------------------------------------------------------------  | 
| #"""Version = 2016-11-16 15:30"""  | 
| #---------------------------------------------------------------------  | 
|   | 
| import PassiveBuffEffMng  | 
| import IPY_GameWorld  | 
| import PySkillManager  | 
| import ChConfig  | 
| import ItemControler  | 
| import SkillCommon  | 
| import SkillBoosts  | 
| import GameWorld  | 
| import BuffSkill  | 
| #µ¼Èë  | 
| GameWorld.ImportAll("Script\\Skill\\", "SkillBoosts")  | 
|   | 
| # ¼ÆËãÁбíË÷Òý   | 
| #[¼¼ÄÜID£¬ ÔöÇ¿ÀàÐÍ£¬¼¼ÄÜЧ¹ûID£¬¸¸¼¼ÄÜ£¨ÈçÕÙ»½£©£¬ÊýÖµ]  | 
| (  | 
| Def_SkillTypeID, # ¼¼ÄÜID  | 
| Def_BoostType, # ÔöÇ¿ÀàÐÍ  | 
| Def_SkillEffectID, # ¼¼ÄÜЧ¹ûID  | 
| Def_ParentSkillTypeID, # ¸¸¼¼ÄÜ£¨ÈçÕÙ»½£©  | 
| Def_BoostValue, # ÊýÖµ  | 
| ) = range(5)  | 
|   | 
| # ¼ÆËã¼õÈõÁбíË÷Òý   | 
| #[¼¼ÄÜID£¬ ¼õÈõÀàÐÍ£¬¼¼ÄÜЧ¹ûID£¬¸¸¼¼ÄÜ£¨ÈçÕÙ»½£©£¬Õë¶ÔµÄbuff״ֵ̬, ÊýÖµ]  | 
| (  | 
| Def_WeakSkillTypeID, # ¼õÈõµÄ¼¼ÄÜID  | 
| Def_WeakType, # ¼õÈõÀàÐÍ  | 
| Def_WeakSkillEffectID, # ¼¼ÄÜЧ¹ûID  | 
| Def_WeakParentSkillTypeID, # ¸¸¼¼ÄÜ£¨ÈçÕÙ»½£©  | 
| Def_WeakBuffState, # Õë¶ÔµÄ¼¼ÄÜbuff״ֵ̬  | 
| Def_WeakValue, # ÊýÖµ  | 
| ) = range(6)  | 
|   | 
|   | 
| ##¼¼ÄÜÔöÇ¿¸Ä±äskilldata½á¹¹  | 
| # @param isEnhanceSkill ÊÇ·ñ¸½¼Ó¼¼ÄÜ  | 
| # @return skilldata  | 
| def ChangeSkillData(attacker, defender, skillData, isEnhanceSkill):  | 
|     # ´¦Àí¹¥»÷·½ÔöÇ¿  | 
|     #skillData = __BoostSkillData(attacker, skillData, isEnhanceSkill)  | 
|     # ´¦Àí·ÀÊØ·½¼õÈõ  | 
|     #skillData = __WeakenSkillData(defender, skillData, isEnhanceSkill)  | 
|     return skillData  | 
|   | 
| def __BoostSkillData(attacker, skillData, isEnhanceSkill):  | 
|     # ¼¼ÄÜÔöÇ¿´¦Àí  | 
|     atkObjType = attacker.GetGameObjType()  | 
|     skillBoostList = []  | 
|       | 
|     # ÕÒµ½ÔöÇ¿¶ÓÁÐ  | 
|     if atkObjType == IPY_GameWorld.gotNPC:  | 
|         if attacker.GetDictByKey(ChConfig.Def_SummonBoost_Count) == 0:  | 
|             #¼¼ÄÜδÔöÇ¿  | 
|             return skillData  | 
|           | 
|         #NPC Õâ±ßÒª½¨Á¢ÁÐ±í  | 
|         skillBoostList = GetNPCSkillBoostList(attacker)  | 
|           | 
|     elif atkObjType == IPY_GameWorld.gotPlayer:  | 
|       | 
|         #±»¶¯buffÔöÇ¿  | 
|         passiveBuffBoostList = []#PassiveBuffEffMng.GetPassiveSkillBoostList(attacker)  | 
|         skillBoostList.extend(passiveBuffBoostList)  | 
|           | 
|     if skillBoostList == []:  | 
|         #ûÓÐÔöǿЧ¹û¶ÓÁÐÍ˳ö  | 
|         return skillData  | 
|       | 
|     skillTypeID = skillData.GetSkillTypeID()  | 
|     needBoost = False  | 
|     for tmpList in skillBoostList:  | 
|         if skillTypeID == tmpList[Def_SkillTypeID] \  | 
|         and tmpList[Def_BoostType] != ChConfig.BoostType_HappenRate:  | 
|             needBoost = True  | 
|             break  | 
|               | 
|     if not needBoost:  | 
|         #¸Ã¼¼Äܲ»ÔÚÔöǿЧ¹ûÖÐÍ˳ö  | 
|         return skillData  | 
|       | 
|     # ´¥·¢¼¼ÄܺÍÖ÷¶¯¼¼ÄÜÐè·Ö¿ª´¦Àí£¬·ñÔòÊý¾Ý´íÂÒ  | 
|     if isEnhanceSkill:  | 
|         PySkillManager.Py_SkillDataTrigger.CopySkillData(skillData)  | 
|         skillData = PySkillManager.Py_SkillDataTrigger  | 
|     else:  | 
|         PySkillManager.Py_SkillData.CopySkillData(skillData)  | 
|         skillData = PySkillManager.Py_SkillData  | 
|       | 
|     #ÓжÔÓ¦ÔöǿЧ¹ûµÄ´¦Àí  | 
|     for skillBoostInfo in skillBoostList:  | 
|         if skillTypeID != skillBoostInfo[Def_SkillTypeID]:  | 
|             continue  | 
|           | 
|         pyName = "SkillBoost_%s"%skillBoostInfo[Def_BoostType]  | 
|         callFunc = GameWorld.GetExecFunc(SkillBoosts, "%s.OnCalcSkillValue"%pyName)  | 
|           | 
|         if callFunc is None:  | 
|             continue  | 
|           | 
|         callFunc(skillData, skillBoostInfo[Def_SkillEffectID], skillBoostInfo[Def_BoostValue])  | 
|     return skillData  | 
|   | 
| def __WeakenSkillData(defender, skillData, isEnhanceSkill):  | 
|     # ¼¼ÄܼõÈõ´¦Àí  | 
|       | 
|     if not defender:  | 
|         return skillData  | 
|       | 
|     objType = defender.GetGameObjType()  | 
|     skillWeakenList = []  | 
|       | 
|     # ÕÒµ½¼õÈõ¶ÓÁÐ  | 
|     if objType == IPY_GameWorld.gotPlayer:  | 
|         #±»¶¯buff¼õÈõ  | 
|         passiveBuffWeakenList = []#PassiveBuffEffMng.GetPassiveSkillWeakenList(defender)  | 
|         skillWeakenList.extend(passiveBuffWeakenList)  | 
|           | 
|     if skillWeakenList == []:  | 
|         #ûÓмõÈõЧ¹û¶ÓÁÐÍ˳ö  | 
|         return skillData  | 
|       | 
|     skillTypeID = skillData.GetSkillTypeID()  | 
|     needWeaken = False  | 
|     for tmpList in skillWeakenList:  | 
|         if tmpList[Def_WeakType] == ChConfig.WeakenType_HappenRate:  | 
|             continue  | 
|         if skillTypeID == tmpList[Def_WeakSkillTypeID] or tmpList[Def_WeakSkillTypeID] == 0:  | 
|             needWeaken = True  | 
|             break  | 
|               | 
|     if not needWeaken:  | 
|         #¸Ã¼¼Äܲ»ÔÚ¼õÈõЧ¹ûÖÐÍ˳ö  | 
|         return skillData  | 
|       | 
|     # ´¥·¢¼¼ÄܺÍÖ÷¶¯¼¼ÄÜÐè·Ö¿ª´¦Àí£¬·ñÔòÊý¾Ý´íÂÒ  | 
|     if not isinstance(skillData, PySkillManager.PySkillData):  | 
|         if isEnhanceSkill:  | 
|             PySkillManager.Py_SkillDataTrigger.CopySkillData(skillData)  | 
|             skillData = PySkillManager.Py_SkillDataTrigger  | 
|         else:  | 
|             PySkillManager.Py_SkillData.CopySkillData(skillData)  | 
|             skillData = PySkillManager.Py_SkillData  | 
|       | 
|     curBuffStateType = None  | 
|       | 
|     #ÓжÔÓ¦ÔöǿЧ¹ûµÄ´¦Àí  | 
|     for skillWeakenInfo in skillWeakenList:  | 
|         # Îª0ʱÕë¶ÔËùÓм¼ÄÜ  | 
|         if skillWeakenInfo[Def_WeakSkillTypeID] > 0 and skillTypeID != skillWeakenInfo[Def_WeakSkillTypeID]:  | 
|             continue  | 
|           | 
|         weakBuffState = skillWeakenInfo[Def_WeakBuffState]  | 
|         if weakBuffState > 0:  | 
|             if curBuffStateType is None:  | 
|                 curBuffStateType = SkillCommon.GetBuffStateType(skillData)  | 
|             if not curBuffStateType:  | 
|                 # ¸ÃbuffÎÞbuffÀàÐÍ£¬Õë¶ÔµÄbuffÎÞЧ  | 
|                 continue  | 
|             if not weakBuffState & pow(2, curBuffStateType):  | 
|                 # ¸ÃbuffÀàÐͲ»ÊÇËùÕë¶ÔµÄbuff, ÎÞЧ  | 
|                 continue  | 
|               | 
|         pyName = "SkillWeaken_%s" % skillWeakenInfo[Def_WeakType]  | 
|         callFunc = GameWorld.GetExecFunc(SkillBoosts, "%s.OnCalcSkillValue"%pyName)  | 
|           | 
|         if callFunc is None:  | 
|             continue  | 
|           | 
|         callFunc(skillData, skillWeakenInfo[Def_WeakSkillEffectID], skillWeakenInfo[Def_WeakValue])  | 
|     return skillData  | 
|   | 
| ## ÕÙ»½ÊÞЧ¹ûÔöÇ¿Âß¼  | 
| #  @param None  | 
| #  @return None  | 
| def SetSummonNPCSkillBoost(curPlayer, summonNPC, curSkill):  | 
|     #ÕÙ»½Ç°Çå¿Õ  | 
|     summonNPC.SetDict(ChConfig.Def_SummonBoost_Count, 0)  | 
|       | 
|     skillBoostList = []  | 
| #    #Íæ¼ÒÐèÅж¨ÎäÆ÷  | 
| #    itemControl = ItemControler.PlayerItemControler(curPlayer)  | 
| #    skillBoostList = itemControl.GetSkillBoostList()  | 
|   | 
|     #±»¶¯buffÔöÇ¿  | 
|     passiveBuffBoostList = []#PassiveBuffEffMng.GetPassiveSkillBoostList(curPlayer)  | 
|     skillBoostList.extend(passiveBuffBoostList)  | 
|   | 
|     skillTypeID = curSkill.GetSkillTypeID()  | 
|       | 
|     summonSkillBoostList = []  | 
|     for tmpList in skillBoostList:  | 
|         # Èç¹ûÖ÷¼¼ÄÜÓжà¸ö¿ÉÒÔ¿¼ÂǸijÉ×ÓÁÐ±í  | 
|         if skillTypeID == tmpList[Def_ParentSkillTypeID]:  | 
|             summonSkillBoostList.append(tmpList)  | 
|           | 
|     if summonSkillBoostList == []:  | 
|         return  | 
|       | 
|     summonNPC.SetDict(ChConfig.Def_SummonBoost_Count, len(summonSkillBoostList))  | 
|     # Èç¹ûÁбí¹ý³¤¿ÉÒÔ¿¼ÂǼǼ¼¼ÄÜÔöÇ¿Ë÷ÒýºÍÊýÖµ£¬ÆäËûÖµÓɱíÈ¡  | 
|     for i, tmpList in enumerate(summonSkillBoostList):  | 
|         summonNPC.SetDict(ChConfig.Def_SummonBoost_SkillTypeID%i, tmpList[Def_SkillTypeID])  | 
|         summonNPC.SetDict(ChConfig.Def_SummonBoost_BoostType%i, tmpList[Def_BoostType])  | 
|         summonNPC.SetDict(ChConfig.Def_SummonBoost_EffectID%i, tmpList[Def_SkillEffectID])  | 
|         summonNPC.SetDict(ChConfig.Def_SummonBoost_ParentID%i, 0)   # ×Ó¼¼Äܲ»ÔټǼ  | 
|         summonNPC.SetDict(ChConfig.Def_SummonBoost_Value%i, tmpList[Def_BoostValue])  | 
|       | 
|     return  | 
|   | 
|   | 
| ## ´æ´¢NPC£¨ÕÙ»½£©¼¼ÄÜÔöǿЧ¹û  | 
| #  @param None  | 
| #  @return None  | 
| def GetNPCSkillBoostList(curNPC):  | 
|     skillBoostList = []  | 
|     for i in xrange(curNPC.GetDictByKey(ChConfig.Def_SummonBoost_Count)):  | 
|         skillBoostList.append([curNPC.GetDictByKey(ChConfig.Def_SummonBoost_SkillTypeID%i),  | 
|                                curNPC.GetDictByKey(ChConfig.Def_SummonBoost_BoostType%i),  | 
|                                curNPC.GetDictByKey(ChConfig.Def_SummonBoost_EffectID%i),  | 
|                                curNPC.GetDictByKey(ChConfig.Def_SummonBoost_ParentID%i),  | 
|                                curNPC.GetDictByKey(ChConfig.Def_SummonBoost_Value%i)])  | 
|       | 
|     return skillBoostList  | 
|   | 
|   | 
| ## Í¨¹ý¼¼ÄÜÔöǿЧ¹ûÀàÐÍÕÒ³ö×ÔÉíµÄÔöǿЧ¹ûÖµ  | 
| #  @param boostType ÔöÇ¿ÀàÐÍ  | 
| #  @return Ôöǿֵ  | 
| def GetSkillBoostValeByType(attacker, skillData, boostType):  | 
|     atkObjType = attacker.GetGameObjType()  | 
|     skillBoostList = []  | 
|       | 
|     # ÕÒµ½ÔöÇ¿¶ÓÁÐ  | 
|     if atkObjType == IPY_GameWorld.gotNPC:  | 
|         if attacker.GetDictByKey(ChConfig.Def_SummonBoost_Count) == 0:  | 
|             #¼¼ÄÜδÔöÇ¿  | 
|             return 0  | 
|           | 
|         #NPC Õâ±ßÒª½¨Á¢ÁÐ±í  | 
|         skillBoostList = GetNPCSkillBoostList(attacker)  | 
|           | 
|     elif atkObjType == IPY_GameWorld.gotPlayer:  | 
| #        #Íæ¼ÒÐèÅж¨ÎäÆ÷  | 
| #        itemControl = ItemControler.PlayerItemControler(attacker)  | 
| #        skillBoostList = itemControl.GetSkillBoostList()  | 
|   | 
|         #±»¶¯buffÔöÇ¿  | 
|         passiveBuffBoostList = []#PassiveBuffEffMng.GetPassiveSkillBoostList(attacker)  | 
|         skillBoostList.extend(passiveBuffBoostList)  | 
|       | 
|     if skillBoostList == []:  | 
|         #ûÓÐÔöǿЧ¹û¶ÓÁÐÍ˳ö  | 
|         return 0  | 
|       | 
|     skillTypeID = skillData.GetSkillTypeID()  | 
|       | 
|     addValue = 0  | 
|     for tmpList in skillBoostList:  | 
|         if skillTypeID == tmpList[Def_SkillTypeID] and tmpList[Def_BoostType] == boostType:  | 
|             addValue += tmpList[Def_BoostValue]  | 
|               | 
|     return addValue  | 
|   | 
| ## Í¨¹ý¼¼ÄܼõÈõЧ¹ûÀàÐÍÕÒ³ö×ÔÉíµÄ¼õÈõЧ¹ûÖµ  | 
| #  @return ¼õÈõЧ¹ûÖµ  | 
| def GetSkillWeakenValeByType(curPlayer, skillData, weakType):  | 
|     if not curPlayer:  | 
|         return 0  | 
|     objType = curPlayer.GetGameObjType()  | 
|     skillWeakList = []  | 
|       | 
|     if objType == IPY_GameWorld.gotPlayer:  | 
|         #±»¶¯buff  | 
|         passiveBuffWeakList = []#PassiveBuffEffMng.GetPassiveSkillWeakenList(curPlayer)  | 
|         skillWeakList.extend(passiveBuffWeakList)  | 
|       | 
|     if skillWeakList == []:  | 
|         return 0  | 
|       | 
|     skillTypeID = skillData.GetSkillTypeID()  | 
|       | 
|     weakValue = 0  | 
|     curBuffStateType = None  | 
|     for tmpList in skillWeakList:  | 
|         # Îª0ʱÕë¶ÔËùÓм¼ÄÜ  | 
|         if tmpList[Def_WeakSkillTypeID] > 0 and skillTypeID != tmpList[Def_WeakSkillTypeID]:  | 
|             continue  | 
|           | 
|         if tmpList[Def_WeakType] != weakType:  | 
|             continue  | 
|           | 
|         weakBuffState = tmpList[Def_WeakBuffState]  | 
|         if weakBuffState > 0:  | 
|             if curBuffStateType is None:  | 
|                 curBuffStateType = SkillCommon.GetBuffStateType(skillData)  | 
|             if not curBuffStateType:  | 
|                 # ¸ÃbuffÎÞbuffÀàÐÍ£¬Õë¶ÔµÄbuffÎÞЧ  | 
|                 continue  | 
|             if not weakBuffState & pow(2, curBuffStateType):  | 
|                 # ¸ÃbuffÀàÐͲ»ÊÇËùÕë¶ÔµÄbuff, ÎÞЧ  | 
|                 continue  | 
|               | 
|         weakValue += tmpList[Def_WeakValue]  | 
|               | 
|     return weakValue  | 
|       | 
|   | 
| ## Í¨¹ýЧ¹ûID»ñµÃ¼¼ÄÜÔöǿЧ¹ûÌí¼ÓµÄBUFFÔöǿֵ  | 
| #  @param None  | 
| #  @return None  | 
| def GetBuffValueByEffectID(curSkill, effectID):  | 
|     boostBuffValue = 0  | 
|     if hasattr(curSkill, 'GetBuffValueByEffectID'):  | 
|         boostBuffValue = getattr(curSkill, 'GetBuffValueByEffectID')(effectID)  | 
|       | 
|     return boostBuffValue  | 
|   | 
| ## Í¨¹ýЧ¹ûID»ñµÃ¼¼ÄÜÔöǿЧ¹ûÌí¼ÓµÄBUFFÔöǿֵ  | 
| #  @param None  | 
| #  @return None  | 
| def GetBuffValueDict(curSkill, effectID):  | 
|     tmpDict = {}  | 
|     if hasattr(curSkill, 'GetBuffValueDict'):  | 
|         tmpDict = getattr(curSkill, 'GetBuffValueDict')()  | 
|       | 
|     return tmpDict  | 
|   | 
| #===============================================================================  | 
| #   | 
| # def AffectedSkillData(attacker, skillData, isEnhanceSkill):  | 
| #    # ¼¼ÄÜÔöÇ¿´¦Àí  | 
| #    atkObjType = attacker.GetGameObjType()  | 
| #      | 
| #    if atkObjType != IPY_GameWorld.gotPlayer:  | 
| #        return skillData  | 
| #      | 
| #    passiveEff = PassiveBuffEffMng.GetPassiveEffManager().GetPassiveEff(attacker)  | 
| #    if not passiveEff:  | 
| #        return skillData  | 
| #    #Ó°Ïì¼¼ÄܵÄBUFF  | 
| #    buffAffectInfo = passiveEff.GetChangeBuff_StartSkill(skillData.GetSkillID())  | 
| #    if not buffAffectInfo:  | 
| #        return skillData  | 
| #      | 
| #    # ´¥·¢¼¼ÄܺÍÖ÷¶¯¼¼ÄÜÐè·Ö¿ª´¦Àí£¬·ñÔòÊý¾Ý´íÂÒ  | 
| #    if isEnhanceSkill:  | 
| #        PySkillManager.Py_SkillDataTrigger.CopySkillData(skillData)  | 
| #        skillData = PySkillManager.Py_SkillDataTrigger  | 
| #    else:  | 
| #        PySkillManager.Py_SkillData.CopySkillData(skillData)  | 
| #        skillData = PySkillManager.Py_SkillData  | 
| #          | 
| #    #¸Ä±äÖ÷¶¯¼¼ÄÜ  | 
| #    passiveEff.CalcChangeBuff_StartSkill(attacker, skillData, buffAffectInfo)  | 
| #                  | 
| #    return skillData  | 
| #===============================================================================  | 
|   | 
|   | 
|   |