xdh
2019-01-14 e7e1e93c2d2237f5fdcb94e4053e7c7584dbc7bf
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
#!/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 IPY_GameWorld
import PlayerControl
import GameWorld
import FBCommon
import ChConfig
#---------------------------------------------------------------------
#È«¾Ö±äÁ¿
#---------------------------------------------------------------------
(
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
    
    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))
        firstEmptyGameWorld = None
        sameLineGameWorldList = []
        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 and curPlayerCnt < maxPlayerCount:
                sameLineGameWorldList.append([gameWorld, curPlayerCnt])
        findGameWorld = None
        if sameLineGameWorldList:
            sameLineGameWorldList.sort(key=lambda asd:asd[1])
            findGameWorld = sameLineGameWorldList[0][0]
        elif firstEmptyGameWorld:
            findGameWorld = firstEmptyGameWorld
        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 == ChConfig.Def_FBMapID_SealDemon:
        tagMapPropertyID = tagMapLineID + 1 # ÒòΪPropertyIDĬÈÏÊÇ0£¬ËùÒÔʹÓÃʱ´Ó1¿ªÊ¼
        resultLineID = -1  # ½á¹ûlineID
        
        gameWorldManager = GameWorld.GetGameWorld()
        GameWorld.Log("    DoLogic()  tagMapID=%s,tagMapLineID=%s" % (tagMapID, tagMapLineID))
        findGameWord = 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 GameLogic_SealDemon.GetBossRemainHPPer(tagMapLineID, tick) < 15:
                    findGameWord = None
                    break
                findGameWord = gameWorld
                break
            if not findGameWord and propertyID == 0:
                findGameWord = gameWorld
        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]
#---------------------------------------------------------------------
 
 
#Ö´Ðнá¹û
## Ö´Ðнá¹û
#  @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) < 2:
        GameWorld.Log("GY_Query_EnterFB DoResult() return []")
        return
    
    tagMapInfo = eval(funResult[0])
    backFBID = int(funResult[1]) # ·µ»ØµÄÇÐͼÏß·id(0~N)
    
    mapID = tagMapInfo[0] # ÇëÇóµÄÇÐͼid
    funcLineID = tagMapInfo[1]   # ÇëÇóµÄ³¡´ÎÏß·id(0~6)
    GameWorld.Log("GY_Query_EnterFB DoResult() mapID=%s,funcLineID=%s,backFBID=%s" % (mapID, funcLineID, backFBID), curPlayer.GetPlayerID())
    
    if backFBID == -1: # Î´ÕÒµ½¿É½øÈëµÄ·ÖÏߣ¬Ôò·µ»Ø£¬ÌáʾÈËÊýÒÑÂú
        if mapID == ChConfig.Def_FBMapID_SealDemon:
            PlayerControl.NotifyCode(curPlayer, "DemonJar_Text4")
        else:
            PlayerControl.NotifyCode(curPlayer, "GeRen_chenxin_500807")
        return
    
    if curPlayer.GetMapID() == mapID:
        #ÒÑÔڸõØÍ¼¾Í²»ÈýøÁË
        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