def seeScenePanel(): ''' 当前场景信息面板 ''' titleText = TextLoading.getTextData(TextLoading.stageWordPath, '75') EraPrint.plt(titleText) timeText = GameTime.getDateText() EraPrint.p(timeText) EraPrint.p(' ') scenePath = CacheContorl.characterData['character'][0].Position scenePathStr = MapHandle.getMapSystemPathStrForList(scenePath) mapList = MapHandle.getMapHierarchyListForScenePath(scenePath, []) mapPathText = '' mapList.reverse() for nowMap in mapList: nowMapMapSystemStr = MapHandle.getMapSystemPathStrForList(nowMap) mapName = CacheContorl.mapData[nowMapMapSystemStr]['MapName'] mapPathText += mapName + '-' sceneData = CacheContorl.sceneData[scenePathStr].copy() sceneName = mapPathText + sceneData['SceneName'] sceneInfoHead = TextLoading.getTextData(TextLoading.stageWordPath, '76') sceneInfo = sceneInfoHead + sceneName EraPrint.p(sceneInfo) panelState = CacheContorl.panelState['SeeSceneCharacterListPage'] switch = panelStateOnText if panelState == '0': switch = panelStateOffText sceneCharacterList = sceneData['SceneCharacterData'] if len(sceneCharacterList) > 1: EraPrint.p(' ') PyCmd.pcmd(switch, 'SeeSceneCharacterListPage') EraPrint.plittleline()
def seeScenePanel(): ''' 当前场景信息面板 ''' titleText = TextLoading.getTextData(TextLoading.stageWordPath, '75') EraPrint.plt(titleText) timeText = GameTime.getDateText() EraPrint.p(timeText) EraPrint.p(' ') scenePath = CacheContorl.characterData['character']['0']['Position'] scenePathStr = MapHandle.getMapSystemPathStrForList(scenePath) sceneData = CacheContorl.sceneData[scenePathStr].copy() sceneName = sceneData['SceneName'] sceneInfoHead = TextLoading.getTextData(TextLoading.stageWordPath, '76') sceneInfo = sceneInfoHead + sceneName EraPrint.p(sceneInfo) panelState = CacheContorl.panelState['SeeSceneCharacterListPage'] switch = panelStateOnText if panelState == '0': switch = panelStateOffText sceneCharacterList = sceneData['SceneCharacterData'] if len(sceneCharacterList) > 1: EraPrint.p(' ') PyCmd.pcmd(switch, 'SeeSceneCharacterListPage') EraPrint.plittleline()
def getInScene_func(): ''' 用于进入场景界面的流程 ''' PyCmd.clr_cmd() scenePath = CacheContorl.characterData['character'][0].Position scenePathStr = MapHandle.getMapSystemPathStrForList(scenePath) MapHandle.sortSceneCharacterId(scenePathStr) CacheContorl.nowMap = MapHandle.getMapForPath(scenePath) sceneData = CacheContorl.sceneData[scenePathStr].copy() sceneCharacterList = sceneData['SceneCharacterData'] if 0 not in sceneCharacterList: characterIdList = [0] sceneCharacterList = sceneCharacterList + characterIdList CacheContorl.sceneData[scenePathStr][ 'SceneCharacterData'] = sceneCharacterList if len(sceneCharacterList ) > 1 and CacheContorl.characterData['characterId'] == 0: nowNameList = MapHandle.getSceneCharacterNameList(scenePathStr) nowNameList.remove(CacheContorl.characterData['character'][0].Name) CacheContorl.characterData[ 'characterId'] = MapHandle.getCharacterIdByCharacterName( nowNameList[0], scenePathStr) if CacheContorl.oldCharacterId != 0: CacheContorl.characterData[ 'characterId'] = CacheContorl.oldCharacterId CacheContorl.oldCharacterId = 0 if len(sceneCharacterList) > 1: seeScene_func(True) else: seeScene_func(False)
def seeMovePathPanel(): inputS = [] nowScene = CacheContorl.characterData['character']['0']['Position'] nowMap = CacheContorl.nowMap nowMapStr = MapHandle.getMapSystemPathStrForList(nowMap) mapData = CacheContorl.mapData[nowMapStr] movePathInfo = TextLoading.getTextData(TextLoading.messagePath, '27') EraPrint.p(movePathInfo) EraPrint.p('\n') pathEdge = mapData['PathEdge'] mapSceneId = str(MapHandle.getMapSceneIdForScenePath(nowMap, nowScene)) scenePath = pathEdge[mapSceneId] scenePathList = ValueHandle.dictKeysToList(scenePath) try: scenePathList.remove(mapSceneId) except ValueError: pass if len(scenePathList) > 0: sceneCmd = [] for scene in scenePathList: loadSceneData = MapHandle.getSceneDataForMap(nowMap, scene) sceneName = loadSceneData['SceneName'] sceneCmd.append(sceneName) yrn = CmdButtonQueue.optionstr(cmdList=None, cmdListData=sceneCmd, cmdColumn=4, askfor=False, cmdSize='center') inputS = inputS + yrn else: errorMoveText = TextLoading.getTextData(TextLoading.messagePath, '28') EraPrint.p(errorMoveText) EraPrint.pline() return {'inputS': inputS, 'scenePathList': scenePathList}
def showSceneNameListPanel() -> str: ''' 地图下场景名称绘制面板 ''' titleText = TextLoading.getTextData(TextLoading.stageWordPath, '86') EraPrint.p(titleText) panelState = CacheContorl.panelState['SeeSceneNameListPanel'] if panelState == '0': PyCmd.pcmd(panelStateOffText, "SeeSceneNameListPanel") EraPrint.p('\n') nowMap = CacheContorl.nowMap nowPosition = CacheContorl.characterData['character']['0']['Position'] nowScene = MapHandle.getSceneIdInMapForScenePathOnMapPath( nowPosition, nowMap) nowMapMapSystemStr = MapHandle.getMapSystemPathStrForList(nowMap) sceneNameData = MapHandle.getSceneNameListForMapPath( nowMapMapSystemStr) sceneNameList = {} nullScene = nowScene for scene in sceneNameData: sceneNameList[scene] = scene + ':' + sceneNameData[scene] CmdButtonQueue.optionstr(None, 4, 'center', False, False, list(sceneNameList.values()), nullScene, list(sceneNameList.keys())) else: PyCmd.pcmd(panelStateOnText, 'SeeSceneNameListPanel') EraPrint.p('\n') EraPrint.plittleline() return 'SeeSceneNameListPanel'
def differenceMapMove(characterId:str,targetScene:list) -> 'MoveEnd:str_Null,str_End,list': ''' 角色跨地图层级移动 Keyword arguments: characterId -- 角色id targetScene -- 寻路目标场景(在地图系统下的绝对坐标) ''' nowPosition = CacheContorl.characterData['character'][characterId].Position isAffiliation = MapHandle.judgeSceneIsAffiliation(nowPosition,targetScene) nowTruePosition = MapHandle.getScenePathForTrue(nowPosition) mapDoorData = MapHandle.getMapDoorDataForScenePath(MapHandle.getMapSystemPathStrForList(nowTruePosition)) doorScene = '0' nowTrueMap = MapHandle.getMapForPath(nowTruePosition) nowTrueMapMapSystemStr = MapHandle.getMapSystemPathStrForList(nowTrueMap) if isAffiliation == 'subordinate': nowTrueAffiliation = MapHandle.judgeSceneIsAffiliation(nowTruePosition,targetScene) if nowTrueAffiliation == 'subordinate': if mapDoorData != {}: doorScene = mapDoorData[nowTrueMapMapSystemStr]['Door'] nowMapSceneId = MapHandle.getMapSceneIdForScenePath(nowTrueMap,nowPosition) return identicalMapMove(characterId,nowTrueMap,nowMapSceneId,doorScene) elif nowTrueAffiliation == 'superior': nowMap = MapHandle.getMapForPath(targetScene) nowMapSceneId = MapHandle.getMapSceneIdForScenePath(nowMap,nowPosition) return identicalMapMove(characterId,nowMap,nowMapSceneId,doorScene) else: if nowTrueMap == []: nowTargetMapSceneId = MapHandle.getMapSceneIdForScenePath([],targetScene) nowMapSceneId = MapHandle.getMapSceneIdForScenePath([],nowTruePosition) return identicalMapMove(characterId,[],nowMapSceneId,nowTargetMapSceneId) else: relationMapList = MapHandle.getRelationMapListForScenePath(nowTruePosition) nowSceneRealMap = relationMapList[-1] commonMap = MapHandle.getCommonMapForScenePath(nowTruePosition,targetScene) realMapInMap = MapHandle.getMapForPath(nowSceneRealMap) targetMapSceneId = MapHandle.getMapSceneIdForScenePath(commonMap,targetScene) if nowSceneRealMap == commonMap: nowMapSceneId = MapHandle.getMapSceneIdForScenePath(commonMap,nowTruePosition) elif realMapInMap == commonMap: nowMapSceneId = MapHandle.getMapSceneIdForScenePath(commonMap,nowSceneRealMap) else: nowMapSceneId =MapHandle.getMapSceneIdForScenePath(nowTrueMap,nowTruePosition) targetMapSceneId = '0' return identicalMapMove(characterId,commonMap,nowMapSceneId,targetMapSceneId)
def seeMapPanel() -> list: ''' 地图绘制面板 ''' inputS = [] titleText = TextLoading.getTextData(TextLoading.stageWordPath, '78') nowMap = CacheContorl.nowMap nowMapMapSystemStr = MapHandle.getMapSystemPathStrForList(nowMap) mapName = CacheContorl.mapData[nowMapMapSystemStr]['MapName'] EraPrint.plt(titleText + ': ' + mapName + ' ') inputS = inputS + MapHandle.printMap(nowMap) return inputS
def seeScenePanel(): titleText = TextLoading.getTextData(TextLoading.stageWordPath,'75') EraPrint.plt(titleText) timeText = GameTime.getDateText() EraPrint.p(timeText) EraPrint.p(' ') scenePath = CacheContorl.characterData['character']['0']['Position'] scenePathStr = MapHandle.getMapSystemPathStrForList(scenePath) sceneData = CacheContorl.sceneData[scenePathStr].copy() sceneName = sceneData['SceneName'] sceneInfoHead = TextLoading.getTextData(TextLoading.stageWordPath, '76') sceneInfo = sceneInfoHead + sceneName EraPrint.p(sceneInfo) EraPrint.plittleline()
def seeMovePathPanel() -> dict: ''' 当前场景可直接通往的移动路径绘制面板 ''' inputS = [] nowScene = CacheContorl.characterData['character'][0].Position nowMap = CacheContorl.nowMap nowMapStr = MapHandle.getMapSystemPathStrForList(nowMap) mapData = CacheContorl.mapData[nowMapStr] movePathInfo = TextLoading.getTextData(TextLoading.messagePath, '27') EraPrint.p(movePathInfo) EraPrint.p('\n') pathEdge = mapData['PathEdge'] mapSceneId = str(MapHandle.getMapSceneIdForScenePath(nowMap, nowScene)) scenePath = pathEdge[mapSceneId] scenePathList = list(scenePath.keys()) if mapSceneId in scenePathList: remove(mapSceneId) if len(scenePathList) > 0: sceneCmd = [] for scene in scenePathList: nowMapStr = MapHandle.getMapSystemPathStrForList(nowMap) loadSceneData = MapHandle.getSceneDataForMap(nowMapStr, scene) sceneName = loadSceneData['SceneName'] sceneCmd.append(sceneName) yrn = CmdButtonQueue.optionstr(cmdList=None, cmdListData=sceneCmd, cmdColumn=4, askfor=False, cmdSize='center') inputS = inputS + yrn else: errorMoveText = TextLoading.getTextData(TextLoading.messagePath, '28') EraPrint.p(errorMoveText) EraPrint.pline() return {'inputS': inputS, 'scenePathList': scenePathList}
def getInScene_func(): PyCmd.clr_cmd() scenePath = CacheContorl.characterData['character']['0']['Position'] MapHandle.sortSceneCharacterId(scenePath) CacheContorl.nowMap = MapHandle.getMapForPath(scenePath) scenePathStr = MapHandle.getMapSystemPathStrForList(scenePath) sceneData = CacheContorl.sceneData[scenePathStr].copy() sceneCharacterList = sceneData['SceneCharacterData'] if '0' not in sceneCharacterList: characterIdList = ['0'] sceneCharacterList = sceneCharacterList + characterIdList CacheContorl.sceneData[scenePathStr][ 'SceneCharacterData'] = sceneCharacterList if len(sceneCharacterList) > 1: CacheContorl.characterData['characterId'] = sceneCharacterList[0] seeScene_func('0') else: seeScene_func('1')
def identicalMapMove(characterId:str,nowMap:list,nowMapSceneId:str,targetMapSceneId:str) -> 'MoveEnd:str_Null,str_End,list': ''' 角色在相同地图层级内移动 Keyword arguments: characterId -- 角色id nowMap -- 当前地图路径 nowMapSceneId -- 当前角色所在场景(当前地图层级下的相对坐标) targetMapSceneId -- 寻路目标场景(当前地图层级下的相对坐标) ''' nowMapStr = MapHandle.getMapSystemPathStrForList(nowMap) movePath = MapHandle.getPathfinding(nowMapStr,nowMapSceneId,targetMapSceneId) if movePath != 'End' and movePath != 'Null': nowTargetSceneId = movePath['Path'][0] nowNeedTime = movePath['Time'][0] nowCharacterPosition = MapHandle.getScenePathForMapSceneId(nowMap,nowMapSceneId) nowTargetPosition = MapHandle.getScenePathForMapSceneId(nowMap,nowTargetSceneId) MapHandle.characterMoveScene(nowCharacterPosition,nowTargetPosition,characterId) GameTime.subTimeNow(nowNeedTime) return movePath
def changeSceneCharacterListPanel() -> list: ''' 当前场景角色列表页切换控制面板 ''' nameListMax = int(GameConfig.in_scene_see_player_max) nowPage = int(CacheContorl.panelState['SeeSceneCharacterListPanel']) scenePath = CacheContorl.characterData['character']['0']['Position'] scenePathStr = MapHandle.getMapSystemPathStrForList(scenePath) sceneCharacterNameList = MapHandle.getSceneCharacterNameList(scenePathStr) characterMax = len(sceneCharacterNameList) pageMax = math.floor(characterMax / nameListMax) pageText = '(' + str(nowPage) + '/' + str(pageMax) + ')' inputS = CmdButtonQueue.optionint(CmdButtonQueue.changescenecharacterlist, cmdColumn=5, askfor=False, cmdSize='center') EraPrint.printPageLine(sample='-', string=pageText) EraPrint.pl() return inputS
def getCharacterDormitoryPathText(characterId: str) -> str: ''' 获取角色宿舍路径描述信息 Keyword arguments: characterId -- 角色Id Return arguments: mapPathStr -- 宿舍路径描述文本 ''' dormitory = CacheContorl.characterData['character'][characterId].Dormitory dormitoryPath = MapHandle.getMapSystemPathForStr(dormitory) mapList = MapHandle.getMapHierarchyListForScenePath(dormitoryPath, []) mapPathText = TextLoading.getTextData(TextLoading.stageWordPath, '143') mapList.reverse() for nowMap in mapList: nowMapMapSystemStr = MapHandle.getMapSystemPathStrForList(nowMap) mapName = CacheContorl.mapData[nowMapMapSystemStr]['MapName'] mapPathText += mapName + '-' mapPathText += CacheContorl.sceneData[dormitory]['SceneName'] return mapPathText
def seeSceneCharacterListPanel() -> list: ''' 当前场景角色列表面板 ''' inputS = [] seeCharacterText = TextLoading.getTextData(TextLoading.messagePath, '26') EraPrint.p(seeCharacterText) EraPrint.p('\n') scenePath = CacheContorl.characterData['character']['0']['Position'] scenePathStr = MapHandle.getMapSystemPathStrForList(scenePath) nameList = MapHandle.getSceneCharacterNameList(scenePathStr, True) nameList = getNowPageNameList(nameList) characterId = CacheContorl.characterData['characterId'] characterData = CacheContorl.characterData['character'][characterId] characterName = characterData['Name'] inputS = CmdButtonQueue.optionstr('', cmdColumn=10, cmdSize='center', askfor=False, cmdListData=nameList, nullCmd=characterName) return inputS
def showSceneNameListPanel() -> str: ''' 地图下场景名称绘制面板 ''' titleText = TextLoading.getTextData(TextLoading.stageWordPath, '86') EraPrint.p(titleText) panelState = CacheContorl.panelState['SeeSceneNameListPanel'] if panelState == '0': PyCmd.pcmd(panelStateOffText, "SeeSceneNameListPanel") EraPrint.p('\n') nowMap = CacheContorl.nowMap nowMapMapSystemStr = MapHandle.getMapSystemPathStrForList(nowMap) sceneNameData = MapHandle.getSceneNameListForMapPath( nowMapMapSystemStr) sceneNameList = [] for scene in sceneNameData: sceneNameList.append(scene + ':' + sceneNameData[scene]) EraPrint.plist(sceneNameList, 5, 'center') else: PyCmd.pcmd(panelStateOnText, 'SeeSceneNameListPanel') EraPrint.p('\n') EraPrint.plittleline() return 'SeeSceneNameListPanel'
def seeAttrOnEveryTime_func(): ''' 通用用于查看角色属性的流程 ''' while (True): characterId = CacheContorl.characterData['characterId'] if CacheContorl.oldFlowId == 'in_scene': nowScene = CacheContorl.characterData['character'][0].Position nowSceneStr = MapHandle.getMapSystemPathStrForList(nowScene) characterIdList = MapHandle.getSceneCharacterIdList(nowSceneStr) else: characterIdList = list( CacheContorl.characterData['character'].keys()) characterIdIndex = characterIdList.index(characterId) inputS = [] seeAttrInEveryTime_func() askSeeAttr = SeeCharacterAttrPanel.askForSeeAttr() inputS += askSeeAttr inputs1 = SeeCharacterAttrPanel.askForSeeAttrCmd() inputS += inputs1 yrn = GameInit.askfor_All(inputS) PyCmd.clr_cmd() showAttrHandleData = TextLoading.getTextData(TextLoading.cmdPath, 'seeAttrPanelHandle') characterMax = characterIdList[len(characterIdList) - 1] if yrn in showAttrHandleData: CacheContorl.panelState['AttrShowHandlePanel'] = yrn elif yrn == '0': if characterIdIndex == 0: CacheContorl.characterData['characterId'] = characterMax else: characterId = characterIdList[characterIdIndex - 1] CacheContorl.characterData['characterId'] = characterId elif yrn == '1': if CacheContorl.oldFlowId == 'main': CacheContorl.characterData['characterId'] = 0 elif CacheContorl.oldFlowId == 'see_character_list': characterListShow = int(GameConfig.characterlist_show) nowPageId = characterIdIndex / characterListShow CacheContorl.panelState['SeeCharacterListPanel'] = nowPageId elif CacheContorl.oldFlowId == 'in_scene': scenePath = CacheContorl.characterData['character'][0].Position scenePathStr = MapHandle.getMapSystemPathStrForList(scenePath) nameList = MapHandle.getSceneCharacterNameList( scenePathStr, True) nowCharacterName = CacheContorl.characterData['character'][ CacheContorl.characterData['characterId']].Name try: nowCharacterIndex = nameList.index(nowCharacterName) except ValueError: nowCharacterIndex = 0 nameListMax = int(GameConfig.in_scene_see_player_max) nowSceneCharacterListPage = math.floor(nowCharacterIndex / nameListMax) CacheContorl.panelState[ 'SeeSceneCharacterListPanel'] = nowSceneCharacterListPage CacheContorl.panelState['AttrShowHandlePanel'] = 'MainAttr' CacheContorl.nowFlowId = CacheContorl.oldFlowId CacheContorl.oldFlowId = CacheContorl.tooOldFlowId break elif yrn == '2': if characterId == characterMax: characterId = characterIdList[0] CacheContorl.characterData['characterId'] = characterId else: characterId = characterIdList[characterIdIndex + 1] CacheContorl.characterData['characterId'] = characterId
def seeScene_func(judge: bool): ''' 用于查看当前场景界面的流程 Keyword argument: judge -- 判断是否绘制角色列表界面的开关 ''' while (True): inputS = [] InScenePanel.seeScenePanel() scenePath = CacheContorl.characterData['character'][0].Position scenePathStr = MapHandle.getMapSystemPathStrForList(scenePath) sceneCharacterNameList = MapHandle.getSceneCharacterNameList( scenePathStr) nameListMax = int(GameConfig.in_scene_see_player_max) changePageJudge = False if len(sceneCharacterNameList) == 1: CacheContorl.characterData['characterId'] = 0 inSceneCmdList1 = [] if judge: if CacheContorl.panelState['SeeSceneCharacterListPage'] == '0': inputS = inputS + InScenePanel.seeSceneCharacterListPanel() if len(sceneCharacterNameList) > nameListMax: inSceneCmdList1 = InScenePanel.changeSceneCharacterListPanel( ) changePageJudge = True inputS.append('SeeSceneCharacterListPage') startId1 = len(inSceneCmdList1) InScenePanel.seeCharacterInfoPanel() SeeCharacterAttrPanel.seeCharacterHPAndMPInSence( CacheContorl.characterData['characterId']) SeeCharacterAttrPanel.seeCharacterStatusPanel( CacheContorl.characterData['characterId']) instructHead = InstructPanel.seeInstructHeadPanel() inSceneCmdList2 = InScenePanel.inSceneButtonPanel(startId1) if changePageJudge: inputS += inSceneCmdList1 + instructHead + inSceneCmdList2 else: inputS += instructHead + inSceneCmdList2 yrn = GameInit.askfor_All(inputS) PyCmd.clr_cmd() nowPage = int(CacheContorl.panelState['SeeSceneCharacterListPanel']) characterMax = len(CacheContorl.characterData['character']) - 1 pageMax = math.floor(characterMax / nameListMax) if yrn in sceneCharacterNameList: CacheContorl.characterData[ 'characterId'] = MapHandle.getCharacterIdByCharacterName( yrn, scenePathStr) elif judge and yrn not in inSceneCmdList2 and yrn != 'SeeSceneCharacterListPage' and changePageJudge: if yrn == inSceneCmdList1[0]: CacheContorl.panelState['SeeSceneCharacterListPanel'] = 0 elif yrn == inSceneCmdList1[1]: if int(nowPage) == 0: CacheContorl.panelState[ 'SeeSceneCharacterListPanel'] = pageMax else: CacheContorl.panelState[ 'SeeSceneCharacterListPanel'] = int(nowPage) - 1 elif yrn == inSceneCmdList1[2]: CacheContorl.panelState[ 'SeeSceneCharacterListPanel'] = InScenePanel.jumpCharacterListPagePanel( ) elif yrn == inSceneCmdList1[3]: if int(nowPage) == pageMax: CacheContorl.panelState['SeeSceneCharacterListPanel'] = 0 else: CacheContorl.panelState[ 'SeeSceneCharacterListPanel'] = int(nowPage) + 1 elif yrn == inSceneCmdList1[4]: CacheContorl.panelState['SeeSceneCharacterListPanel'] = pageMax elif yrn == inSceneCmdList2[0]: CacheContorl.nowFlowId = 'see_map' nowMap = MapHandle.getMapForPath( CacheContorl.characterData['character'][0].Position) CacheContorl.nowMap = nowMap break elif yrn in [inSceneCmdList2[1], inSceneCmdList2[2]]: if yrn == inSceneCmdList2[2]: CacheContorl.oldCharacterId = CacheContorl.characterData[ 'characterId'] CacheContorl.characterData['characterId'] = 0 CacheContorl.nowFlowId = 'see_character_attr' CacheContorl.oldFlowId = 'in_scene' break elif yrn == 'SeeSceneCharacterListPage': PanelStateHandle.panelStateChange(yrn) elif yrn in instructHead: if CacheContorl.instructFilter[yrn] == 1: CacheContorl.instructFilter[yrn] = 0 else: CacheContorl.instructFilter[yrn] = 1