| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #---------------------------------------------------------------------  | 
| #  | 
| #---------------------------------------------------------------------  | 
| ##@package Item_Add_LimitingBuff  | 
| # @todo: Ìí¼ÓÓÐ×î´óʱ¼äÉÏÏÞBuffÎïÆ·  | 
| #  | 
| # @author: zhangd  | 
| # @date 2011-03-16  | 
| # @version 1.3  | 
| #  | 
| # @change: "2011-04-02 16:30" zhangd ÐÞ¸ÄÌí¼ÓbuffʱˢÐÂÊôÐÔ  | 
| # @change: "2012-06-18 18:00" jiang ÐÞ¸ÄItemCommon.DelItemº¯ÊýµÄ²ÎÊýÓÃÓÚOssʼþ¼Ç¼  | 
| # @change: "2015-01-29 19:40" ljd ÐÞ¸ÄÎïÆ·Ê¹ÓÃÉÏÏÞϵͳÌáʾ²ÎÊý  | 
| #---------------------------------------------------------------------  | 
| #"""Version = 2015-01-29 19:40"""  | 
| #---------------------------------------------------------------------  | 
| import GameWorld  | 
| import PlayerControl  | 
| import ItemCommon  | 
| import SkillCommon  | 
| import IpyGameDataPY  | 
| import ChConfig  | 
| #---------------------------------------------------------------------  | 
| #×î´óʹÓÃʱ¼ä  | 
| Def_MaxUseTime = 576 * 60 * 60 * 1000                               | 
| #---------------------------------------------------------------------  | 
|   | 
|   | 
| def BatchUseItem(curPlayer, curRoleItem, tick, useCnt, exData):  | 
|     curRoleItemID = curRoleItem.GetItemTypeID()  | 
|       | 
|     if curRoleItem.GetAddSkillCount() <= 0:  | 
|         return False  | 
|       | 
|     curSkillID = curRoleItem.GetAddSkill(0)  | 
|       | 
|     if not curSkillID:  | 
|         return False  | 
|       | 
|     curSkill = GameWorld.GetGameData().GetSkillBySkillID(curSkillID)  | 
|       | 
|     if not curSkill:  | 
|         GameWorld.ErrLog('Ìí¼ÓÓÐ×î´óʱ¼äÉÏÏÞBuffÎïÆ· = %s Ê¹ÓÃÒì³£, ÎÞ·¨»ñÈ¡¸½¼Ó¼¼ÄÜ = %s'%(curRoleItemID, curSkillID))  | 
|         return False  | 
|       | 
|     #--»ñÈ¡ÊÇ·ñÒѾÌí¼Ó¹ý¸ÃBuff--  | 
|     buffType = SkillCommon.GetBuffType(curSkill)  | 
|     buffTuple = SkillCommon.GetBuffManagerByBuffType(curPlayer, buffType)  | 
|     #ͨ¹ýÀàÐÍ»ñȡĿ±êµÄbuff¹ÜÀíÆ÷Ϊ¿Õ£¬ÔòÌø³ö  | 
|     if buffTuple == ():  | 
|         return  | 
|       | 
|     buffState = buffTuple[0]  | 
|     #¿ÉÌí¼ÓµÄ³ÖÐøÊ±¼ä  | 
|     curSkillLastTime = curSkill.GetLastTime()*useCnt  | 
|     #»ñÈ¡buff  | 
|     curBuff = buffState.FindBuff(curSkillID)  | 
|     if curBuff:     | 
|         #µ±Ç°buffÊ£Óàʱ¼ä  | 
|         curBuffRemainTime = curBuff.GetRemainTime()  | 
|           | 
|         #ÀÛ¼ÓÊý¾Ý  | 
|         sumTime = curSkillLastTime + curBuffRemainTime  | 
|         #¼ì²éÀÛ¼Óʱ¼äÊÇ·ñ³¬¹ýÉÏÏÞ  | 
|         if sumTime > Def_MaxUseTime:  | 
|             #ÎïÆ·Ê¹ÓÃÉÏÏÞ24Ì죬³¬¹ýÎÞ·¨Ê¹Óà  | 
|             PlayerControl.NotifyCode(curPlayer, 'Item_Effect_Max', [curRoleItemID, Def_MaxUseTime / (60 * 60 * 1000)])  | 
|             return False          | 
|   | 
|     if not ItemCommon.ItemUseSkillAddBuff(curPlayer, curRoleItem, tick, True, useCnt):  | 
|         return False  | 
|     if curRoleItemID not in IpyGameDataPY.GetFuncEvalCfg('UnShowMsgBuffItemID', 1):  | 
|         if curSkillLastTime:  | 
|             PlayerControl.NotifyCode(curPlayer, 'UseItem1', [curRoleItemID, curSkillID, curSkillLastTime])  | 
|         else:  | 
|             PlayerControl.NotifyCode(curPlayer, 'UseItem3', [curRoleItemID, curSkillID])  | 
|     #µ÷ÓÃͨÓýӿÚɾ³ýµÀ¾ß  | 
|     ItemCommon.DelItem(curPlayer, curRoleItem, useCnt, True, ChConfig.ItemDel_Add_LimitingBuff)  | 
|     return True, useCnt  | 
|   | 
|   | 
| ## Â߼ʵÏÖ //·µ»ØÖµÎªÊÇ·ñʹÓóɹ¦(Íâ²ãÍ¨ÖªÌØÐ§)  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param curRoleItem µ±Ç°Ö÷½ÇʹÓõÄÎïÆ·  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return True or False ·µ»ØÖµÎªÊÇ·ñʹÓóɹ¦(Íâ²ãÍ¨ÖªÌØÐ§)  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def UseItem(curPlayer, curRoleItem, tick):  | 
|     BatchUseItem(curPlayer, curRoleItem, tick, 1, 0)  | 
|     return True  | 
|   |