コード例 #1
0
ファイル: __init__.py プロジェクト: jamesxia4/wot_client
def parseAction(xmlCtx, section, flags):
    name = section.name
    if name not in ACTION_TAGS:
        LOG_ERROR('Action is not supported: ', name)
        return
    targetID = parseID(xmlCtx, section, 'Specify a target ID')
    action = chapter.Action(ACTION_TAGS[name], targetID)
    if 'effects' in section.keys():
        for _, effectSec in _xml.getChildren(xmlCtx, section, 'effects'):
            effect = _parseEffect(xmlCtx, effectSec, flags)
            if effect is not None:
                action.addEffect(effect)

    return action
コード例 #2
0
def _readAction(xmlCtx, section, eventType, flags):
    actionID = parseID(xmlCtx, section, 'Specify a action ID')
    itemID = None
    if 'item-id' in section.keys():
        itemID = parseID(xmlCtx, section['item-id'], 'Specify a item ID')
    else:
        _xml.raiseWrongXml(xmlCtx, section.name, 'Specify a item ID')
    action = tutorial_chapter.Action(eventType, itemID)
    action.setID(actionID)
    for _, effectSec in _xml.getChildren(xmlCtx, section, 'effects'):
        effect = _parseEffect(xmlCtx, effectSec, flags)
        if effect is not None:
            action.addEffect(effect)

    return action
コード例 #3
0
def _parseActions(xmlCtx, section, flags):
    result = []
    for name, subSec in section.items():
        actionType = ACTION_TAGS.get(name)
        if actionType is None:
            LOG_ERROR('Action is not supported: ', name)
            continue
        targetID = _parseID(xmlCtx, subSec, 'Specify a target ID')
        action = chapter.Action(actionType, targetID)
        if 'effects' in subSec.keys():
            for _, effectSec in _xml.getChildren(xmlCtx, subSec, 'effects'):
                effect = _parseEffect(xmlCtx, effectSec, flags)
                if effect is not None:
                    action.addEffect(effect)

        result.append(action)

    return result