| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #---------------------------------------------------------------------  | 
| #  | 
| #---------------------------------------------------------------------  | 
| ##@package Item_Add_HPMP  | 
| # @todo: Ò©¼ÁÎïÆ·Ê¹Óà  | 
| #  | 
| # @author: panwei  | 
| # @date 2010-04-23  | 
| # @version 2.5  | 
| #  | 
| # @change: "2010-08-09 16:00" panwei ÐÂÔö¶à´Î»Ø¸´Ò©¼ÁÂß¼  | 
| # @change: "2010-08-18 14:25" panwei ³ÖÐø²¹ºìºÍ³ÖÐø²¹ÀºÐ§¹û·Ö¿ª  | 
| # @change: "2011-02-23 17:30" panwei É¾³ýÍâ²ãͳһÁ÷Ïò¼Ç¼, µ¥¸öÎïÆ·µ÷ÓÃͳһÁ÷Ïò¼Ç¼  | 
| # @change: "2011-04-13 18:00" Alee Ìí¼Ó³èÎï¶à´Î²¹¸øÎïÆ·  | 
| # @change: "2011-04-18 13:30" Alee Ìí¼ÓϵͳÌáʾ²ÎÊý  | 
| # @change: "2012-06-18 18:00" jiang ÐÞ¸ÄItemCommon.DelItemº¯ÊýµÄ²ÎÊýÓÃÓÚOssʼþ¼Ç¼  | 
| # @change: "2012-07-18 17:40" Alee ¾«¼òÁ÷ÏòÊä³ö  | 
| # @change: "2013-07-17 20:10" Alee ÐÞ¸ÄϵͳÌáʾ  | 
| # @change: "2014-07-03 21:00" hxp Ôö¼ÓѪ°ü/À¶°ü²¹³äÁ¿ÎïÆ·  | 
| # @change: "2015-03-23 03:30" ljd Ò©¼Á²¹ÑªÔö¼ÓÖÎÁÆ(Ôö¼Ó¼õÉÙ»ØÑªÐ§¹û)Ч¹û  | 
| # @change: "2015-05-07 11:00" hxp ÐÞ¸ÄÌáʾ  | 
| # @change: "2015-05-22 20:30" hxp Ôö¼Ó³èÎï»ØÑªÑª°ü  | 
| # @change: "2016-11-03 20:30" xdh ËÀÍö²»»ØÑª  | 
| # @change: "2016-11-16 20:00" hxp Ôö¼Ó½ûÁÆ×´Ì¬ÏÂÏÞÖÆ  | 
| # @change: "2016-11-24 16:30" hxp Ôö¼Ó²»¿É»ØÑªµÄµØÍ¼É趨  | 
| #---------------------------------------------------------------------  | 
| #"""Version = 2016-11-24 16:30"""  | 
| #---------------------------------------------------------------------  | 
| #µ¼Èë  | 
| import ChConfig  | 
| import PlayerControl  | 
| import GameWorld  | 
| import ItemCommon  | 
| import Item_Txt_Skill_ByItemList  | 
| import PetControl  | 
| import SkillCommon  | 
| import BuffSkill  | 
| import IPY_GameWorld  | 
| import GameObj  | 
| #---------------------------------------------------------------------  | 
| #È«¾Ö±äÁ¿  | 
| #---------------------------------------------------------------------  | 
|   | 
| #---------------------------------------------------------------------  | 
| ## Â߼ʵÏÖ //·µ»ØÖµÎªÊÇ·ñʹÓóɹ¦(Íâ²ãÍ¨ÖªÌØÐ§)  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param curRoleItem µ±Ç°Ö÷½ÇʹÓõÄÎïÆ·  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return True or False ·µ»ØÖµÎªÊÇ·ñʹÓóɹ¦(Íâ²ãÍ¨ÖªÌØÐ§)  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def UseItem(curPlayer, curRoleItem, tick):  | 
|     if curPlayer.GetHP() <= 0 or curPlayer.GetPlayerAction() == IPY_GameWorld.paDie:  | 
|         #ËÀÍö²»»ØÑª  | 
|         return  | 
|       | 
|     if curPlayer.GetMapID() in ChConfig.CanNotRecoverMapIDList:  | 
|         #GameWorld.DebugLog("¸ÃµØÍ¼ÎÞ·¨Ê¹Óûָ´ÎïÆ·!")  | 
|         return  | 
|       | 
|     if GameObj.GetPyPlayerState(curPlayer, ChConfig.Def_PlayerState_LimitAddHP):  | 
|         # ÔÝʱºìÀ¶¶¼½ûµô  | 
|         #GameWorld.DebugLog("µ±Ç°½ûÁÆ×´Ì¬Ï£¬ÎÞ·¨Ê¹ÓûØÑªÎïÆ·!")  | 
|         return  | 
|       | 
|     useItemEff = curRoleItem.GetEffectByIndex(0)  | 
|     curEffID = useItemEff.GetEffectID()  | 
|     curEffValueA = useItemEff.GetEffectValue(0)  | 
|     curEffValueB = useItemEff.GetEffectValue(1)  | 
|   | 
|     # HP»Ö¸´Ð§¹û±ä»¯  | 
|     if curEffID in [ChConfig.Def_Effect_AddHP_Once, ChConfig.Def_Effect_AddHP_More,  | 
|                     ChConfig.Def_Effect_AddHP_Package, ChConfig.Def_Effect_AddPetHP_More]:  | 
|         # ÑªÆ¿»Ö¸´Ð§¹û¼Ó³É  | 
|         curEffValueB += PlayerControl.GetHPCureEnhance(curPlayer)  | 
|   | 
|     #²¹ºì(µ¥´Î)  | 
|     if curEffID == ChConfig.Def_Effect_AddHP_Once:  | 
|         return __DoLogic_AddHP_Once(curPlayer, curRoleItem, curEffValueA, curEffValueB)  | 
|       | 
|     #²¹À¶(µ¥´Î)  | 
|     if curEffID == ChConfig.Def_Effect_AddMP_Once:  | 
|         return __DoLogic_AddMP_Once(curPlayer, curRoleItem, curEffValueA, curEffValueB)  | 
|       | 
|     #===========================================================================  | 
|     # #²¹ºì(¶à´Î)  | 
|     # if curEffID == ChConfig.Def_Effect_AddHP_More:  | 
|     #    return __DoLogic_AddHP_More(curPlayer, curRoleItem, curEffValueA)  | 
|     #   | 
|     # #²¹À¶(¶à´Î)  | 
|     # if curEffID == ChConfig.Def_Effect_AddMP_More:  | 
|     #    return __DoLogic_AddMP_More(curPlayer, curRoleItem, curEffValueA)  | 
|     #===========================================================================  | 
|       | 
|     #³ÖÐø»Ø¸´Ñª»òÀ¶  | 
|     if curEffID in [ChConfig.Def_Effect_AddHP_Last, ChConfig.Def_Effect_AddMP_Last]:  | 
|         #µ÷ÓÃÎïÆ·´¥·¢¼¼ÄÜ  | 
|         return Item_Txt_Skill_ByItemList.UseItem(curPlayer, curRoleItem, tick)  | 
|       | 
|     #Ѫ°ü»òÀ¶°üÈÝÁ¿  | 
|     if curEffID in [ChConfig.Def_Effect_AddHP_Package, ChConfig.Def_Effect_AddMP_Package,   | 
|                     ChConfig.Def_Effect_AddPetHP_Package]:  | 
|         return __DoLogic_AddHPMP_Package(curPlayer, curRoleItem, curEffValueA, tick)  | 
|       | 
|     if curEffID == ChConfig.Def_Effect_AddPetHP_More:  | 
|         return __DoLogic_AddPetHP_More(curPlayer, curRoleItem, curEffValueA)  | 
|       | 
|     #ʹÓÃʧ°Ü  | 
|     GameWorld.ErrLog('Item_Add_HPMP effID = %s NoFind'%(curEffID))  | 
|     return False  | 
|   | 
| #===============================================================================  | 
| #---µ¥´Î»Ø¸´Âß¼--- »Ø¸´Ð§¹û = Íæ¼Òµ±Ç°ÉúÃü(ħ·¨) + Íæ¼Ò×î´óÉúÃü(ħ·¨)ÉÏÏÞ * Ð§¹ûAÖµ + Ð§¹ûBÖµ  | 
| #===============================================================================  | 
| #---------------------------------------------------------------------  | 
| ##Ò»´ÎÐÔ»ØÑªÎïÆ·Âß¼´¦Àí  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param curItem ÎïÆ·ÊµÀý  | 
| # @param effValueA Ð§¹ûAÖµ  | 
| # @param effValueB Ð§¹ûBÖµ  | 
| # @return ²¼¶ûÖµ  | 
| # @remarks Ò»´ÎÐÔ»ØÑªÎïÆ·Âß¼´¦Àí  | 
| def __DoLogic_AddHP_Once(curPlayer, curItem, effValueA, effValueB):  | 
|     curValue = curPlayer.GetHP()  | 
|     curMaxValue = curPlayer.GetMaxHP()  | 
|     setFunc = curPlayer.SetHP  | 
|     sysMsgStr = 'GeRen_chenxin_21675'  | 
|       | 
|     return __Add_HPorMP_Once(curPlayer, curItem, curValue, curMaxValue, setFunc, effValueA, effValueB, sysMsgStr)  | 
| #---------------------------------------------------------------------  | 
| ##Ò»´ÎÐÔ»ØÀ¶ÎïÆ·Âß¼´¦Àí  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param curItem ÎïÆ·ÊµÀý  | 
| # @param effValueA Ð§¹ûAÖµ  | 
| # @param effValueB Ð§¹ûBÖµ  | 
| # @return ²¼¶ûÖµ  | 
| # @remarks Ò»´ÎÐÔ»ØÀ¶ÎïÆ·Âß¼´¦Àí  | 
| def __DoLogic_AddMP_Once(curPlayer, curItem, effValueA, effValueB):  | 
|     curValue = curPlayer.GetMP()  | 
|     curMaxValue = curPlayer.GetMaxMP()  | 
|     setFunc = curPlayer.SetMP  | 
|     sysMsgStr = 'GeRen_chenxin_295695'  | 
|       | 
|     return __Add_HPorMP_Once(curPlayer, curItem, curValue, curMaxValue, setFunc, effValueA, effValueB, sysMsgStr)  | 
| #---------------------------------------------------------------------  | 
| ##µ¥´Î»Ø¸´Âß¼´¦Àí  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param curItem ÎïÆ·ÊµÀý  | 
| # @param curValue µ±Ç°Öµ  | 
| # @param curMaxValue µ±Ç°×î´óÖµ  | 
| # @param setFunc µ÷ÓÃÉèÖú¯Êý  | 
| # @param addPer °Ù·Ö±È¼Ó³É  | 
| # @param addValue ¹Ì¶¨Öµ  | 
| # @param sysMsgStr ÏµÍ³ÌáʾÏûÏ¢×Ö·û´®  | 
| # @return ²¼¶ûÖµ  | 
| # @remarks µ¥´Î²¹HP»òÕß²¹MP  | 
| def __Add_HPorMP_Once(curPlayer, curItem, curValue, curMaxValue, setFunc, addPer, addValue, sysMsgStr):  | 
|     if curValue == curMaxValue:  | 
|         PlayerControl.NotifyCode(curPlayer, sysMsgStr)  | 
|         return False  | 
|       | 
|     #»Ø¸´Ð§¹û = Íæ¼Òµ±Ç°ÉúÃü(ħ·¨) + Íæ¼Ò×î´óÉúÃü(ħ·¨)ÉÏÏÞ * Ð§¹ûAÖµ + Ð§¹ûBÖµ  | 
|     addTotalValue = int(curMaxValue * addPer / ChConfig.Def_MaxRateValue + addValue)  | 
|     #»Ø¸´ÊýÖµ  | 
|     setFunc(min(curMaxValue, curValue + addTotalValue))  | 
|     #¿Û³ýÎïÆ·  | 
|     ItemCommon.DelItem(curPlayer, curItem, 1, True)  | 
|     return True  | 
|   | 
| #===============================================================================  | 
| #--¶à´Î»Ø¸´Âß¼--- »Ø¸´Ð§¹û = Íæ¼Òµ±Ç°ÉúÃü(ħ·¨) + Ð§¹ûAÖµ  | 
| #===============================================================================  | 
| #---------------------------------------------------------------------  | 
| ##¶à´Î»ØÑªÎïÆ·Âß¼´¦Àí  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param curItem ÎïÆ·ÊµÀý  | 
| # @param effValueA Ð§¹ûAÖµ  | 
| # @return ²¼¶ûÖµ  | 
| # @remarks ¶à´Î»ØÑªÎïÆ·Âß¼´¦Àí  | 
| def __DoLogic_AddHP_More(curPlayer, curItem, effValueA):  | 
|     curValue = curPlayer.GetHP()  | 
|     curMaxValue = curPlayer.GetMaxHP()  | 
|     setFunc = curPlayer.SetHP  | 
|     sysMsgStr = 'GeRen_chenxin_21675'  | 
|       | 
|     return __Add_HPorMP_More(curPlayer, curItem, curValue, curMaxValue, setFunc, effValueA, sysMsgStr)  | 
| #---------------------------------------------------------------------  | 
| ##¶à´Î»ØÀ¶ÎïÆ·Âß¼´¦Àí  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param curItem ÎïÆ·ÊµÀý  | 
| # @param effValueA Ð§¹ûAÖµ  | 
| # @return ²¼¶ûÖµ  | 
| # @remarks ¶à´Î»ØÀ¶ÎïÆ·Âß¼´¦Àí  | 
| def __DoLogic_AddMP_More(curPlayer, curItem, effValueA):  | 
|     curValue = curPlayer.GetMP()  | 
|     curMaxValue = curPlayer.GetMaxMP()  | 
|     setFunc = curPlayer.SetMP  | 
|     sysMsgStr = 'GeRen_chenxin_295695'  | 
|       | 
|     return __Add_HPorMP_More(curPlayer, curItem, curValue, curMaxValue, setFunc, effValueA, sysMsgStr)  | 
| #---------------------------------------------------------------------  | 
| ##¶à´Î»Ö¸´Âß¼´¦Àí  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param curItem ÎïÆ·ÊµÀý  | 
| # @param curValue µ±Ç°Öµ  | 
| # @param curMaxValue µ±Ç°×î´óÖµ  | 
| # @param setFunc ÉèÖú¯Êý  | 
| # @param addValue Ìí¼ÓÖµ  | 
| # @param sysMsgStr ÏµÍ³ÌáʾÏûÏ¢×Ö·û´®  | 
| # @return ²¼¶ûÖµ  | 
| # @remarks ¶à´Î²¹HP»òÕß²¹MP  | 
| def __Add_HPorMP_More(curPlayer, curItem, curValue, curMaxValue, setFunc, addValue, sysMsgStr):  | 
|     #===========================================================================  | 
|     # #ÒѾÂúÖµ  | 
|     # if curValue == curMaxValue:  | 
|     #    PlayerControl.NotifyCode(curPlayer, sysMsgStr)  | 
|     #    return False  | 
|     #   | 
|     # curItemDurg = curItem.GetCurDurg()  | 
|     #   | 
|     # #»Ø¸´Ð§¹û = Íæ¼Òµ±Ç°ÉúÃü(ħ·¨) + Ð§¹ûAÖµ (×îºóÒ»´Î²»Ò»¶¨×ã¹»)  | 
|     # setFunc(min(curMaxValue, curValue + min(addValue, curItemDurg)))  | 
|     #   | 
|     # #---ÎïÆ·Ä;üõÉÙ---  | 
|     # if curItemDurg > addValue:  | 
|     #    curItem.SetCurDurg(curItemDurg - addValue)  | 
|     # else:  | 
|     #    ItemCommon.DelItem(curPlayer, curItem, 1, True)  | 
|     #===========================================================================  | 
|           | 
|     return True  | 
|   | 
|   | 
| ##³èÎï¶à´Î»ØÑªÎïÆ·Âß¼´¦Àí  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param curRoleItem ÎïÆ·ÊµÀý  | 
| # @param curEffValueA Ð§¹ûAÖµ  | 
| # @return ²¼¶ûÖµ  | 
| def __DoLogic_AddPetHP_More(curPlayer, curRoleItem, curEffValueA):  | 
| #===============================================================================  | 
| #    fightPetObj = curPlayer.GetPetMgr().GetFightPet()  # ³öÕ½µÄ³èÎï¶ÔÏó  | 
| #      | 
| #    if fightPetObj == None:  | 
| #        PlayerControl.NotifyCode(curPlayer, "Pet_liubo_381601", [curRoleItem.GetItemTypeID()])  | 
| #        return False  | 
| #      | 
| #    curValue = fightPetObj.GetHP()  | 
| #    curMaxValue = fightPetObj.GetMaxHP()  | 
| #    #ÒѾÂúÖµ  | 
| #    if curValue == curMaxValue:  | 
| #        PlayerControl.NotifyCode(curPlayer, "Pet_liubo_493922")  | 
| #        return False  | 
| #      | 
| #    curItemDurg = curRoleItem.GetCurDurg()  | 
| #   | 
| #    #»Ø¸´Ð§¹û = µ±Ç°ÉúÃü + Ð§¹ûAÖµ(×îºóÒ»´Î²»Ò»¶¨¹»)  | 
| #    PetControl.AddPetHP(fightPetObj, min(curEffValueA, curItemDurg))  | 
| #      | 
| #    #---ÎïÆ·Ä;üõÉÙ---  | 
| #    if curItemDurg > curEffValueA:  | 
| #        curRoleItem.SetCurDurg(curItemDurg - curEffValueA)  | 
| #    else:  | 
| #        ItemCommon.DelItem(curPlayer, curRoleItem, 1, True)  | 
| #          | 
| #===============================================================================  | 
|     return True  | 
|   | 
|   | 
| ##Ѫ°ü/À¶°ü²¹³ä°ü  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param curRoleItem ÎïÆ·ÊµÀý  | 
| # @param curEffValueA Ð§¹ûAÖµ  | 
| # @return ²¼¶ûÖµ  | 
| def __DoLogic_AddHPMP_Package(curPlayer, curRoleItem, curEffValueA, tick):  | 
|     # Ê¹Óõȼ¶  | 
|     if curPlayer.GetLV() < curRoleItem.GetUseLV():  | 
|         return False  | 
|       | 
|     addSkillID = curRoleItem.GetAddSkill(0)  | 
|       | 
|     if not addSkillID:  | 
|         return False  | 
|       | 
|     addSkill = GameWorld.GetGameData().GetSkillBySkillID(addSkillID)  | 
|   | 
|     buffType = SkillCommon.GetBuffType(addSkill)  | 
|     BuffSkill.AddBuffNoRefreshState(curPlayer, buffType, addSkill, tick, [curEffValueA], curPlayer)  | 
|     # ¼¤»îÍæ¼Ò(±£Ö¤³ÖÐøÐÔBuff´¦Àí¼ä¸ô)  | 
|     PlayerControl.SetIsNeedProcess(curPlayer, True)  | 
|     # ¿Û³ýÎïÆ·  | 
|     ItemCommon.DelItem(curPlayer, curRoleItem, 1, True)  | 
|     return True  | 
|   |