diff --git a/noname/game/index.js b/noname/game/index.js index a48005ab8..46bb51611 100644 --- a/noname/game/index.js +++ b/noname/game/index.js @@ -5429,11 +5429,14 @@ export class Game extends Uninstantable { * 但是需要事件结果的除外 */ static executingAsyncEventMap = new Map(); + /** + * @type { GameEventPromise[] } + */ + static belongAsyncEventList = []; /** * @param { GameEventPromise } [belongAsyncEvent] */ static async loop(belongAsyncEvent) { - if (!game.belongAsyncEventList) game.belongAsyncEventList = []; if (belongAsyncEvent) { game.belongAsyncEventList.push(belongAsyncEvent); } else if (game.belongAsyncEventList.length) { @@ -5639,10 +5642,21 @@ export class Game extends Uninstantable { run(event).then(() => { // 其实这个if几乎一定执行了 if (game.executingAsyncEventMap.has(event.toEvent())) { - game.executingAsyncEventMap.set(_status.event.toEvent(), game.executingAsyncEventMap.get(_status.event.toEvent()).then(() => { - event.finish(); - resolve(); - })); + if (!game.executingAsyncEventMap.get(_status.event.toEvent())) { + console.warn(`game.executingAsyncEventMap中包括了event,但不包括_status.event!`); + console.log('event :>> ', event.toEvent()); + console.log('_status.event :>> ', _status.event.toEvent()); + // debugger; + game.executingAsyncEventMap.set(event.toEvent(), game.executingAsyncEventMap.get(event.toEvent()).then(() => { + event.finish(); + resolve(); + })); + } else { + game.executingAsyncEventMap.set(_status.event.toEvent(), game.executingAsyncEventMap.get(_status.event.toEvent()).then(() => { + event.finish(); + resolve(); + })); + } } else { event.finish(); resolve(); diff --git a/noname/game/promises.js b/noname/game/promises.js index c5f6d6988..4563fd8d3 100644 --- a/noname/game/promises.js +++ b/noname/game/promises.js @@ -13,7 +13,7 @@ export class GamePromises extends Uninstantable { * (alertOption: 'alert', title: string): Promise; * }} * - * @param { string } title 设置prompt标题与input内容 + * @param { string } [title] 设置prompt标题与input内容 * @param { boolean } [forced] 为true的话将没有"取消按钮" * @param { string } alertOption 设置prompt是否模拟alert * @example diff --git a/noname/library/element/gameEvent.js b/noname/library/element/gameEvent.js index 5817376c4..b46b7d9ea 100644 --- a/noname/library/element/gameEvent.js +++ b/noname/library/element/gameEvent.js @@ -65,6 +65,111 @@ export class GameEvent { static initialGameEvent() { return new GameEvent().finish().toPromise(); } + /** + * @type { Player } + */ + // @ts-ignore + source; + /** + * @type { Player } + */ + // @ts-ignore + player; + /** + * @type { Player } + */ + // @ts-ignore + target; + /** + * @type { Player[] } + */ + // @ts-ignore + targets; + /** + * @type { Card } + */ + // @ts-ignore + card; + /** + * @type { Card[] } + */ + // @ts-ignore + cards; + /** + * @type { string } + */ + skill; + /** + * @type { boolean } + */ + forced; + /** + * @type { number } + */ + num; + /** + * @type { GameEvent } + */ + // @ts-ignore + _trigger; + /** + * @type { Result } + */ + _result; + /** + * @type { number } + */ + // @ts-ignore + baseDamage; + /** + * @type { Player } + */ + // @ts-ignore + customSource; + /** + * @type { number } + */ + // @ts-ignore + extraDamage; + /** + * @type { string } + */ + // @ts-ignore + nature; + /** + * @type { boolean } + */ + // @ts-ignore + notrigger; + /** + * @type { number } + */ + // @ts-ignore + original_num; + /** + * @type { boolean } + */ + // @ts-ignore + unreal; + /** + * @type { Button[] } + */ + // @ts-ignore + excludeButton; + /** + * @type { Result } + */ + // @ts-ignore + result; + /** + * @type { GameEventPromise | void | null } + */ + // @ts-ignore + parent; + /** + * @type { string } + */ + name; /** * @param {keyof this} key * @param {number} [value] @@ -761,106 +866,4 @@ export class GameEvent { } return this.#promise; } - /** - * @returns {never} - */ - typeAnnotation() { - /** - * @type { Player } - */ - // @ts-ignore - this.source; - /** - * @type { Player } - */ - // @ts-ignore - this.player; - /** - * @type { Player } - */ - // @ts-ignore - this.target; - /** - * @type { Player[] } - */ - // @ts-ignore - this.targets; - /** - * @type { Card } - */ - // @ts-ignore - this.card; - /** - * @type { Card[] } - */ - // @ts-ignore - this.cards; - /** - * @type { string } - */ - this.skill; - /** - * @type { boolean } - */ - this.forced; - /** - * @type { number } - */ - this.num; - /** - * @type { GameEvent } - */ - // @ts-ignore - this._trigger; - /** - * @type { Record } - */ - this._result; - /** - * @type { number } - */ - // @ts-ignore - this.baseDamage; - /** - * @type { Player } - */ - // @ts-ignore - this.customSource; - /** - * @type { number } - */ - // @ts-ignore - this.extraDamage; - /** - * @type { string } - */ - // @ts-ignore - this.nature; - /** - * @type { boolean } - */ - // @ts-ignore - this.notrigger; - /** - * @type { number } - */ - // @ts-ignore - this.original_num; - /** - * @type { boolean } - */ - // @ts-ignore - this.unreal; - /** - * @type { Button[] } - */ - // @ts-ignore - this.excludeButton; - /** - * @type { Result } - */ - // @ts-ignore - this.result; - throw new Error('Do not call this method'); - } } diff --git a/noname/library/element/gameEventPromise.js b/noname/library/element/gameEventPromise.js index c3488f966..7aeecc31d 100644 --- a/noname/library/element/gameEventPromise.js +++ b/noname/library/element/gameEventPromise.js @@ -70,6 +70,7 @@ export class GameEventPromise extends Promise { if (lib.phaseName.includes(event.name)) event.player.getHistory('skipped').add(event.name); _status.event.next.remove(eventPromise); event.finish(); + // @ts-ignore resolve(); return eventPromise; }