为runContent增加一处保底

This commit is contained in:
nonameShijian 2024-02-05 23:51:02 +08:00
parent 9b7ce5bc1c
commit 2d60f27e2b
4 changed files with 126 additions and 108 deletions

View File

@ -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();

View File

@ -13,7 +13,7 @@ export class GamePromises extends Uninstantable {
* (alertOption: 'alert', title: string): Promise<true>;
* }}
*
* @param { string } title 设置prompt标题与input内容
* @param { string } [title] 设置prompt标题与input内容
* @param { boolean } [forced] 为true的话将没有"取消按钮"
* @param { string } alertOption 设置prompt是否模拟alert
* @example

View File

@ -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<string, any> }
*/
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');
}
}

View File

@ -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;
}