hxp
2023-08-01 8bb11f630222dfe8d264d915ca7b638167af95eb
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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
#!/usr/bin/python
# -*- coding: GBK -*-
#
#
##@package PlayerDienstgrad.py
#
# @todo: Íæ¼Ò³ÆºÅ¹ÜÀí
# @author: alee
# @date: 2017-07-26 22£º00
# @version 1.0
# ÏêϸÃèÊö:
# @change: 2017-10-18 21:00 alee ²ß»®ÐèÇóÈ¥³ýµãÁÁ³ÆºÅÂß¼­
#------------------------------------------------------------------------------ 
"""Version = 2017-07-26 22£º00"""
#------------------------------------------------------------------------------ 
 
#µ¼Èë
import GameWorld
import PlayerControl
import IPY_GameWorld
import ChConfig
import ReadChConfig
import IpyGameDataPY
import SkillCommon
import SkillShell
import PassiveBuffEffMng
import DataRecordPack
import CrossPlayerData
import GameFuncComm
import ShareDefine
 
import time
#-------------------------------------------------------------
#####ͨ¹ýPlayer¶ÔÏó½Ó¿Ú#####
 
 
## ²éÕÒÍæ¼ÒÖ¸¶¨³ÆºÅ
#  @param curPlayer
#  @param dienstgradID ³ÆºÅID
#  @return ³ÆºÅʵÀý
def PlayerGetDienstgrad(curPlayer, dienstgradID):    
    if curPlayer == None:
        #Íæ¼Ò²»ÔÚÏß
        return None
    curDienstgradMgr = curPlayer.GetDienstgradManager()
    curDienstgrad = curDienstgradMgr.GetDienstgrad(dienstgradID)
    return curDienstgrad
 
 
def GetDienstgradData(dienstgradID):
    return IpyGameDataPY.GetIpyGameData('Dienstgrad', dienstgradID)
 
def PlayerDelAddDienstgrad(curPlayer, delDienstgradIDList, addDienstgradIDList):
    ## Íæ¼Òɾ³ý³ÆºÅµÄͬʱ£¬Ôö¼Ó³ÆºÅ£¬Ò»°ãÓÃÓڳƺŻ¥³âµÄÔöɾ±ä¸üͬ²½´¦Àí
    if not delDienstgradIDList and not addDienstgradIDList:
        return
    
    isRefresh = False
    for dienstgradID in delDienstgradIDList:
        if PlayerDelDienstgrad(curPlayer, dienstgradID, isRefreshAttr=False):
            isRefresh = True
        
    for dienstgradID in addDienstgradIDList:
        if PlayerAddDienstgrad(curPlayer, dienstgradID, isDelRepeat=False, isRefreshAttr=False):
            isRefresh = True
        
    #ÖØÐÂˢнÇÉ«ÊôÐÔ
    if isRefresh:
        CalcAllDienstgradAttr(curPlayer)
        playerControl = PlayerControl.PlayerControl(curPlayer)
        playerControl.RefreshPlayerAttrState()
    return isRefresh
 
## Ìí¼ÓÍæ¼Ò³ÆºÅ
#  @param curPlayer
#  @param dienstgradID ³ÆºÅID
#  @param isDelRepeat ÊÇ·ñɾ³ýÖØ¸´³ÆºÅ
#  @return ÊÇ·ñÌí¼Ó³É¹¦
def PlayerAddDienstgrad(curPlayer, dienstgradID, isDelRepeat=True, isRefreshAttr=True, expireTime=0):
 
    if dienstgradID <= 0:
        return False
    
    #²éϵͳ±íÊý¾Ý
    curDienstgradData = GetDienstgradData(dienstgradID)
    if curDienstgradData == None:
        return False
    
    curDienstgradMgr = curPlayer.GetDienstgradManager()
    
    #curOldGradID = curDienstgradMgr.GetCurGradID()
    
    #ÖØ¸´Ìí¼Ó³ÆºÅ, ÏÞʱµÄÐèҪɾ³ýÖØÉèË¢ÐÂʱ¼ä
    curDienstgrad = curDienstgradMgr.GetDienstgrad(dienstgradID)
    if curDienstgrad:
        if isDelRepeat:
            curDienstgradMgr.DeleteDienstgrad(dienstgradID)
        else:
            return True
        
        
    #¼ì²é»¥³âµÄ³ÆºÅÀàÐÍ
#    curType = curDienstgradData.GetType()
#    ExcludeDienstgradType = ReadChConfig.GetEvalChConfig("ExcludeDienstgradType")
#    if curType in ExcludeDienstgradType:
#        #»¥³âµÄ³ÆºÅÀàÐÍ ÐèҪɾµôͬÀàÐͳƺÅ
#        curTypeIDList = IpyGameDataPY.DienstgradData.GetTypeIDList(curType)
#        for id in curTypeIDList:
#            if id == dienstgradID:
#                continue
#            curDienstgrad = curDienstgradMgr.GetDienstgrad(id)
#            if curDienstgrad == None:
#                #Íæ¼Ò³ÆºÅ²»´æÔÚ
#                continue
#            #Èç¹ûµ±Ç°×°±¸³ÆºÅ±»É¾£¬ÐèÒª¹ã²¥
#            if curOldGradID == id:
#                PlayerTakeOffDienstgrad(curPlayer)
#            
#            curDienstgradMgr.DeleteDienstgrad(id)
#            #֪ͨ³ÆºÅɾ³ý
#            curDienstgradMgr.Sync_PlayerDelDienstgrad(id)
    
    #Ìí¼Ó³ÆºÅ
    curDienstgrad = curDienstgradMgr.AddDienstgrad(dienstgradID) 
    
    if expireTime != 0:
        curDienstgrad.SetExpireTime(expireTime)
    curDienstgradMgr.Sync_PlayerGetDienstgrad(dienstgradID)
    
    # Ñ§Ï°¼¼ÄÜ
    skillList = curDienstgradData.GetSkills()
 
    for skillID in skillList:
        __GiveSkill(curPlayer, skillID)
        
    CrossPlayerData.OnDienstgradChange(curPlayer, dienstgradID, 1)
    if dienstgradID == IpyGameDataPY.GetFuncCfg("TitleAddPoint"):
        __DoTitleAddPoint(curPlayer)
    #ÖØÐÂˢнÇÉ«ÊôÐÔ
    if isRefreshAttr:
        CalcAllDienstgradAttr(curPlayer)
        playerControl = PlayerControl.PlayerControl(curPlayer)
        playerControl.RefreshPlayerAttrState()
    return True
 
 
# »ñµÃ³ÆºÅ¼Óµã
def __DoTitleAddPoint(curPlayer):
    if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_AddPoint):
        # Î´¿ªÆôǰ²»¿É¼Óµã£¬ÒòΪDoAddPointOpen»áÒ»´ÎÐÔ²¹Æë£¬±ÜÃâÒâÍâÇé¿ö¶à¼ÓÁ˵ãÊý
        return
    addPointDict = IpyGameDataPY.GetFuncEvalCfg("LVUPAddPoint", 1, {})
    titleAddPoint = PlayerControl.GetTitleAddExtraPoint(curPlayer)
    if titleAddPoint <=0:
        return
    curLV = curPlayer.GetLV()
    addFreePoint = 0
    for rangLVs, point in addPointDict.items():
        if curLV < rangLVs[0]:
            continue
        addFreePoint += titleAddPoint * (min(curLV, rangLVs[1]) - rangLVs[0] + 1)
    freePoint = curPlayer.GetFreePoint()
    updFreePoint = freePoint + addFreePoint
    curPlayer.SetFreePoint(updFreePoint)
    GameWorld.DebugLog("»ñµÃ³ÆºÅÔö¼Ó×ÔÓÉÊôÐÔµã: freePoint=%s,addFreePoint=%s,curLV=%s,updFreePoint=%s" 
                       % (freePoint, addFreePoint, curLV, updFreePoint))
    
    return
 
# ´Ó³ÆºÅ»ñµÃ¼¼ÄÜ
def __GiveSkill(curPlayer, skillResID):
    
    skillData = GameWorld.GetGameData().FindSkillByType(skillResID, 1)
    if skillData == None:
        GameWorld.DebugLog("__GiveSkill() hasn't find skill(%s)" % skillResID)
        return
    if not SkillCommon.CheckSkillJob(curPlayer, skillData):
        return
    if not SkillShell.CheckLearnSkillCondition(curPlayer, skillData):
        GameWorld.DebugLog("__GiveSkill() learn skill(%s) condition isn't enough" % skillResID)
        return
    skillManager = curPlayer.GetSkillManager()
    if skillManager.FindSkillBySkillTypeID(skillResID):
        GameWorld.DebugLog("__GiveSkill() have learned skill(%s)" % skillResID)
        return
 
    skillManager.LVUpSkillBySkillTypeID(skillResID)
    
    PassiveBuffEffMng.GetPassiveEffManager().RegistPassiveEff(curPlayer, skillResID)    
    
    PlayerControl.PlayerControl(curPlayer).RefreshSkillFightPowerEx(skillResID, 0)
    return
 
 
# ³ÆºÅ¹ýÆÚɾ³ý¼¼ÄÜ
def __DelSkill(curPlayer, curDienstgradData):
    # Ñ§Ï°¼¼ÄÜ
    skillList = curDienstgradData.GetSkills()
    isDel = False
    for skillResID in skillList:
        skillManager = curPlayer.GetSkillManager()
        if not skillManager.FindSkillBySkillTypeID(skillResID):
            continue
    
        skillManager.DeleteSkillBySkillTypeID(skillResID)
        isDel = True
        
    if not isDel:
        return
    
    # ÖØË¢±»¶¯¼¼ÄÜ
    PassiveBuffEffMng.GetPassiveEffManager().RegistPassiveEff(curPlayer)    
    # ÖØË¢¼¼ÄÜÕ½Á¦
    PlayerControl.PlayerControl(curPlayer).RefreshAllSkill()
    return
 
## É¾³ýÍæ¼Ò³ÆºÅ
#  @param curPlayer
#  @param dienstgradID ³ÆºÅID
#  @return None
def PlayerDelDienstgrad(curPlayer, dienstgradID, isRefreshAttr=True, notifyMail=""):
    if curPlayer == None:
        #Íæ¼Ò²»ÔÚÏß
        return
    
    if dienstgradID <= 0:
        return
    
    curDienstgradMgr = curPlayer.GetDienstgradManager()
    curDienstgrad = curDienstgradMgr.GetDienstgrad(dienstgradID)
    if curDienstgrad == None:
        #Íæ¼Ò³ÆºÅ²»´æÔÚ
        return
    
    #Èç¹ûµ±Ç°×°±¸³ÆºÅ±»É¾£¬ÐèÒª¹ã²¥
    if curDienstgradMgr.GetCurGradID() == dienstgradID:
        PlayerTakeOffDienstgrad(curPlayer)
        
    #===========================================================================
    # if curDienstgradMgr.GetUseGradID() == dienstgradID:
    #    UnUseDienstgrad(curPlayer)
    #===========================================================================
        
    curDienstgradMgr.DeleteDienstgrad(dienstgradID)
    #֪ͨ³ÆºÅɾ³ý
    curDienstgradMgr.Sync_PlayerDelDienstgrad(dienstgradID)
    
    curDienstgradData = GetDienstgradData(dienstgradID)
    if curDienstgradData:
        # É¾³ý¶ÔÓ¦¼¼ÄÜ
        __DelSkill(curPlayer, curDienstgradData)
    DataRecordPack.Cache_FightPowerChangeInfo(curPlayer, ChConfig.PowerDownType_Title, {'dienstgradID':dienstgradID})
    
    CrossPlayerData.OnDienstgradChange(curPlayer, dienstgradID, 0)
    #ÖØÐÂˢнÇÉ«ÊôÐÔ
    if isRefreshAttr:
        CalcAllDienstgradAttr(curPlayer)
        playerControl = PlayerControl.PlayerControl(curPlayer)
        playerControl.RefreshPlayerAttrState()
        
    if notifyMail != "":
        PlayerControl.SendMailByKey(notifyMail, [curPlayer.GetPlayerID()], [], [dienstgradID, dienstgradID])
        
    return True
 
## ´©×ÅÍæ¼Ò³ÆºÅ
#  @param curPlayer
#  @param dienstgradID ³ÆºÅID
#  @return None   
def PlayerFitOnDienstgrad(curPlayer, dienstgradID):
 
    curDienstgradMgr = curPlayer.GetDienstgradManager()
    curDienstgrad = curDienstgradMgr.GetDienstgrad(dienstgradID)
    if curDienstgrad == None:
        #Íæ¼Ò³ÆºÅ²»´æÔÚ
        return
    curOldGradID = curDienstgradMgr.GetCurGradID()
    if curOldGradID == dienstgradID:
        #ÒÑ×°±¸¸Ã³ÆºÅ
        return
    curDienstgradMgr.SetCurGradID(dienstgradID)
    curDienstgradMgr.Notify_PlayerChangeDienstgrad(dienstgradID)
 
    return
 
## Ð¶ÏÂÍæ¼Ò³ÆºÅ
#  @param curPlayer
#  @return None
def PlayerTakeOffDienstgrad(curPlayer):
 
    curDienstgradMgr = curPlayer.GetDienstgradManager()
    curOldGradID = curDienstgradMgr.GetCurGradID()
    if curOldGradID == 0:
        return
    curDienstgradMgr.SetCurGradID(0)
    curDienstgradMgr.Notify_PlayerChangeDienstgrad(0)
 
    return
 
## ²»Ê¹Óã¨Åå´÷£©³ÆºÅ£¬ÓÃÓÚ¼¤»îÊôÐÔ£¬²»ÏÔʾ³¡¾°ÖÐ
#  @param curPlayer
#  @return None
def UnUseDienstgrad(curPlayer):
 
    curDienstgradMgr = curPlayer.GetDienstgradManager()
    curOldGradID = curDienstgradMgr.GetUseGradID()
    if curOldGradID == 0:
        return False
    curDienstgradMgr.SetUseGradID(0)
 
    return True
    
    
## Ê¹Óã¨Åå´÷£©³ÆºÅ£¬ÓÃÓÚ¼¤»îÊôÐÔ£¬ ²»ÏÔʾ³¡¾°ÖÐ
#  @param curPlayer
#  @param dienstgradID ³ÆºÅID
#  @return None   
def UseDienstgrad(curPlayer, dienstgradID):
 
    curDienstgradMgr = curPlayer.GetDienstgradManager()
    curDienstgrad = curDienstgradMgr.GetDienstgrad(dienstgradID)
    if curDienstgrad == None:
        #Íæ¼Ò³ÆºÅ²»´æÔÚ
        return False
    curOldGradID = curDienstgradMgr.GetUseGradID()
    if curOldGradID == dienstgradID:
        #ÒÑ×°±¸¸Ã³ÆºÅ
        return False
    curDienstgradMgr.SetUseGradID(dienstgradID)
 
    return True
    
#-------------------------------------------------------------
#####ͨ¹ýindexÍæ¼ÒË÷Òý½Ó¿Ú#####
 
## ²éÕÒÍæ¼ÒÖ¸¶¨³ÆºÅ
#  @param index Íæ¼ÒË÷Òý
#  @param dienstgradID ³ÆºÅID
#  @return ³ÆºÅʵÀý
def GetDienstgrad(index, dienstgradID):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    return PlayerGetDienstgrad(curPlayer, dienstgradID)
 
## Ìí¼ÓÍæ¼Ò³ÆºÅ
#  @param index Íæ¼ÒË÷Òý
#  @param dienstgradID ³ÆºÅID
#  @return ÊÇ·ñÌí¼Ó³É¹¦
def AddDienstgrad(index, dienstgradID):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    return PlayerAddDienstgrad(curPlayer, dienstgradID) 
 
## É¾³ýÍæ¼Ò³ÆºÅ
#  @param index Íæ¼ÒË÷Òý
#  @param dienstgradID ³ÆºÅID
#  @return None
def DelDienstgrad(index, dienstgradID):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    PlayerDelDienstgrad(curPlayer, dienstgradID)
    
    
## ´©×ÅÍæ¼Ò³ÆºÅ
#  @param index Íæ¼ÒË÷Òý
#  @param dienstgradID ³ÆºÅID
#  @return None   
def FitOnDienstgrad(index, dienstgradID):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    PlayerFitOnDienstgrad(curPlayer, dienstgradID)
 
## Ð¶ÏÂÍæ¼Ò³ÆºÅ
#  @param index Íæ¼ÒË÷Òý
#  @return None
def TakeOffDienstgrad(index):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    PlayerTakeOffDienstgrad(curPlayer)
    return
 
#-------------------------------------------------------------
#####·â°ü´¦Àí#####
 
##//03 35 Ö÷½ÇÍ·ÏÎË¢ÐÂ#tagCPlayerDienstgradRefresh
#  @param index Íæ¼ÒË÷Òý
#  @param tick
#  @return None      
def OnCPlayerDienstgradRefresh(index, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    if curPlayer == None:
        #Íæ¼Ò²»ÔÚÏß
        return
    Sync_AllDienstgradOnLogin(curPlayer)
    return
 
def Sync_AllDienstgradOnLogin(curPlayer):
    curDienstgradMgr = curPlayer.GetDienstgradManager()
    curDienstgradMgr.Sync_AllDienstgrad()
    curDienstgradMgr.Notify_PlayerChangeDienstgrad(curDienstgradMgr.GetCurGradID())
 
#===============================================================================
# //B2 01 Ê¹ÓóƺÅ(ÓÐÊôÐÔ²»ÏÔʾ³¡¾°ÖÐ) #tagPyCMUseDienstgrad
# struct    tagPyCMUseDienstgrad
# {
#    tagHead        Head;
#    DWORD        GradID;        //Í·ÏÎID
#    BYTE        State;        //ʹÓÃ״̬ 0È¡ÏûʹÓà1ʹÓàעÒâ0307°üΪ´©´÷³¡¾°ÖÐÏÔʾ
# };
#===============================================================================
def UseDienstgradPack(index, clientData, tick):
 
    #===========================================================================
    # curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    # curGradID = clientData.GradID
    # curGradState = clientData.State
    # 
    # result = False
    # if curGradID == 0:
    #    result = UnUseDienstgrad(curPlayer)
    # else:
    #    if curGradState:
    #        result = UseDienstgrad(curPlayer, curGradID)
    #    else:
    #        result = UnUseDienstgrad(curPlayer)
    #        
    # if result:
    #    CalcAllDienstgradAttr(curPlayer)
    #    playerControl = PlayerControl.PlayerControl(curPlayer)
    #    playerControl.RefreshPlayerAttrState()
    #===========================================================================
    return
 
 
##//03 37 Ö÷½ÇװжͷÏÎ#tagCPlayerChangeDienstgrad
#  @param index Íæ¼ÒË÷Òý
#  @param tick
#  @return None    
def OnCPlayerChangeDienstgrad(index, tick):   
    sendPack = IPY_GameWorld.IPY_CPlayerChangeDienstgrad()
    #//Í·ÏÎID
    curGradID = sendPack.GetGradID()
    #//×°±¸×´Ì¬ 0δװ±¸1ÒÑ×°±¸
    curGradState = sendPack.GetState()
    
    if curGradID == 0:
        TakeOffDienstgrad(index)
        return
    
    if curGradState:
        FitOnDienstgrad(index, curGradID)
    else:
        TakeOffDienstgrad(index)
 
#-------------------------------------------------------------
## »ñÈ¡ÒѼ¤»î³ÆºÅÁбí
#  @param curPlayer
#  @return ³ÆºÅÁбí
def GetDienstgradActiveInfo(curPlayer):
    titleActiveList = []
    gradCnt = curPlayer.GetDienstgradManager().GetCount()
    for i in xrange(gradCnt):
        curGradID = curPlayer.GetDienstgradManager().AtGradID(i)
        if curGradID == 0:
            continue
 
        titleActiveList.append(curGradID)
    return titleActiveList
 
def GetDienstgradActiveTypeCountInfo(curPlayer):
    activeTypeCountDict = {}
    dienstgradManager = curPlayer.GetDienstgradManager()
    gradCnt = dienstgradManager.GetCount()
    for i in xrange(gradCnt):
        curGradID = dienstgradManager.AtGradID(i)
        if curGradID == 0:
            continue
        curDienstgradData = GetDienstgradData(curGradID)
        if curDienstgradData == None:
            continue
        curType = curDienstgradData.GetType()
        activeTypeCountDict[curType] = activeTypeCountDict.get(curType, 0) + 1
    return activeTypeCountDict
 
def CalcAllDienstgradAttr(curPlayer):
    # ¼ÆËãÈ«²¿³ÆºÅÊôÐÔ
    allAttrList = [{} for i in range(4)]
    dienstgradManager = curPlayer.GetDienstgradManager()
    gradCnt = dienstgradManager.GetCount()
    for i in xrange(gradCnt):
        curGradID = dienstgradManager.AtGradID(i)
        if curGradID == 0:
            continue
        curDienstgradData = GetDienstgradData(curGradID)
        if curDienstgradData == None:
            continue
        
        attrTypeList = curDienstgradData.GetLightType()
        attrValueList = curDienstgradData.GetLightAttribute()
    
        for i, attrID in enumerate(attrTypeList):
            PlayerControl.CalcAttrDict_Type(attrID, attrValueList[i], allAttrList)
            
    # ±£´æ¼ÆËãÖµ
    PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_Dienstgrad, allAttrList)
    return
 
## ³ÆºÅÿÈÕ¸üд¦Àí
#  @param curPlayer
#  @return None
def OnDay(curPlayer):
    return
 
##¼ì²é³ÆºÅ³¬Ê±
#  @param curPlayer
#  @return None
def CheckDienstgradTimeout(curPlayer):
    tick = int(time.time())
    lastTick = curPlayer.GetTickByType(ChConfig.TYPE_Player_Tick_Dienstgrad)
    if tick - lastTick < (ChConfig.TYPE_Player_Tick_Time[ChConfig.TYPE_Player_Tick_Dienstgrad] / 1000):
        return
    curPlayer.SetTickByType(ChConfig.TYPE_Player_Tick_Dienstgrad, tick)
    
    gradCnt = curPlayer.GetDienstgradManager().GetCount()
    needClearList = []
 
    #±éÀúËùÓгƺţ¬¼ì²é³¬Ê±
    for i in xrange(gradCnt):
        curGrad = curPlayer.GetDienstgradManager().At(i)
        if not curGrad:
            continue
        curGradID = curGrad.GetGradID()
        if curGradID == 0:
            continue
        curDienstgradData = GetDienstgradData(curGradID)
        if curDienstgradData == None:
            continue
        
        curExpireTime = curGrad.GetExpireTime()     # ÌØÊâÖ¸¶¨ÓÐЧÆÚ
        if not curExpireTime:
            curExpireTime = curDienstgradData.GetExpireTime()
            # 0´ú±í²»ÏÞʱ
            if curExpireTime == 0:
                continue
        
        curCreateTime = curPlayer.GetDienstgradManager().AtCreateTime(i)
        pastSeconds = GameWorld.GetPastSeconds(curCreateTime)
        if pastSeconds < curExpireTime:
            continue
        needClearList.append(curGradID) #²»ÔÚ±éÀú¹ý³ÌÖÐɾ³ý£¬Ïȱ£´æÐèҪɾ³ýµÄ³ÆºÅ
    
    #ÒÀ´Îɾ³ý³ÆºÅ
    for curGradID in needClearList:
        PlayerDelDienstgrad(curPlayer, curGradID, notifyMail="TitleTimeout")
    return
 
#-------------------ÌØÊâ´¦Àí³ÆºÅÂß¼­-------------------
 
##Íæ¼ÒµÚÒ»´ÎµÇ½¸ø³ÆºÅ
#  @param curPlayer
#  @return None
def GiveFirstLoginDienstgrad(curPlayer):
    dienstgradIDDict = ReadChConfig.GetEvalChConfig('FirstLogin_GiveDienstgrad')
    platFormName = GameWorld.GetPlayerPlatform(curPlayer)
    dienstgradIDList = dienstgradIDDict.get(platFormName)
    if not dienstgradIDList: #δÅäÖÃµÄÆ½Ì¨Ä¬ÈÏÈ¡keyΪ0µÄÄÚÈÝ
        dienstgradIDList = dienstgradIDDict.get(0, [])
        
    for dienstgradID in dienstgradIDList:
        PlayerAddDienstgrad(curPlayer, dienstgradID)
        #PlayerFitOnDienstgrad(curPlayer, dienstgradID)
    return