| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #---------------------------------------------------------------------  | 
| #  | 
| #---------------------------------------------------------------------  | 
| ##@package Item_ResetAttrPoint  | 
| # @todo: Ï´µã¾íÖá  | 
| #  | 
| # @author: xdh  | 
| # @date 2017-12-15  | 
| # @version 1.0  | 
| #  | 
| #---------------------------------------------------------------------  | 
| #"""Version = 2017-12-15 17:40"""  | 
| #---------------------------------------------------------------------  | 
|   | 
| import ChPlayer  | 
| import PlayerControl  | 
| import DataRecordPack  | 
| import IpyGameDataPY  | 
| import ItemCommon  | 
| import ChConfig  | 
| import SkillShell  | 
|   | 
| ##ÅúÁ¿Ê¹ÓÃÎïÆ·  | 
| # @param curPlayer: Íæ¼ÒʵÀý  | 
| # @param curRoleItem: ÎïÆ·ÊµÀý  | 
| # @param tick: Ê±¼ä´Á  | 
| # @param useCnt: Ê¹ÓøöÊý  | 
| # @return:   | 
| def BatchUseItem(curPlayer, curRoleItem, tick, useCnt, exData):  | 
|     curEff = curRoleItem.GetEffectByIndex(0)  | 
|     effectID = curEff.GetEffectID()  | 
|     if effectID != ChConfig.Def_Effect_ResetAttrPoint:  | 
|         return  | 
|     resetID = curEff.GetEffectValue(0)  | 
|     if not resetID and exData:  | 
|         resetID = exData  | 
|     resetPoint = curEff.GetEffectValue(1) * useCnt  | 
|     if not DoResetAttrPoint(curPlayer, resetID, resetPoint, curRoleItem.GetItemTypeID()):  | 
|         return  | 
|       | 
|     #¿Û³ýÎïÆ·  | 
|     ItemCommon.DelItem(curPlayer, curRoleItem, useCnt, True, ChConfig.ItemDel_ResetAttrPoint)  | 
|     return True, useCnt  | 
|   | 
| def DoResetAttrPoint(curPlayer, resetID, resetPoint, useItemID=0):  | 
|     '''ÖØÖÃÁé¸ùÊôÐ﵋  | 
|     @param resetID: ÖØÖÃÊôÐÔID£¬0ÎªÖØÖÃÈ«²¿  | 
|     @param resetPoint: ÖØÖõãÊý£¬0ÎªÖØÖÃÈ«²¿  | 
|     '''  | 
|       | 
|     ipyDataMgr = IpyGameDataPY.IPY_Data()  | 
|     canResetIDList = [ipyDataMgr.GetRolePointByIndex(index).GetAttrID() for index in xrange(ipyDataMgr.GetRolePointCount())]  | 
|     if resetID == 0:  | 
|         resetIDList = canResetIDList  | 
|         resetValueList = [resetPoint for _ in xrange(len(canResetIDList))]  | 
|     elif resetID in canResetIDList:  | 
|         resetIDList = [resetID]  | 
|         resetValueList = [resetPoint]  | 
|     else:  | 
|         return  | 
|       | 
|     resetPointTotal = 0  | 
|     for i, resetID in enumerate(resetIDList):  | 
|         resetPoint = resetValueList[i]  | 
|         curPoint = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AddPointValue % resetID)  | 
|         if not resetPoint:  | 
|             realResetPoint = curPoint  | 
|         else:  | 
|             realResetPoint = min(resetPoint, curPoint)  | 
|         if not realResetPoint:  | 
|             continue  | 
|         resetPointTotal += realResetPoint  | 
|         updPoint = max(curPoint - realResetPoint, 0)  | 
|         PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_AddPointValue % resetID, updPoint)  | 
|         if useItemID:  | 
|             PlayerControl.NotifyCode(curPlayer, 'WashPoint2', [useItemID, resetID, realResetPoint, updPoint])  | 
|               | 
|     freePoint = curPlayer.GetFreePoint()  | 
|     curPlayer.SetFreePoint(freePoint + resetPointTotal)  | 
|     ChPlayer.NotifyPlayerBasePoint(curPlayer, resetIDList)  | 
|     DataRecordPack.Cache_FightPowerChangeInfo(curPlayer, ChConfig.PowerDownType_ResetPoint, {'resetIDList':resetIDList, 'resetPointTotal':resetPointTotal})  | 
|       | 
|     #Ë¢ÐÂÈËÎïËùÓÐ״̬  | 
|     playerControl = PlayerControl.PlayerControl(curPlayer)  | 
|     playerControl.RefreshPlayerAttrState()  | 
|     return True  | 
|   | 
| ## Â߼ʵÏÖ //·µ»ØÖµÎªÊÇ·ñʹÓóɹ¦(Íâ²ãÍ¨ÖªÌØÐ§)  | 
| #  @param curPlayer µ±Ç°Íæ¼Ò  | 
| #  @param curRoleItem µ±Ç°Ö÷½ÇʹÓõÄÎïÆ·  | 
| #  @param tick µ±Ç°Ê±¼ä  | 
| #  @return True or False ·µ»ØÖµÎªÊÇ·ñʹÓóɹ¦(Íâ²ãÍ¨ÖªÌØÐ§)  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def UseItem(curPlayer, curRoleItem, tick):  | 
|     return BatchUseItem(curPlayer, curRoleItem, tick, 1, 0)  | 
|      |