hxp
2024-10-29 328648da94a07437fc46024f3e9b7e48c2e2ae38
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
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
#-------------------------------------------------------------------------------
#
##@package Player.RemoteQuery.GY_Query_EnterFB
#
# @todo:½øÈ븱±¾
# @author hxp
# @date 2014-04-16
# @version 1.4
#
# ÏêϸÃèÊö: ½øÈ븱±¾
# @change: "2014-04-16 18:00" hxp ½øÈ븱±¾ÐÞ¸Ä
# @change: "2015-03-21 16:00" hxp ½øÈëÕ½Ã˼ÒÔ°
# @change: "2015-03-25 21:30" hxp ½øÈëÕ½Ã˼ÒÔ°Ôö¼ÓÑӳٹرմ¦Àí
# @change: "2015-06-29 17:20" ljd ¾­µäÕ½ÒÛ
#
#---------------------------------------------------------------------
#"""Version = 2015-06-29 17:20"""
#---------------------------------------------------------------------
 
#µ¼Èë
import FBLogic
import GameLogic_SealDemon
import GameLogic_ZhuXianBoss
import IPY_GameWorld
import PlayerControl
import GameWorld
import FBCommon
import ChConfig
import IpyGameDataPY
import random
#---------------------------------------------------------------------
#È«¾Ö±äÁ¿
#---------------------------------------------------------------------
(
MapInfo_MapID, # Ä¿±êµØÍ¼ÐÅÏ¢ - µØÍ¼id
MapInfo_LineID, # Ä¿±êµØÍ¼ÐÅÏ¢ - ³¡´Î·ÖÏßid
) = range(2)
#---------------------------------------------------------------------
#Âß¼­ÊµÏÖ
## ÇëÇóÂß¼­
#  @param query_Type ÇëÇóÀàÐÍ
#  @param query_ID ÇëÇóµÄÍæ¼ÒID
#  @param packCMDList ·¢°üÃüÁî [ ]
#  @param tick µ±Ç°Ê±¼ä
#  @return "True" or "False" or ""
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def DoLogic(query_Type, query_ID, packCMDList, tick):
    GameWorld.Log("GY_Query_EnterFB DoLogic() query_Type=%s,query_ID=%s,packCMDList=%s,tick=%s" % \
                  (query_Type, query_ID, packCMDList, tick))
    
 
    if not packCMDList or len(packCMDList) < 2:
        GameWorld.Log("    DoLogic() return []")
        return []
    
    tagMapID = packCMDList[0]  # Ä¿±êµØÍ¼id
    tagMapLineID = packCMDList[1]  # Ä¿±êµØÍ¼Ïß·ÊôÐÔ,´Ó0¿ªÊ¼
    resultLineID = -1  # ½á¹ûlineID
    hpPer = -1
    notifyMark = 'GeRen_chenxin_500807' #²»ÄܽøµÄÌáʾ
    if tagMapID in ChConfig.Def_MapID_LineIDToPropertyID:        
        GameWorld.Log("    DoLogic() tagMapID in ChConfig.Def_MapID_LineIDToPropertyID")
        tagMapPropertyID = tagMapLineID + 1 # ÒòΪPropertyIDĬÈÏÊÇ0£¬ËùÒÔʹÓÃʱ´Ó1¿ªÊ¼
        
        resultLineID = -1  # ½á¹ûlineID
        
        gameWorldManager = GameWorld.GetGameWorld()
        maxPlayerCount = FBLogic.GetFBLineMaxPlayerCount(tagMapID, tagMapLineID)
        
        GameWorld.Log("    DoLogic()  tagMapID=%s,tagMapLineID=%s,maxPlayerCount=%s" % (tagMapID, tagMapLineID,maxPlayerCount))
        if not maxPlayerCount:
            pass
        firstEmptyGameWorld = None
        sameLineGameWorldList = [] #ÈËÊýδÂúµÄÏß·Áбí
        fullLineGameWorldList = [] #ÈËÊýÒÑÂúµÄÏß·Áбí
        for index in xrange(gameWorldManager.GetGameWorldCount()):
            gameWorld = IPY_GameWorld.IPY_GameWorld(index)
            playerManager = gameWorld.GetMapCopyPlayerManagerByFbIndex(index)
            propertyID = gameWorld.GetPropertyID()
            curPlayerCnt = playerManager.GetPlayerCount()
#            GameWorld.Log("    DoLogic()  check gameworld index=%s,propertyID=%s,playerCount=%s" \
#                          % (index, propertyID, curPlayerCnt))
            if propertyID == 0 and not firstEmptyGameWorld:
                firstEmptyGameWorld = gameWorld
            # Èç¹û²»ÊÇͬһÏß·ÊôÐԵģ¬ÔòÌø¹ý
            # Èç¹ûµ±Ç°ÈËÊý³¬¹ý¶î¶¨ÈËÊý£¬ÔòÌø¹ý
            if propertyID == tagMapPropertyID:
                if curPlayerCnt < maxPlayerCount:
                    sameLineGameWorldList.append([gameWorld, curPlayerCnt])
                else:
                    fullLineGameWorldList.append([gameWorld, curPlayerCnt])
        findGameWorld = None
        if sameLineGameWorldList:
            #ÈôÊǽøÈë¹ý¸±±¾ÔòËæ»úÒ»¸ö£¬·ñÔòÑ¡ÈËÊý×îÉÙµÄÒ»¸ö
            enterCnt = packCMDList[2]
            if enterCnt:
                #GameWorld.DebugLog('DoLogic() sameLineGameWorldList=%s'%len(sameLineGameWorldList))
                findGameWorld = random.choice(sameLineGameWorldList)[0]
            else:
                sameLineGameWorldList.sort(key=lambda asd:asd[1])
                findGameWorld = sameLineGameWorldList[0][0]
                
        elif firstEmptyGameWorld:
            findGameWorld = firstEmptyGameWorld
        elif fullLineGameWorldList:
            #Ïß·¶¼ÂúÈËÁËÔòÈ¡¸öÈËÊýÏà¶Ô½ÏÉÙµÄ
            fullLineGameWorldList.sort(key=lambda asd:asd[1])
            findGameWorld = fullLineGameWorldList[0][0]
            
        if findGameWorld:
            if findGameWorld.GetPropertyID() == 0:
                findGameWorld.SetFBFirstOpen(1) # ¿ªÆô¸±±¾
            findGameWorld.SetPropertyID(tagMapPropertyID)
            resultLineID = findGameWorld.GetLineID()
            GameWorld.Log("    DoLogic()  check ok!resultLineID=%s" % (resultLineID))
            
            
#===================================================================================================
#    # Õ½Ã˼ÒÔ°
#    elif tagMapID == ChConfig.Def_MapID_FamilyHome:
#        
#        if len(packCMDList) < 4:
#            GameWorld.DebugLog("    ÇëÇó½øÈëÕ½Ã˼ÒÔ°£ºÎÞÄ¿±êÕ½ÃËID£¡")
#            return
#        
#        tagFamilyID = packCMDList[2]
#        tagFamilyHomeLV = packCMDList[3]
#        if tagFamilyID <= 0:
#            GameWorld.DebugLog("    ÇëÇó½øÈëÕ½Ã˼ÒÔ°£ºÄ¿±êÕ½ÃËID´íÎó=%s£¡" % tagFamilyID)
#            return
#        
#        resultLineID = -1  # ½á¹ûlineID
#        
#        gameWorldManager = GameWorld.GetGameWorld()
#        firstNotPropertyGameWorld = None
#        
#        for index in range(gameWorldManager.GetGameWorldCount()):
#            gameWorld = IPY_GameWorld.IPY_GameWorld(index)
#            playerManager = gameWorld.GetMapCopyPlayerManagerByFbIndex(index)
#            propertyID = gameWorld.GetPropertyID()
#            
#            # ²»¿É½øÈë
#            if gameWorld.GetCloseFBTick() > 0:
#                continue
#            if gameWorld.GetOpenState() == IPY_GameWorld.fbosWaitForClose:
#                continue
#            
#            if propertyID <= 0 and firstNotPropertyGameWorld == None:
#                firstNotPropertyGameWorld = gameWorld
#            
#            if propertyID == tagFamilyID:
#                resultLineID = gameWorld.GetLineID()
#                GameWorld.DebugLog("    ÕÒµ½ÒѾ­´æÔÚµÄÕ½Ã˼ÒÔ°: tagFamilyID=%s,resultLineID=%s" % (tagFamilyID, resultLineID))
#                break
#            
#        if resultLineID < 0 and firstNotPropertyGameWorld != None and firstNotPropertyGameWorld.GetPropertyID() <= 0:
#            firstNotPropertyGameWorld.SetPropertyID(tagFamilyID)
#            firstNotPropertyGameWorld.SetFBFirstOpen(1) # ¿ªÆô¸±±¾
#            resultLineID = firstNotPropertyGameWorld.GetLineID()
#            GameWorld.GetGameWorld().SetGameWorldDict("FamilyHomeLV_%s" % tagFamilyID, tagFamilyHomeLV)
#            GameWorld.DebugLog("    ´´½¨ÐÂÕ½Ã˼ÒÔ°: tagFamilyID=%s,tagFamilyHomeLV=%s,resultLineID=%s" 
#                               % (tagFamilyID, tagFamilyHomeLV, resultLineID))
#===================================================================================================
    elif tagMapID in [ChConfig.Def_FBMapID_HorsePetBoss, ChConfig.Def_FBMapID_SealDemon, ChConfig.Def_FBMapID_ZhuXianBoss, ChConfig.Def_FBMapID_AllFamilyBoss, ChConfig.Def_FBMapID_DemonKing]:
        tagMapPropertyID = tagMapLineID + 1 # ÒòΪPropertyIDĬÈÏÊÇ0£¬ËùÒÔʹÓÃʱ´Ó1¿ªÊ¼
        resultLineID = -1  # ½á¹ûlineID
        
        gameWorldManager = GameWorld.GetGameWorld()
        GameWorld.Log("    DoLogic()  tagMapID=%s,tagMapLineID=%s" % (tagMapID, tagMapLineID))
        findGameWord = None
        findPlayerManager = None
        for index in range(gameWorldManager.GetGameWorldCount()):
            gameWorld = IPY_GameWorld.IPY_GameWorld(index)
            playerManager = gameWorld.GetMapCopyPlayerManagerByFbIndex(index)
            propertyID = gameWorld.GetPropertyID()
            if gameWorld.GetCloseFBTick() > 0:
                #ÕýÔڹرՠ²»¿É½ø
                continue
            
#            GameWorld.Log("    DoLogic()  check gameworld index=%s,propertyID=%s,playerCount=%s" \
#                          % (index, propertyID, playerManager.GetPlayerCount()))
            # Èç¹û²»ÊÇͬһÏß·ÊôÐԵģ¬ÔòÌø¹ý
            if propertyID == tagMapPropertyID:
                if tagMapID == ChConfig.Def_FBMapID_SealDemon:
                    hpPer = GameLogic_SealDemon.GetBossRemainHPPer(index, tagMapLineID, tick)
                    
                elif tagMapID == ChConfig.Def_FBMapID_ZhuXianBoss:
                    hpPer = GameLogic_ZhuXianBoss.GetBossRemainHPPer(index, tagMapLineID, tick)
                    
                findGameWord = gameWorld
                findPlayerManager = playerManager
                break
            if not findGameWord and propertyID == 0:
                findGameWord = gameWorld
                findPlayerManager = playerManager
        
        if findPlayerManager and tagMapID == ChConfig.Def_FBMapID_ZhuXianBoss:
            if packCMDList[3] !=-1 and not GameLogic_ZhuXianBoss.GetHasSameFamilyMerber(packCMDList[3], findPlayerManager):
                notifyMark = "TryEnterJadeDynastyBossError_6"
                findGameWord = None
                GameWorld.DebugLog("    ¹éÊô´ÎÊýΪ0ÇÒûÓÐͬÃËÍæ¼ÒÔÚ¸±±¾Àï!")
                
        if findGameWord:
            if findGameWord.GetPropertyID() == 0:
                findGameWord.SetFBFirstOpen(1) # ¿ªÆô¸±±¾
            findGameWord.SetPropertyID(tagMapPropertyID)
            resultLineID = findGameWord.GetLineID()
 
    else:
        #resultLineID = tagMapLineID
        resultLineID = 0
        
    return ['%s' % packCMDList, '%d' % resultLineID, notifyMark, hpPer]
#---------------------------------------------------------------------
 
 
#Ö´Ðнá¹û
## Ö´Ðнá¹û
#  @param curPlayer ·¢³öÇëÇóµÄÍæ¼Ò
#  @param callFunName ¹¦ÄÜÃû³Æ
#  @param funResult ²éѯµÄ½á¹û
#  @param tick µ±Ç°Ê±¼ä
#  @return None
#  @remarks º¯ÊýÏêϸ˵Ã÷.
def DoResult(curPlayer, callFunName, funResult, tick):
    
    #»¹Ô­¸ñʽ '[]' -> []
    funResult = eval(funResult)
    if not funResult or len(funResult) < 3:
        GameWorld.Log("GY_Query_EnterFB DoResult() return []")
        return
    
    tagMapInfo = eval(funResult[0])
    backFBID = int(funResult[1]) # ·µ»ØµÄÇÐͼÏß·id(0~N)
    notifyMark = funResult[2]
    hpPer = funResult[3]
    mapID = tagMapInfo[0] # ÇëÇóµÄÇÐͼid
    funcLineID = tagMapInfo[1]   # ÇëÇóµÄ³¡´ÎÏß·id(0~6)
    GameWorld.Log("GY_Query_EnterFB DoResult() mapID=%s,funcLineID=%s,backFBID=%s,hpPer=%s" % (mapID, funcLineID, backFBID, hpPer), curPlayer.GetPlayerID())
    
    if backFBID == -1: # Î´ÕÒµ½¿É½øÈëµÄ·ÖÏߣ¬Ôò·µ»Ø£¬ÌáʾÈËÊýÒÑÂú
        PlayerControl.NotifyCode(curPlayer, notifyMark)
        return
    
    if curPlayer.GetMapID() == mapID:
        #ÒÑÔڸõØÍ¼¾Í²»ÈýøÁË
        return
    
    # ·ÇЭÖúÍæ¼Ò½øÈëÐèÒªÅжÏbossÊ£ÓàѪÁ¿ÊÇ·ñÔÊÐí½øÈë
    if hpPer >= 0 and not PlayerControl.GetAssistTagPlayerID(curPlayer):
        minHPPer = 15
        if mapID == ChConfig.Def_FBMapID_SealDemon:
            minHPPer = IpyGameDataPY.GetFuncCfg('SealDemonFirstPos', 2)
        elif mapID == ChConfig.Def_FBMapID_ZhuXianBoss:
            minHPPer = IpyGameDataPY.GetFuncCfg('ZhuXianBossCntCfg', 4)
        if hpPer < minHPPer:
            GameWorld.DebugLog("bossѪÁ¿ÉÙÓڿɽøÈëµÄ×îµÍѪÁ¿°Ù·Ö±È£¬ÎÞ·¨½øÈë!hpPer=%s,minHPPer=%s" % (hpPer, minHPPer))
            PlayerControl.NotifyCode(curPlayer, "DemonJar_Text4")
            return
        
    # ÇëÇó½øÈëFBµã
    ipyEnterPosInfo = FBCommon.GetFBLineEnterPosInfo(mapID, funcLineID)
    retPos = FBLogic.OnGetFBEnterPos(curPlayer, mapID, funcLineID, ipyEnterPosInfo, tick)
    
    if not retPos:
        return
    
    # ´«ËÍÂß¼­
    PlayerControl.PlayerResetWorldPosFB(curPlayer, mapID, retPos[0], retPos[1], False, backFBID, funcLineID=funcLineID)
    return