hxp
2023-02-08 cb1d20b4aff8ca422a12a18f024a65b201687ec0
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
#!/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