#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#-------------------------------------------------------------------------------
|
#
|
##@package GM.Commands.MissionXML
|
#
|
# @todo:ÈÎÎñ½Ó¿Ú²âÊÔ
|
# @author hxp
|
# @date 2017-12-23
|
# @version 1.0
|
#
|
# ÏêϸÃèÊö: ÈÎÎñ½Ó¿Ú²âÊÔ, ²âÊÔXMLÎļþ·¾¶: ZoneServerGroup\map1_8G\MapServer\MapServerData\QUESTDATATest.xml
|
#
|
#-------------------------------------------------------------------------------
|
#"""Version = 2017-12-23 18:00"""
|
#-------------------------------------------------------------------------------
|
|
import QuestRunner
|
import IPY_GameWorld
|
import GameWorld
|
import ChConfig
|
|
import time
|
|
## GMÃüÁîÖ´ÐÐÈë¿Ú
|
# @param curPlayer µ±Ç°Íæ¼Ò
|
# @param playerList ²ÎÊýÁбí [ missionID]
|
# @return None
|
# @remarks º¯ÊýÏêϸ˵Ã÷.
|
def OnExec(curPlayer, playerList):
|
curMission = curPlayer.FindMission(1)
|
if curMission == None:
|
GameWorld.DebugAnswer(curPlayer, "ÈÎÎñ1²»´æÔÚ£¡ÎÞ·¨²âÊÔ£¡")
|
return
|
|
testXMLPath = ChConfig.GetAppPath() + "QUESTDATATest.xml"
|
testXML = open(testXMLPath, 'r')
|
testXMLContent = testXML.read()
|
testXML.close()
|
|
# ¼ÓÉÏʱ¼ä°æ±¾£¬È·±£Ã¿´ÎÔËÐÐÖØÐ¼ÓÔØ²âÊÔÎļþ
|
xmlLoader = IPY_GameWorld.IPY_XMLLoader()
|
isOK = xmlLoader.LoadFromXML("MissionXMLTest%d" % (int(time.time())), testXMLContent)
|
if not isOK:
|
GameWorld.DebugAnswer(curPlayer, "XMLÎļþ¸ñʽ´íÎó£¡%s" % (testXMLPath))
|
return
|
|
nodeList = xmlLoader.GetNodeList()
|
__DoAction(curPlayer, curMission, nodeList)
|
return
|
|
def __DoAction(curPlayer, curMission, nodeList):
|
for i in xrange(nodeList.GetCount()):
|
node = nodeList.Get(i)
|
childCount = node.GetChildCount()
|
if childCount:
|
__DoAction(curPlayer, curMission, node.ChildNodes())
|
continue
|
|
xmlMsg = node.GetXML()
|
if xmlMsg.startswith("<!--"):
|
continue
|
if not xmlMsg.startswith("<"):
|
continue
|
nodeName = node.GetNodeName().title()
|
if nodeName in ["Xml", "Actions", "Light", "Answer_Conditions", "Answer_Actions"]:
|
continue
|
#GameWorld.DebugLog("DoAction: %s" % node.GetXML())
|
QuestRunner.DoAction(curPlayer, curMission, node)
|
#QuestRunner.AnswerConditionJudge(curPlayer, curMission, node)
|
return
|
|
|
|