From 3b4cb81799ff7885141c92ad7f8a40b19ccfe779 Mon Sep 17 00:00:00 2001 From: Rintim Date: Sat, 23 Dec 2023 16:03:59 +0800 Subject: [PATCH] fix: maybe not a bug. --- noname/game/index.js | 25 +++++++++++-------------- noname/library/element/content.js | 5 ++++- noname/library/element/contents.js | 2 +- noname/library/index.js | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/noname/game/index.js b/noname/game/index.js index 4002ec736..e3d71a8a3 100644 --- a/noname/game/index.js +++ b/noname/game/index.js @@ -5836,21 +5836,18 @@ export class Game extends Uninstantable { let { step, source, player, target, targets, card, cards, skill, forced, num, _trigger: trigger, _result: result, _storeEvent } = event; // 数组形式 if ("contents" in event && Array.isArray(event.contents)) { - event.contents[step](event, trigger, player, _storeEvent) - .then((evt) => Promise.resolve(evt)) - .then((evt) => { - event._storeEvent = evt; - if (step < event.contents.length - 1 && !event.finished) return resolve(); - if (game.executingAsyncEventMap.has(event.toEvent())) { - game.executingAsyncEventMap.set(_status.event.toEvent(), game.executingAsyncEventMap.get(_status.event.toEvent()).then(() => { - event.finish(); - resolve(); - })); - } else { - event.finish(); + event.contents[step](event, trigger, player, _storeEvent).then((evt) => { + if (evt) event._storeEvent = evt; + if (game.executingAsyncEventMap.has(event.toEvent())) { + game.executingAsyncEventMap.set(_status.event.toEvent(), game.executingAsyncEventMap.get(_status.event.toEvent()).then(() => { + if (event.step >= event.contents.length - 1) event.finish(); resolve(); - } - }) + })); + } else { + if (event.step >= event.contents.length - 1) event.finish(); + resolve(); + } + }) } else if (event.content instanceof GeneratorFunction) { if (!event.debugging) { diff --git a/noname/library/element/content.js b/noname/library/element/content.js index 8cec78a27..b9b53f44b 100644 --- a/noname/library/element/content.js +++ b/noname/library/element/content.js @@ -2409,7 +2409,7 @@ export default { /** * @deprecated */ - phase_old2: function () { + phase: function () { 'step 0'; //初始化阶段列表 if (!event.phaseList) { @@ -8249,6 +8249,9 @@ export default { }, player, player.isLinked()); game.addVideo('link', player, player.isLinked()); }, + /** + * @deprecated + */ chooseToGuanxing: function () { "step 0"; var cards = get.cards(num); diff --git a/noname/library/element/contents.js b/noname/library/element/contents.js index e89431ad2..8c9654907 100644 --- a/noname/library/element/contents.js +++ b/noname/library/element/contents.js @@ -244,5 +244,5 @@ export default { delete _status.currentPhase; }, player); } - ], + ] }; diff --git a/noname/library/index.js b/noname/library/index.js index e90493602..ba39dcaca 100644 --- a/noname/library/index.js +++ b/noname/library/index.js @@ -20496,7 +20496,7 @@ export class Library extends Uninstantable { let eventPromise = _status.event.next.find(e => e.toEvent() == event); // 如果父级事件也是一个异步的话,那应该立即执行这个事件的 // 如果在AsyncFunction执行过程中在别的位置新建了一个异步事件,那也直接(等会set配置完)执行 - if (eventPromise && _status.event.content instanceof AsyncFunction) { + if (eventPromise && (_status.event.content instanceof AsyncFunction || Array.isArray(_status.event.contents))) { // 异步执行game.loop // 不直接game.loop(event)是因为需要让别人可以手动set()和setContent() // 再执行game.loop是因为原有的game.loop被await卡住了,