Exemplo n.º 1
0
def init(main_flow):
    global def_style
    IoInit.clear_screen()
    IoInit.clearorder()
    FlowHandle.cmd_clear()
    # 事件载入
    Event.load_event_file()
    # 载入按键监听
    KeyListionEvent.onWFrameListion()
    # 设置背景颜色
    IoInit.set_background(GameData.gamedata()['core_cfg']['background_color'])
    # 初始化字体
    IoInit.init_style()
    # 初始化地图数据
    CacheContorl.mapData = GameData._gamedata[GameConfig.language]['map']
    CacheContorl.sceneData = GameData.sceneData
    CacheContorl.mapData = GameData.mapData
    FlowHandle.reset_func = reset
    global _main_flow
    _main_flow = main_flow

    _have_run = False

    def run_main_flow():
        nonlocal _have_run
        while True:
            if _have_run == False:
                main_flow()
                _have_run = True
            askfor_order()
            FlowHandle.call_default_flow()
            if FlowHandle.exit_flag == True:
                break

    run_main_flow()
Exemplo n.º 2
0
def pcmd(cmd_str,
         cmd_id,
         cmd_func=FlowHandle.null_func,
         arg=(),
         kw={},
         normal_style='standard',
         on_style='onbutton'):
    '''
    打印一条指令
    Keyword arguments:
    cmd_str -- 命令对应文字
    cmd_id -- 命令数字
    cmd_func -- 命令函数
    arg -- 传给命令函数的顺序参数
    kw -- 传给命令函数的字典参数
    normal_style -- 正常状态下命令显示样式
    on_style -- 鼠标在其上的时候命令显示样式
    '''
    cmd_str = Dictionaries.handleText(cmd_str)
    cmd_id = Dictionaries.handleText(str(cmd_id))
    CacheContorl.textWait = float(GameConfig.text_wait)
    global last_char
    if len(cmd_str) > 0:
        last_char = cmd_str[-1:]
    FlowHandle.print_cmd(cmd_str, cmd_id, cmd_func, arg, kw, normal_style,
                         on_style)
Exemplo n.º 3
0
def plwait(string='', style='standard'):
    textWait = CacheContorl.textWait
    if textWait != 0:
        time.sleep(textWait)
    else:
        pass
    pl(string, style)
    FlowHandle.askfor_wait()
Exemplo n.º 4
0
def pcmd(cmd_str, cmd_id, cmd_func=FlowHandle.null_func, arg=(), kw={}, normal_style='standard', on_style='onbutton'):
    cmd_str = Dictionaries.handleText(cmd_str)
    cmd_id = Dictionaries.handleText(str(cmd_id))
    CacheContorl.textWait = float(GameConfig.text_wait)
    global last_char
    if len(cmd_str) > 0:
        last_char = cmd_str[-1:]
    FlowHandle.print_cmd(cmd_str, cmd_id, cmd_func, arg, kw, normal_style, on_style)
Exemplo n.º 5
0
def clr_cmd(*number, clr_default_flow=True):
    if clr_default_flow == True:
        clear_default_flow()
    if number:
        FlowHandle.cmd_clear(number)
    else:
        global unused_cmd_num
        unused_cmd_num = 500
        FlowHandle.cmd_clear()
Exemplo n.º 6
0
def startFrame():
    '''
    游戏主流程
    '''
    FlowHandle.initCache()
    while (True):
        nowFlowId = CacheContorl.nowFlowId
        PyCmd.clr_cmd()
        flowData[nowFlowId]()
Exemplo n.º 7
0
 def run_main_flow():
     nonlocal _have_run
     while True:
         if _have_run == False:
             main_flow()
             _have_run = True
         askfor_order()
         FlowHandle.call_default_flow()
         if FlowHandle.exit_flag == True:
             break
Exemplo n.º 8
0
def plwait(string='', style='standard'):
    '''
    绘制文本换行并等待玩家按下回车或鼠标左键
    Keyword arguments:
    string -- 要绘制的文本 (default '')
    style -- 绘制文本的默认样式 (default 'standard')
    '''
    textWait = CacheContorl.textWait
    if textWait != 0:
        time.sleep(textWait)
    pl(string, style)
    FlowHandle.askfor_wait()
Exemplo n.º 9
0
def clr_cmd(*number, clr_default_flow=True):
    '''
    清楚绑定命令和默认处理函数
    Keyword arguments:
    number -- 清楚绑定命令数字
    clr_default_flow -- 是否同时清楚默认处理函数
    '''
    if clr_default_flow==True:
        clear_default_flow()
    if number:
        FlowHandle.cmd_clear(number)
    else:
        global  unused_cmd_num
        unused_cmd_num = 500
        FlowHandle.cmd_clear()
Exemplo n.º 10
0
def changeCharacterClothes(characterId):
    ChangeClothesPanel.seeCharacterWearClothes(characterId)
    inputS = ChangeClothesPanel.seeCharacterWearClothesCmd()
    yrn = FlowHandle.askfor_All(inputS)
    if yrn == '0':
        from script.Flow import Main
        Main.mainFrame_func()
Exemplo n.º 11
0
def gameHelp_func():
    '''
    查看帮助信息流程
    '''
    inputS = GameHelpPanel.gameHelpPanel()
    yrn = FlowHandle.askfor_All(inputS)
    if yrn == '0':
        CacheContorl.nowFlowId = 'main'
Exemplo n.º 12
0
def seeMapFlow():
    '''
    地图查看流程
    '''
    while (True):
        PyCmd.clr_cmd()
        inputS = []
        mapCmd = SeeMapPanel.seeMapPanel()
        startId1 = len(mapCmd)
        inputS = inputS + mapCmd
        movePathCmdData = SeeMapPanel.seeMovePathPanel()
        movePathCmd = movePathCmdData['inputS']
        movePathList = movePathCmdData['scenePathList']
        showSceneNameListCmd = SeeMapPanel.showSceneNameListPanel()
        seeMapCmd = SeeMapPanel.backScenePanel(startId1)
        inputS = inputS + seeMapCmd + movePathCmd + [showSceneNameListCmd]
        yrn = FlowHandle.askfor_All(inputS)
        backButton = str(startId1)
        nowPosition = CacheContorl.characterData['character'][0].Position
        nowPositionMap = MapHandle.getMapForPath(nowPosition)
        upMapButton = 'Null'
        downMapButton = 'Null'
        if nowPositionMap != [] and CacheContorl.nowMap != []:
            upMapButton = str(int(startId1) + 1)
        if nowPositionMap != CacheContorl.nowMap:
            if upMapButton == 'Null':
                downMapButton = str(int(startId1) + 1)
            else:
                downMapButton = str(int(startId1) + 2)
        nowMap = CacheContorl.nowMap.copy()
        if yrn in mapCmd:
            nowTargetPath = MapHandle.getScenePathForMapSceneId(nowMap, yrn)
            CharacterMove.ownCharcterMove(nowTargetPath)
            break
        elif yrn == backButton:
            CacheContorl.nowMap = []
            CacheContorl.nowFlowId = 'in_scene'
            break
        elif yrn in movePathCmd:
            moveListId = movePathCmd.index(yrn)
            moveId = movePathList[moveListId]
            nowTargetPath = MapHandle.getScenePathForMapSceneId(nowMap, moveId)
            CharacterMove.ownCharcterMove(nowTargetPath)
            break
        elif upMapButton != 'Null' and yrn == upMapButton:
            upMapPath = MapHandle.getMapForPath(nowMap)
            CacheContorl.nowMap = upMapPath
        elif downMapButton != 'Null' and yrn == downMapButton:
            characterPosition = CacheContorl.characterData['character'][
                0].Position
            downMapSceneId = MapHandle.getMapSceneIdForScenePath(
                CacheContorl.nowMap, characterPosition)
            nowMap.append(downMapSceneId)
            CacheContorl.nowMap = nowMap
        elif yrn == showSceneNameListCmd:
            PanelStateHandle.panelStateChange(showSceneNameListCmd)
Exemplo n.º 13
0
def changeCharacterClothes():
    '''
    更换角色服装流程
    '''
    characterId = CacheContorl.characterData['characterId']
    ChangeClothesPanel.seeCharacterWearClothes(characterId)
    inputS = ChangeClothesPanel.seeCharacterWearClothesCmd()
    yrn = FlowHandle.askfor_All(inputS)
    if yrn == '0':
        CacheContorl.nowFlowId = 'main'
Exemplo n.º 14
0
def seeCharacterClothesList(clothingType: str):
    '''
    查看角色服装列表流程
    Keyword arguments:
    clothingType -- 服装类型
    '''
    clothingTypeList = list(Clothing.clothingTypeTextList.keys())
    while (True):
        nowClothingTypeIndex = clothingTypeList.index(clothingType)
        upTypeId = nowClothingTypeIndex - 1
        if nowClothingTypeIndex == 0:
            upTypeId = len(clothingTypeList) - 1
        nextTypeId = nowClothingTypeIndex + 1
        if nowClothingTypeIndex == len(clothingTypeList) - 1:
            nextTypeId = 0
        upType = clothingTypeList[upTypeId]
        nextType = clothingTypeList[nextTypeId]
        characterId = CacheContorl.characterData['characterId']
        ChangeClothesPanel.seeCharacterClothesInfo(characterId)
        pageMax = getCharacterClothesPageMax(characterId, clothingType)
        inputS = ChangeClothesPanel.seeCharacterClothesPanel(
            characterId, clothingType, pageMax)
        startId = len(inputS)
        inputS += ChangeClothesPanel.seeCharacterClothesCmd(
            startId, clothingType)
        yrn = FlowHandle.askfor_All(inputS)
        yrn = int(yrn)
        PyCmd.clr_cmd()
        nowPageId = int(CacheContorl.panelState["SeeCharacterClothesPanel"])
        if yrn == startId:
            clothingType = upType
        elif yrn == startId + 1:
            if nowPageId == 0:
                CacheContorl.panelState['SeeCharacterClothesPanel'] = str(
                    pageMax)
            else:
                CacheContorl.panelState['SeeCharacterClothesPanel'] = str(
                    nowPageId - 1)
        elif yrn == startId + 2:
            break
        elif yrn == startId + 3:
            if nowPageId == pageMax:
                CacheContorl.panelState['SeeCharacterClothesPanel'] = '0'
            else:
                CacheContorl.panelState['SeeCharacterClothesPanel'] = str(
                    nowPageId + 1)
        elif yrn == startId + 4:
            clothingType = nextType
        else:
            clothingId = list(
                CacheContorl.characterData['character'][characterId]
                ['Clothing'][clothingType].keys())[yrn]
            askSeeClothingInfo(clothingType, clothingId, characterId)
Exemplo n.º 15
0
def sceneSeeCharacterWearItem(characterId: str):
    '''
    在场景中查看角色穿戴道具列表的流程
    Keyword arguments:
    characterId -- 角色Id
    '''
    while 1:
        nowInputS = WearItemPanel.seeCharacterWearItemPanelForPlayer(
            characterId)
        nowYrn = FlowHandle.askfor_All(nowInputS)
        if nowYrn == nowInputS[:-1]:
            CacheContorl.nowFlowId = 'main'
            break
Exemplo n.º 16
0
def seeMapFlow():
    PyCmd.clr_cmd()
    inputS = []
    mapCmd = SeeMapPanel.seeMapPanel()
    startId1 = len(mapCmd)
    inputS = inputS + mapCmd
    movePathCmdData = SeeMapPanel.seeMovePathPanel()
    movePathCmd = movePathCmdData['inputS']
    movePathList = movePathCmdData['scenePathList']
    seeMapCmd = SeeMapPanel.backScenePanel(startId1)
    inputS = inputS + seeMapCmd + movePathCmd
    yrn = FlowHandle.askfor_All(inputS)
    backButton = str(startId1)
    nowPosition = CacheContorl.characterData['character']['0']['Position']
    nowPositionMap = MapHandle.getMapForPath(nowPosition)
    upMapButton = 'Null'
    downMapButton = 'Null'
    if nowPositionMap != [] and CacheContorl.nowMap != []:
        upMapButton = str(int(startId1) + 1)
    if nowPositionMap != CacheContorl.nowMap:
        if upMapButton == 'Null':
            downMapButton = str(int(startId1) + 1)
        else:
            downMapButton = str(int(startId1) + 2)
    nowMap = CacheContorl.nowMap
    if yrn in mapCmd:
        nowTargetPath = MapHandle.getScenePathForMapSceneId(nowMap,yrn)
        CharacterMove.ownCharcterMove(nowTargetPath)
    elif yrn == backButton:
        CacheContorl.nowMap = []
        import script.Flow.InScene as inscene
        inscene.getInScene_func()
    elif yrn in movePathCmd:
        moveListId = movePathCmd.index(yrn)
        moveId = movePathList[moveListId]
        nowTargetPath = MapHandle.getScenePathForMapSceneId(nowMap,moveId)
        CharacterMove.ownCharcterMove(nowTargetPath)
    elif upMapButton != 'Null' and yrn == upMapButton:
        upMapPath = MapHandle.getMapForPath(nowMap)
        CacheContorl.nowMap = upMapPath
        seeMapFlow()
    elif downMapButton != 'Null' and yrn == downMapButton:
        characterPosition = CacheContorl.characterData['character']['0']['Position']
        downMapSceneId = MapHandle.getMapSceneIdForScenePath(CacheContorl.nowMap,characterPosition)
        downMapPath = nowMap.append(downMapSceneId)
        CacheContorl.nowMap = downMapPath
        seeMapFlow()
Exemplo n.º 17
0
def changeCharacterClothes():
    '''
    更换角色服装流程
    '''
    characterId = CacheContorl.characterData['characterId']
    characterClothingData = CacheContorl.characterData['character'][characterId].Clothing
    ChangeClothesPanel.seeCharacterWearClothesInfo(characterId)
    cmdList1 = ChangeClothesPanel.seeCharacterWearClothes(characterId,True)
    startId = len(characterClothingData.keys())
    inputS = ChangeClothesPanel.seeCharacterWearClothesCmd(startId)
    inputS = cmdList1 + inputS
    yrn = FlowHandle.askfor_All(inputS)
    PyCmd.clr_cmd()
    if yrn == str(startId):
        CacheContorl.nowFlowId = 'main'
    else:
        clothingType = list(Clothing.clothingTypeTextList.keys())[int(yrn)]
        seeCharacterClothesList(clothingType)
Exemplo n.º 18
0
def wearCharacterItem():
    '''
    查看并更换角色穿戴道具流程
    '''
    characterId = CacheContorl.characterData['characterId']
    while 1:
        inputs = WearItemPanel.seeCharacterWearItemPanelForPlayer(characterId)
        startId = len(inputs)
        inputs += WearItemPanel.seeCharacterWearItemCmdPanel(startId)
        yrn = FlowHandle.askfor_All(inputs)
        PyCmd.clr_cmd()
        if yrn == str(len(inputs) - 1):
            CacheContorl.nowFlowId = 'main'
            break
        else:
            wearItemInfoTextData = TextLoading.getTextData(
                TextLoading.stageWordPath, '49')
            changeWearItem(list(wearItemInfoTextData.keys())[int(yrn)])
Exemplo n.º 19
0
def changeWearItem(itemType: str) -> bool:
    '''
    更换角色穿戴道具流程
    Keyword arguments:
    itemType -- 道具类型
    '''
    characterId = CacheContorl.characterData['characterId']
    maxPage = getCharacterWearItemPageMax(characterId)
    inputS = WearItemPanel.seeCharacterWearItemListPanel(
        characterId, itemType, maxPage)
    if inputS == []:
        return
    yrn = FlowHandle.askfor_All(inputS)
    if yrn == inputS[:-1]:
        return
    else:
        CacheContorl.characterData['character'][characterId].WearItem['Wear'][
            itemType] = list(
                CacheContorl.characterData['character']
                [characterId].WearItem['Item'][itemType].keys())[int(yrn)]
Exemplo n.º 20
0
def gameHelp_func():
    inputS = GameHelpPanel.gameHelpPanel()
    yrn = FlowHandle.askfor_All(inputS)
    if yrn == '0':
        from script.Flow import Main
        Main.mainFrame_func()
Exemplo n.º 21
0
def loadGamePanel():
    FlowHandle.initCache()
    EraPrint.pnextscreen()
    EraPrint.pnextscreen()
    EraPrint.pobo(1 / 3, TextLoading.getTextData(TextLoading.messagePath, '1'))
    EraPrint.p('\n')