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
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package GameWorldLogic.FBProcess.GameLogic_GodArea
#
# @todo:¹ÅÉñ½ûµØ
# @author xdh
# @date 2017-11-09
# @version 1.0
#
# ÏêϸÃèÊö: ¹ÅÉñ½ûµØ
#
#-------------------------------------------------------------------------------
#"""Version = 2017-11-09 14:30"""
#-------------------------------------------------------------------------------
 
import FBCommon
import GameWorld
import IpyGameDataPY
import IPY_GameWorld
import ChConfig
import PlayerControl
import PlayerBossReborn
import PlayerFairyCeremony
import PlayerNewFairyCeremony
import PlayerWeekParty
import PlayerActLogin
import EventReport
import time
import EventShell
 
Map_FBDict_LastGodAreaCheckTick = 'LastGodAreaCheckTick'
FBPlayerDict_LeaveTick = 'FBPlayerDict_LeaveTick'
FBPlayerDict_FullTick = 'FBPlayerDict_FullTick'
def __AddGodAreaAnger(curPlayer, addCnt):
    ## Ôö¼ÓÅ­ÆøÖµ
    anger = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_GodArea_Anger)
    maxAnger = IpyGameDataPY.GetFuncCfg('AngryAdd', 4)
    if anger >= maxAnger:
        return True
    updAnger = min(maxAnger, addCnt + anger)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_GodArea_Anger, updAnger)
    DoFBHelp(curPlayer, 0)
    if updAnger >= maxAnger:
        deadTime = FBCommon.GetFBLineStepTime(ChConfig.Def_FBMapID_GodArea)[0]
        curPlayer.Sync_TimeTick(ChConfig.tttDeadTime , 0, deadTime * 1000, True)
        tick = GameWorld.GetGameWorld().GetTick()
        GameWorld.GetGameFB().SetPlayerGameFBDict(curPlayer.GetID(), FBPlayerDict_FullTick, tick)
 
        #FBCommon.SetHadDelTicket(curPlayer, 0)
    return updAnger >= maxAnger
 
 
 
def GodAreaOnLogin(curPlayer):
    ## Íæ¼ÒÔÚ¸±±¾µÇ¼Ðè¼ÆËãÀëÏßʱ¼äÔö¼ÓµÄÅ­ÆøÖµ
    mapID = GameWorld.GetGameWorld().GetMapID()
    if mapID != ChConfig.Def_FBMapID_GodArea:
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_GodArea_Anger, 0)
        return
    leaveServerSecond = PlayerControl.GetPlayerLeaveServerSecond(curPlayer) #ÀëÏßʱ¼äÃë
    addPoint = TimeAddGodAreaAnger(curPlayer, leaveServerSecond)[0]
    GameWorld.DebugLog("    ¸±±¾ÀïOnLogin, leaveServerSecond=%s, addPoint=%s"%(leaveServerSecond, addPoint))
    return
 
def TimeAddGodAreaAnger(curPlayer, second):
    ## Ê±¼äÔö¼ÓÅ­ÆøÖµ
    
    perAngerNeedSecond = IpyGameDataPY.GetFuncCfg('AngryAdd')
    addPoint = second / perAngerNeedSecond
    isFull = False
    if addPoint:
        isFull = __AddGodAreaAnger(curPlayer, addPoint)
    return addPoint, isFull
 
def __IsAngerFull(curPlayer):
    # Å­ÆøÖµÊÇ·ñÒÑÂú
    anger = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_GodArea_Anger)
    maxAnger = IpyGameDataPY.GetFuncCfg('AngryAdd', 4)
    return anger >= maxAnger
 
## ÊÇ·ñÄܹ»Í¨¹ý»î¶¯²éѯ½øÈë
#  @param curPlayer Íæ¼ÒʵÀý
#  @param mapID µØÍ¼ID
#  @param lineID Ïß·id
#  @param tick Ê±¼ä´Á
#  @return ²¼¶ûÖµ
def OnEnterFBEvent(curPlayer, mapID, lineID, tick):
    return True
 
 
##¸±±¾Íæ¼Ò½øÈëµã
# @param curPlayer Íæ¼ÒʵÀý
# @param mapID µØÍ¼ID
# @param lineId ·ÖÏßID
# @param ipyEnterPosInfo ¹¦ÄÜÏß·IPYÅäÖÃ×ø±êÐÅÏ¢
# @param tick Ê±¼ä´Á
# @return posX, posY, Ëæ»ú°ë¾¶(¿ÉÑ¡)
def OnGetFBEnterPos(curPlayer, mapID, lineId, ipyEnterPosInfo, tick):
    return ipyEnterPosInfo
 
## ÖØÖø±±¾¸´»îÍæ¼Ò×ø±êµã
# @param None
# @return ÎÞÒâÒå
def OnResetFBRebornPlacePos(curPlayer, rebornPlace, tick):
    ipyEnterPosInfo = FBCommon.GetFBLineEnterPosInfo(ChConfig.Def_FBMapID_GodArea, 0)
    posX, posY = ipyEnterPosInfo[:2]
    curPlayer.ResetPos(posX, posY)
    return
 
## ²éѯµØÍ¼ÊÇ·ñ¿ªÆô
#  @param tick Ê±¼ä´Á
#  @return ²¼¶ûÖµ
def OnCanOpen(tick):
    return True
 
##²éѯÊÇ·ñ¿ÉÒÔ½øÈëµØÍ¼
# @param ask:ÇëÇó½á¹¹Ìå(IPY_BMChangeMapAsk)
# @param tick:ʱ¼ä´Á
# @return IPY_GameWorld.cme Ã¶¾Ù
def OnChangeMapAsk(ask, tick):
    return IPY_GameWorld.cmeAccept
 
 
## ½ø¸±±¾
#  @param curPlayer
#  @param tick
#  @return None
def DoEnterFB(curPlayer, tick):
    hadDelTicket = FBCommon.GetHadDelTicket(curPlayer)
    GameWorld.DebugLog("    ½ø¸±±¾DoEnterFB hadDelTicket=%s"%hadDelTicket)
    if not hadDelTicket:
        mapID = GameWorld.GetGameWorld().GetMapID()
        delResult = FBCommon.DelFBEnterTicket(curPlayer, mapID)
        isOK = delResult[0]
        #hasBind = delResult[1]
        if not isOK:
            PlayerControl.PlayerLeaveFB(curPlayer)
            return
        FBCommon.ClearAreaRewardRecord(curPlayer.GetID())
        FBCommon.SetHadDelTicket(curPlayer)
        FBCommon.AddEnterFBCount(curPlayer, mapID)
        EventShell.EventRespons_FBEvent(curPlayer, 'godarea')
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_GodArea_Anger, 0)
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_GodArea_LastAddAngerTime, 0)
        PlayerControl.FBNotify('ElderGod_SomeIn', [curPlayer.GetName()])
        EventReport.WriteEvent_FB(curPlayer, ChConfig.Def_FBMapID_GodArea, 0, ChConfig.CME_Log_Start)
        PlayerBossReborn.AddBossRebornActionCnt(curPlayer, ChConfig.Def_BRAct_GodArea, 1)
        PlayerFairyCeremony.AddFCPartyActionCnt(curPlayer, ChConfig.Def_PPAct_GodArea, 1)
        PlayerNewFairyCeremony.AddFCPartyActionCnt(curPlayer, ChConfig.Def_PPAct_GodArea, 1)
        PlayerWeekParty.AddWeekPartyActionCnt(curPlayer, ChConfig.Def_WPAct_GodArea, 1)
        PlayerActLogin.AddLoginAwardActionCnt(curPlayer, ChConfig.Def_LoginAct_GodArea, 1)
    elif __IsAngerFull(curPlayer):
        #Å­ÆøÒÑÂú£¬Í˳ö¸±±¾
        GameWorld.DebugLog("    ¸±±¾ÀïµôÏßÖØÉÏ Å­ÆøÒÑÂú£¬Í˳ö¸±±¾")
        PlayerControl.PlayerLeaveFB(curPlayer)
    DoFBHelp(curPlayer, tick)
    return
 
##Íæ¼ÒÍ˳ö¸±±¾
# @param curPlayer Íæ¼ÒʵÀý
# @param tick Ê±¼ä´Á
# @return ÎÞÒâÒå
def DoExitFB(curPlayer, tick):
    
    return
 
##Íæ¼ÒÖ÷¶¯À뿪¸±±¾.
# @param curPlayer Íæ¼ÒʵÀý
# @param tick Ê±¼ä´Á
# @return ·µ»ØÖµÎÞÒâÒå
def DoPlayerLeaveFB(curPlayer, tick):
    return
 
##Íæ¼ÒÇл»µØÍ¼
def DoPlayerChangeMapLogic(curPlayer):
    FBCommon.SetHadDelTicket(curPlayer, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_GodArea_Anger, 0)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_GodArea_LastAddAngerTime, 0)
    GameWorld.GetGameFB().SetPlayerGameFBDict(curPlayer.GetID(), FBPlayerDict_LeaveTick, 0)
    GameWorld.GetGameFB().SetPlayerGameFBDict(curPlayer.GetID(), FBPlayerDict_FullTick, 0)
    
    return
 
## ÊÇ·ñ¸±±¾¸´»î
#  @param None
#  @return ÊÇ·ñ¸±±¾¸´»î
def OnPlayerReborn():
    return True
 
##Íæ¼ÒËÀÍö.
# @param curPlayer:ËÀÍöµÄÍæ¼Ò 
# @param tick Ê±¼ä´Á
# @return ·µ»ØÖµÎÞÒâÒå
# @remarks Íæ¼ÒÖ÷¶¯À뿪¸±±¾.
def DoPlayerDead(curPlayer):
    if __IsAngerFull(curPlayer):
        leaveTime = FBCommon.GetFBLineStepTime(ChConfig.Def_FBMapID_GodArea)[1]
        curPlayer.Sync_TimeTick(IPY_GameWorld.tttLeaveMap , 0, leaveTime * 1000, True)
    return
 
 
## Íæ¼Ò¸´»îºó´¦Àí
def OnPlayerRebornOver(curPlayer, playerRebornType):
    #¼ÓÅ­Æø
    addPoint = IpyGameDataPY.GetFuncCfg('AngryAdd', 3)
    __AddGodAreaAnger(curPlayer, addPoint)
    return
 
## »÷ɱnpcµôÂä¹éÊô
#  @param curPlayer µ±Ç°Íæ¼Ò
#  @param curNPC ±»É±µÄNPC
#  @param tick µ±Ç°Ê±¼ä
#  @return None
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def DoFB_DropOwner(curPlayer , curNPC):
    npcID = curNPC.GetNPCID()
    ipyData = IpyGameDataPY.GetIpyGameDataNotLog('ElderGodArea', npcID)
    if not ipyData:
        return
    addPoint = ipyData.GetMonsterAnger()
    #¼ÓÅ­Æø
    __AddGodAreaAnger(curPlayer, addPoint)
    if ChConfig.IsGameBoss(curNPC):
        DoFBHelp(curPlayer, 0, {"KillBOSS":npcID})
    return
 
## »ñµÃ¸±±¾°ïÖúÐÅÏ¢
#  @param curPlayer µ±Ç°Íæ¼Ò£¨±»Í¨Öª¶ÔÏó£©
#  @param tick µ±Ç°Ê±¼ä
#  @return None
def DoFBHelp(curPlayer, tick, helpDict = {}):
    #¸±±¾°ïÖú
    helpDict[FBCommon.Help_score] = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_GodArea_Anger)
    GameWorld.DebugLog("helpDict=%s" % helpDict, curPlayer.GetID())
    FBCommon.Notify_FBHelp(curPlayer, helpDict)
    return
 
 
##---¸±±¾×ÜÂß¼­¼ÆÊ±Æ÷---
# @param tick:ʱ¼ä´Á
# @return ÎÞÒâÒå
# @remarks ¸±±¾×ÜÂß¼­¼ÆÊ±Æ÷
def OnProcess(tick):
    __DoLogic_CheckAnger(tick)
    
    FBCommon.DoLogicAreaReward("GodAreaExpAward", tick, True)
    return
 
def __DoLogic_CheckAnger(tick):
    gameFB = GameWorld.GetGameFB()
    lastAwardTick = gameFB.GetGameFBDictByKey(Map_FBDict_LastGodAreaCheckTick)
    checkInterval = IpyGameDataPY.GetFuncCfg('AngryAdd', 2)
    if tick - lastAwardTick < checkInterval * 1000:
        return
    gameFB.SetGameFBDict(Map_FBDict_LastGodAreaCheckTick, tick)
    
    stepTimeList = FBCommon.GetFBLineStepTime(ChConfig.Def_FBMapID_GodArea)
    deadTime, leaveTime = stepTimeList
 
    playerManager = GameWorld.GetMapCopyPlayerManager()
    curTime = int(time.time())
    for index in range(0, playerManager.GetPlayerCount()):
        curPlayer = playerManager.GetPlayerByIndex(index)
        playerID = curPlayer.GetPlayerID()
        if not playerID:
            continue
        
        if __IsAngerFull(curPlayer):
            fullTick = gameFB.GetPlayerGameFBDictByKey(playerID, FBPlayerDict_FullTick)
            if fullTick and tick - fullTick > deadTime*1000:
                gameFB.SetPlayerGameFBDict(playerID, FBPlayerDict_FullTick, 0)
                gameFB.SetPlayerGameFBDict(playerID, FBPlayerDict_LeaveTick, tick)
                playerControl = PlayerControl.PlayerControl(curPlayer)
                playerControl.SetDead()
                
                GameWorld.DebugLog('    Ê±¼äµ½ ÉèÖÃËÀÍö ', playerID)
                
            leaveTick = gameFB.GetPlayerGameFBDictByKey(playerID, FBPlayerDict_LeaveTick)
            if leaveTick and tick - leaveTick > leaveTime*1000:
                PlayerControl.PlayerLeaveFB(curPlayer)
                gameFB.SetPlayerGameFBDict(playerID, FBPlayerDict_LeaveTick, 0)
                GameWorld.DebugLog('    Ê±¼äµ½ TÈË ', playerID)
            continue
        isFull = False
        lastAddAngerTime = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_GodArea_LastAddAngerTime)
        if lastAddAngerTime:
            passSecond = curTime - lastAddAngerTime
            isOK, isFull = TimeAddGodAreaAnger(curPlayer, passSecond)
            if isOK:
                PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_GodArea_LastAddAngerTime, curTime)
        else:
            PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_GodArea_LastAddAngerTime, curTime)
        
    return