hxp
2019-01-07 d8cf06e323dca770512529f741a667278c0c8786
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
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
#-------------------------------------------------------------------------------
#
##@package PlayerRecall
#
# @todo: ÕÙ»ØÍæ¼Ò
# @author Alee
# @date 2011-07-22 15:00
# @version 1.7
#
# ÏêϸÃèÊö:
# @change: "2011-07-22 17:00" Alee Ð޸ĻعéÍæ¼ÒÉÏÏß֪ͨ
# @change: "2011-07-25 19:00" Alee ÀëÏßÌìÊý֪ͨ´íÎó
# @change: "2011-07-26 11:00" Alee ÁìÈ¡ÎïÆ·ÏµÍ³ÌáʾºÍ±äÁ¿³õʼ»¯£¬Í¨ÖªÎÊÌâ
# @change: "2011-07-26 13:30" Alee  ·¢ËÍÑûÇëÂëµÈ¼¶ÏÞÖÆ
# @change: "2011-07-26 15:30" Alee ÐÞ¸´ÔÚMapServerºÍGameServer½»»¥ÆÚ¼ä»áÁìÈ¡¶à·ÝÀñÎï
# @change: "2012-05-16 15:00" jiang C++Ð޸ĽӿÚGameServer_QueryPlayerByIDºÍGameServer_QueryPlayerResult
# @change: "2012-07-30 16:30" wdb ²¹³äoss¼Ç¼
#------------------------------------------------------------------------------ 
"""Version = 2012-07-30 16:30"""
#------------------------------------------------------------------------------ 
 
import GameWorld
import ChConfig
import ReadChConfig
import ItemControler
import IPY_GameWorld
import ShareDefine
import PlayerControl
import DataRecordPack
 
 
#»Ø¹é½±ÀøµÄ×î¶Ìʱ¼ä
Def_Base_OffDay = 7
#»Ø¹é½±Àø×îµÍµÈ¼¶
Def_Base_LV = 30
 
 
##Íæ¼Ò»Ø¹é֪ͨ½±Àø
# @param curPlayer Íæ¼ÒʵÀý
# @return None
def PlayerBack(curPlayer):
    if ReadChConfig.GetEvalChConfig('PlayerRecall_Open') != ShareDefine.Def_Player_Recall_Open:
        return
    
    #µÈ¼¶ÏÞÖÆ
    if curPlayer.GetLV() < Def_Base_LV:
        return
    
    #µ±Ç°ÀëÏßʱ¼ä×Ö·û´«
    logoffTimeStr = curPlayer.GetLogoffTime()
 
    if logoffTimeStr == "" or logoffTimeStr == '0':
        return
 
    logoffTime = GameWorld.GetDateTimeByStr(logoffTimeStr)
    
    limitTime = GameWorld.GetDateTimeByStr(ReadChConfig.GetEvalChConfig('PlayerRecall_TimeLimit'))
    
    #¼Ç¼ÒÑÓÐÌìÊýºÍÐÂÌìÊý±äÁ¿
    newOffDays = offDays = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_OffDaysAward)
    
    #Åжϻʱ¼ä
    if logoffTime > limitTime:
        #֮ǰµÄÀëÏßδÁìÈ¡ÀñÎïµÄÅж¨
        if  offDays == 0:
            return
    
    else:
        loginTime = GameWorld.GetDateTimeByStr(GameWorld.GetCurrentDataTimeStr())
        diffTime = loginTime - logoffTime
        
        #¼Ç¼ÐÂʱ¼ä
        newOffDays = diffTime.days
        if newOffDays < Def_Base_OffDay: 
            if offDays == 0:
                #ʱ¼ä²»×ã
                return
            
            #»ñÈ¡Éϴν±Àø£¬¾ÉµÄ½±Àø²»¸üÐÂ×ֵ䣬ԭÑù֪ͨ
            newOffDays = offDays
        else:
            #³õʼ»¯Ò»´Î£¬±ÜÃ⿪¹ØÊ§°Ü
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_CheckInviteCode, 0)
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_OffDaysAward, newOffDays)
        
    #֪ͨÓÐÀñÎï¿ÉÁì
    curPlayer.Sync_PlayerBeRecalledInfo(newOffDays)
    
    #·Ç0±íʾÒÑ·¢ËÍ
    if curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_CheckInviteCode) != 0:
        #֪ͨ¿Í»§¶ËÒÑ·¢Ë͹ýÑûÇëÂë
        curPlayer.Sync_PlayerBeRecalledInfo(0)
    
    return
 
#===============================================================================
# //03 3D ÁìÈ¡±»Õٻؽ±Àø#tagCReceiveBeRecalledReward
# struct tagCReceiveBeRecalledReward
# {
#         tagHead Head;
# };
#===============================================================================
##Íæ¼Ò»Ø¹é½±Àø
#@param index Íæ¼ÒË÷Òý
#@param tick Ê±¼ä´Á
#@return ·µ»ØÖµÎÞÒâÒå
def PlayerBackAward(index, tick):
    if ReadChConfig.GetEvalChConfig('PlayerRecall_Open') != ShareDefine.Def_Player_Recall_Open:
        return
    
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    
    playerLV = curPlayer.GetLV()
    if playerLV < Def_Base_LV:
        return
    
    offDays = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_OffDaysAward)
    if offDays == 0:
        return
    
    lvList = ReadChConfig.GetEvalChConfig('PlayerRecall_OffDays')
    
    #µÈ¼¶
    offDaysList = GameWorld.GetResultByRiseList(lvList, playerLV)
    if offDaysList == None:
        GameWorld.ErrLog("PlayerBackAward, LVErr LV=%s, award=%s"%(playerLV, lvList))
        return
    
    #ÀëÏßÌìÊý
    itemList = GameWorld.GetResultByRiseList(offDaysList, offDays)
    if itemList == None:
        GameWorld.ErrLog("PlayerBackAward, offDaysErr LV=%s, offDays=%s, award=%s"%(playerLV, offDays, lvList))
        return
    
    itemID, count = itemList
    
    #°ÑµØÍ¼ÎïÆ··Åµ½±³°üÖÐ
    dataDict = {'PlayerLV':playerLV, 'OffDays':offDays}
    if not ItemControler.GivePlayerItem(curPlayer, itemID, count, True, [IPY_GameWorld.rptItem], True,
                                        showSysInfo=True, event=["PlayerBackAward", True, dataDict]):
        return
    
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_OffDaysAward, 0)
    return
 
#===============================================================================
# //03 3E ±»ÕÙ»ØÍæ¼Ò·¢ËÍÑûÇëÂë#tagCBeRecalledInviteCode
# struct tagCBeRecalledInviteCode
# {
#         tagHead Head;
#         DWORD InviteCode; // ÑûÇëÂë
# };
#===============================================================================
##Íæ¼Ò»Ø¹é½±Àø
#@param index Íæ¼ÒË÷Òý
#@param tick Ê±¼ä´Á
#@return ·µ»ØÖµÎÞÒâÒå
def RecallInviteCode(index, tick):
    if ReadChConfig.GetEvalChConfig('PlayerRecall_Open') != ShareDefine.Def_Player_Recall_Open:
        return
        
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    
    #ÑûÇëÂëµÈ¼¶ÏÞÖÆ
    if curPlayer.GetLV() < Def_Base_LV:
        return
    
    #Ìí¼Ó×ÖµäÓÃÓÚÔÚGameServer »Ø¸´ÏûϢǰ£¬ÏÞÖÆ·¢°ü£¬Î´È·ÈϽá¹û
    if curPlayer.GetDictByKey(ChConfig.Def_Player_NoSave_Dict_SendInviteCode) == 1:
        return
    
    curPlayer.SetDict(ChConfig.Def_Player_NoSave_Dict_SendInviteCode, 1)
    
    if curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_CheckInviteCode) == 1:
        #´æÓÚÊý¾Ý¿âÖУ¬¼Ç¼ÄãÕæµÄÌá½»¹ýÑûÇëÂë²¢³É¹¦
        return
       
    pack = IPY_GameWorld.IPY_CBeRecalledInviteCode()
    inviteCode = pack.GetInviteCode()
 
    GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(curPlayer.GetPlayerID(), 0, 
                                                              int(inviteCode), 'SendInviteCode', '', 0)
    
    return