#!/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
|
|