Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/parser/src/scriptParser/contentParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ function getChooseContent(contentRaw: string, assetSetter: any): string {
const chooseKeyList: Array<string> = [];
const chooseValueList: Array<string> = [];
for (const e of chooseList) {
chooseKeyList.push(e.split(/(?<!\\):/)[0] ?? '');
chooseValueList.push(e.split(/(?<!\\):/)[1] ?? '');
const chooseItem = e.split(/(?<!\\):|(?<!\\):/);
chooseKeyList.push(chooseItem[0] ?? '');
chooseValueList.push(chooseItem[1] ?? '');
}
const parsedChooseList = chooseValueList.map((e) => {
if (e.match(/\./)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/parser/src/scriptParser/subSceneScanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const subSceneScanner = (
}
if (command === commandType.choose) {
const chooseList = content.split('|');
const chooseValue = chooseList.map((e) => e.split(':')[1] ?? '');
const chooseValue = chooseList.map((e) => e.split(/(?<!\\):|(?<!\\):/)[1] ?? '');
chooseValue.forEach((e) => {
if (e.match(/\./)) {
subSceneList.push(e);
Expand Down
20 changes: 20 additions & 0 deletions packages/parser/test/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,26 @@ test("choose", async () => {
expect(result.sentenceList).toContainEqual(expectSentenceItem);
});

test("choose supports chinese colon separator", async () => {
const parser = new SceneParser((assetList) => {
}, (fileName, assetType) => {
return fileName;
}, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG);

const result = parser.parse(`choose:继续冒险:sceneA.scene|返回城市:sceneB.scene;`, 'test', 'test');

const expectSentenceItem: ISentence = {
command: commandType.choose,
commandRaw: "choose",
content: "继续冒险:sceneA.scene|返回城市:sceneB.scene",
args: [],
sentenceAssets: [],
subScene: ["sceneA.scene", "sceneB.scene"],
inlineComment: ""
};
expect(result.sentenceList).toContainEqual(expectSentenceItem);
});

test("long-script", async () => {

const sceneRaw = await fsp.readFile('test/test-resources/long-script.txt');
Expand Down