| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #  | 
| ##@package  | 
| #  | 
| # @todo: Ó¡¼ÇÎªÍæ¼ÒÑ¡ÔñսʿľÁé¸ùºó»á»ñµÃµÄÄÜÁ¿µã£¬SP¼¼Äܻḽ´ø¼Ó³É»òÕßÏûºÄÓ¡¼Çµã  | 
| #          | 
| # @author: Alee  | 
| # @date 2019-4-26 ÏÂÎç03:05:54  | 
| # @version 1.0  | 
| #  | 
| # @note: ÓÃXP½Ó¿Ú¼Ç¼  | 
| #  | 
| #---------------------------------------------------------------------  | 
|   | 
| import IpyGameDataPY  | 
| import PlayerControl  | 
| import GameWorld  | 
| import ChPyNetSendPack  | 
| import NetPackCommon  | 
| import ChConfig  | 
| import ShareDefine  | 
|   | 
| Def_LastYinji_Tick = "lastyjtick"   # ÉÏÒ»´ÎÓ¡¼ÇÏûʧʱ¼ä  | 
|   | 
| def AddYinji(curPlayer, cnt):  | 
|     beforeCnt = PlayerControl.GetYinjiCnt(curPlayer)  | 
|     #ÉÏÏÞ    X¸ö  | 
|     PlayerControl.SetYinjiCnt(curPlayer, min(beforeCnt + cnt, IpyGameDataPY.GetFuncCfg('Yinji', 2)))  | 
|       | 
|     if beforeCnt == 0:  | 
|         # µÚÒ»´Î¼ÓÓ¡¼ÇÐèÖØ¼ÆÊ±  | 
|         StartYinjiTick(curPlayer)  | 
|       | 
|     return  | 
|   | 
| def SubYinji(curPlayer, cnt):  | 
|     PlayerControl.SetYinjiCnt(curPlayer, max(PlayerControl.GetYinjiCnt(curPlayer) - cnt, 0))  | 
|     return  | 
|   | 
|   | 
|   | 
| # Ã¿XÃë×Ô¶¯¼õÉÙ1¸öÓ¡¼Ç  | 
| def ProcessPlayerYinji(curPlayer, tick):  | 
|     if PlayerControl.GetYinjiCnt(curPlayer) == 0:  | 
|         return  | 
|       | 
|     if tick - curPlayer.GetDictByKey(Def_LastYinji_Tick) < PlayerControl.GetLostYinjiTime(curPlayer):  | 
|         return  | 
|       | 
|     StartYinjiTick(curPlayer)  | 
|       | 
|       | 
|     SubYinji(curPlayer, 1)  | 
|       | 
|       | 
| def StartYinjiTick(curPlayer):  | 
|     curPlayer.SetDict(Def_LastYinji_Tick, GameWorld.GetGameWorld().GetTick())  | 
|     pack = ChPyNetSendPack.tagMCYinjiStartTime()  | 
|   | 
|     NetPackCommon.SendFakePack(curPlayer, pack)  | 
|       | 
|       | 
| def OnLoadMap(curPlayer):  | 
|     PlayerControl.SetYinjiCnt(curPlayer, 0)  | 
|     return  | 
|       | 
| #===============================================================================  | 
| # // B4 0D Õ½¶·Ó¡¼Ç #tagCMYinji  | 
| #   | 
| # struct    tagCMYinji  | 
| # {  | 
| #    tagHead        Head;  | 
| #    BYTE        Count;  | 
| #    BYTE        Type;    // 0 ¼Ó£¬1¼õ  | 
| # };  | 
| #===============================================================================  | 
| def OnYinji(index, clientData, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     if curPlayer.GetSightLevel() == 0:  | 
|         return  | 
|     if clientData.Type == 0:  | 
|         AddYinji(curPlayer, clientData.Count)  | 
|     elif clientData.Type == 1:  | 
|         SubYinji(curPlayer, clientData.Count)  | 
|     return  | 
|   |