1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/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