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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
#!/usr/bin/python
# -*- coding: GBK -*-
#
##@package PlayerGameWallow
#
# @todo: 
#
# @author: Alee
# @date 2018-3-15 ÏÂÎç08:32:14
# @version 1.0
#
# @note: 
#
#---------------------------------------------------------------------
 
 
import ChConfig
import GameWorld
import IPY_GameWorld
import ReadChConfig
import PlayerControl
import PlayerTJG
import ChPyNetSendPack
import NetPackCommon
#------------------------------------------------------------------------------
 
 
#·À³ÁÃÔ¾­ÑéϵÊý
Def_GameWallow_ExpDict = {ChConfig.Def_GameWallow_LV_1_1:1,
                            ChConfig.Def_GameWallow_LV_1_2:1,
                            ChConfig.Def_GameWallow_LV_First:1,
                            ChConfig.Def_GameWallow_LV_Second:0,
                            ChConfig.Def_GameWallow_LV_2_1:0,
                            ChConfig.Def_GameWallow_LV_2_2:0,
                            ChConfig.Def_GameWallow_LV_2_3:0,
                            ChConfig.Def_GameWallow_LV_Third:0,
                           }
 
# ·À³ÁÃÔÔÚÏßʱ¼ä·ÖÖÓ¶ÔÓ¦½×¶Î
Def_WallowLV_Time_Dict = [
                          [60, ChConfig.Def_GameWallow_LV_1_2],
                          [120, ChConfig.Def_GameWallow_LV_First],
                          [180, ChConfig.Def_GameWallow_LV_Second],
                          [210, ChConfig.Def_GameWallow_LV_2_1],
                          [240, ChConfig.Def_GameWallow_LV_2_2],
                          [270, ChConfig.Def_GameWallow_LV_2_3],
                          [300, ChConfig.Def_GameWallow_LV_Third],
                          ]
 
# µÈ¼¶£¬Ìáʾ
Def_WallowLV_Notify_Dict = {
                            ChConfig.Def_GameWallow_LV_1_2:["AvoidSink02", [1]],
                            ChConfig.Def_GameWallow_LV_First:["AvoidSink02", [2]],
                            ChConfig.Def_GameWallow_LV_Second:["AvoidSink03", [3]],
                            ChConfig.Def_GameWallow_LV_2_1:["AvoidSink03", ['3.5']],
                            ChConfig.Def_GameWallow_LV_2_2:["AvoidSink03", [4]],
                            ChConfig.Def_GameWallow_LV_2_3:["AvoidSink03", ['4.5']],
                            ChConfig.Def_GameWallow_LV_Third:["AvoidSink05", [5]],
                            }
 
 
#·À³ÁÃÔ¿ªÆô
Def_GameWallow_Open = 1
 
#·À³ÁÃÔÀëÏßÀÛ»ýʱ¼äÉÏÏÞ´ïµ½XСʱ£¬Îª½¡¿µ×´Ì¬
Def_Wallow_Offline_HealthTime = 5 * 60
#------------------------------------------------------------------------------
 
# Í¨Öª¿Í»§¶Ë·À³ÁÃÔÔÚÏßʱ¼ä
def NotifyWallowTime(curPlayer):
    sendPack = ChPyNetSendPack.tagMCPlayerWallow()
    if not GetIsWallowRole(curPlayer):
        sendPack.Open = 0
        sendPack.OnlineTime = 0
    else:
        sendPack.Open = 1
        sendPack.OnlineTime = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_Wallow_OnlineTime)/1000
        
    NetPackCommon.SendFakePack(curPlayer, sendPack)
    
    
    
##ÉÏÏß/ÇеØÍ¼·À³ÁÃÔÅж¨
# @param curPlayer Íæ¼ÒʵÀý
# @param tick Ê±¼ä´Á
# @return None
def DoLogic_CheckWallow(curPlayer, tick):
    NotifyWallowTime(curPlayer)
    if not GetIsWallowRole(curPlayer):
        #·Ç³ÁÃÔ£¬É¾³ý³ÁÃÔ״̬
        Del_Wallow(curPlayer)
        return
    
    wallowLV = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_Wallow_LV)
    
    if wallowLV != ChConfig.Def_GameWallow_LV_None:
        return
    
    #µÚÒ»´Î½øÈë·À³ÁÃÔ£¬ÉèÖÃ1¼¶³ÁÃÔ
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_Wallow_LV, ChConfig.Def_GameWallow_LV_1_1)
    PlayerControl.NotifyCode(curPlayer, "AvoidSink01")
    
    return
    
##ɾ³ýBUFF£¬È¥µô³ÁÃÔ±êʶ
# @param curPlayer Íæ¼ÒʵÀý
# @return ÎÞ 
def Del_Wallow(curPlayer):
    if curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_Wallow_LV) == ChConfig.Def_GameWallow_LV_None:
        return
    
    #Çå¿Õ±êʶ
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_Wallow_LV, ChConfig.Def_GameWallow_LV_None)
    #ÔÚÏßʱ¼äÇå¿Õ
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_Wallow_OnlineTime, 0)
    #ÀëÏßÇå¿Õ
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_Wallow_OfflineTime, 0)
 
    return
 
 
##ÉÏÏß¼ÆËãÀÛ»ýÀëÏßʱ¼ä´¦Àí·À³ÁÃÔ
# @param curPlayer Íæ¼ÒʵÀý
# @param tick Ê±¼ä´Á
# @return None
def Calc_Wallow_OfflineTime(curPlayer, tick):
    if not GetIsWallowRole(curPlayer):
        return
    
    PlayerControl.NotifyCode(curPlayer, "AvoidSink01")
    
    offMin = PlayerControl.GetPlayerLeaveServerMinute(curPlayer)
    noteOffMin = offMin + curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_Wallow_OfflineTime)
    
    #ÍÑ»ú¹Òʱ¼ä£¬ÍÑ»ú¹Òʱ¼äÇå³ý±ØÐëÔÚÕâÖ®ºó
    tjgtime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDictType_TJGNotify_Time, 0, ChConfig.Def_PDictType_TJGNotify)/60
    noteOffMin += tjgtime
    
    if noteOffMin < Def_Wallow_Offline_HealthTime:
        #δ´ïµ½½¡¿µÀëÏߣ¬¼Ç¼ʱ¼ä,Í˳ö
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_Wallow_OfflineTime, noteOffMin)
        return
    
    #ÉèÖÃΪ½¡¿µ×´Ì¬
    RevertHealthGame(curPlayer, tick)
 
 
##»Ö¸´ÎªÒ»¼¶³ÁÃÔ£¬½¡¿µÓÎÏ·
# @param curPlayer Íæ¼ÒʵÀý
# @param tick Ê±¼ä´Á
# @return None
def RevertHealthGame(curPlayer, tick):
    #ÉèÖÃ1¼¶³ÁÃÔ
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_Wallow_OfflineTime, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_Wallow_LV, ChConfig.Def_GameWallow_LV_1_1)
    
    #ÔÚÏßʱ¼äÇå¿Õ
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_Wallow_OnlineTime, 0)
    
    PlayerControl.NotifyCode(curPlayer, "AvoidSink01")
    
    return
 
 
##»ñµÃÊÇ·ñΪ·À³ÁÃÔ½ÇÉ«
# @param curPlayer Íæ¼ÒʵÀý
# @return bool
def GetIsWallowRole(curPlayer):
    if ReadChConfig.GetEvalChConfig("HealthGame_CountWallow") != Def_GameWallow_Open:
        return False
    
    if curPlayer.IsAdult() == 1:
        return False
    
    return True
 
##»Ö¸´ÎªÒ»¼¶³ÁÃÔ£¬½¡¿µÓÎÏ·
# @param curPlayer Íæ¼ÒʵÀý
# @param tick Ê±¼ä´Á
# @return None
def RevertHealthGame_OnDay(curPlayer):
    if not GetIsWallowRole(curPlayer):
        #·Ç³ÁÃÔ£¬É¾³ý³ÁÃÔ״̬
        Del_Wallow(curPlayer)
        return
    
    tick = GameWorld.GetGameWorld().GetTick()
    
    #ÉèÖÃΪ½¡¿µ×´Ì¬
    RevertHealthGame(curPlayer, tick)
    
 
##·µ»Ø³ÁÃÔºóµÄ¾­Ñé
# @param curPlayer Íæ¼ÒʵÀý
# @param addExp Ôö¼Ó¾­ÑéÖµ
# @return ¼ÆËãºóµÄ¾­Ñé
def ChangeExpByWallow(curPlayer, addExp):
    if not GetIsWallowRole(curPlayer):
        return addExp
    
    wallowLV = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_Wallow_LV)
    expMulNum = Def_GameWallow_ExpDict.get(wallowLV, 1)
        
    if expMulNum == None:
        GameWorld.ErrLog("ÎÞ·¨ÕÒµ½¾­ÑéϵÊý£¬µ±Ç°³ÁÃԵȼ¶%s ¶ÔÓ¦±í%s"%(wallowLV, Def_GameWallow_ExpDict))
        return addExp
    
    return int(addExp*expMulNum)
    
    
##³ÁÃÔÔÚÏßʱ¼ä
# @param curPlayer Íæ¼ÒʵÀý
# @param pastTick ¾­¹ýµÄʱ¼ä
# @param tick Ê±¼ä´Á
# @return none
def DoLogic_WallowOnlineTime(curPlayer, tick):
    if PlayerTJG.GetIsTJG(curPlayer):
        return
    
    if not GetIsWallowRole(curPlayer):
        return
    
    lastDealTick = curPlayer.GetTickByType(ChConfig.TYPE_Player_Tick_PlayerWallow)
    
    if lastDealTick <= 0:
        #Çл»µØÍ¼£¬ÎÞÐÅÏ¢£¬ÖØÐ¼Ç¼
        curPlayer.SetTickByType(ChConfig.TYPE_Player_Tick_PlayerWallow, tick)
        return
    
    curTimePassed = tick - lastDealTick
    
    #ˢмä¸ôûÓе½
    checkInterval = ChConfig.TYPE_Player_Tick_Time[ChConfig.TYPE_Player_Tick_PlayerWallow]
    if curTimePassed < checkInterval:
        return 
    
    curPlayer.SetTickByType(ChConfig.TYPE_Player_Tick_PlayerWallow, tick)
    
    onlineTick = min(curTimePassed + curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_Wallow_OnlineTime), 24*60*60*1000)
 
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_Wallow_OnlineTime, onlineTick)
    
    wallowLV = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_Wallow_LV)
    onlineMin = onlineTick/1000/60
    
    findLv = ChConfig.Def_GameWallow_LV_1_1
    for timeList in Def_WallowLV_Time_Dict:
        if onlineMin >= timeList[0]:
            findLv = timeList[1]
    
    # Ìá¸ßµ½¸ü¸ßµÈ¼¶ÐèÌáʾ
    if findLv > wallowLV:
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_Wallow_LV, findLv)
        notifyInfo = Def_WallowLV_Notify_Dict.get(findLv, ["AvoidSink05", [5]])
        PlayerControl.NotifyCode(curPlayer, notifyInfo[0], notifyInfo[1])
        NotifyWallowTime(curPlayer)
        return
    
    #  5Сʱºóÿ15·ÖÖÓÌáʾһ´Î
    if onlineMin > 300 and (onlineMin - 300)%15 == 0:
        PlayerControl.NotifyCode(curPlayer, "AvoidSink05", [5])
        NotifyWallowTime(curPlayer)
        return
        
    return