给所有的_status.event.next.remove(GameEvent)添加GameEvent.resolve()

This commit is contained in:
Spmario233 2024-02-29 22:28:45 +08:00
parent 2c66172a56
commit e33c68c147
1 changed files with 36 additions and 8 deletions

View File

@ -728,7 +728,10 @@ export class Player extends HTMLDivElement {
virtualCard.init(['', '', card, info && info.cardnature]); virtualCard.init(['', '', card, info && info.cardnature]);
} }
else if (get.itemtype(card) == 'card') executeDelayCardEffect.card = card; else if (get.itemtype(card) == 'card') executeDelayCardEffect.card = card;
else _status.event.next.remove(executeDelayCardEffect); else {
_status.event.next.remove(executeDelayCardEffect);
executeDelayCardEffect.resolve();
}
executeDelayCardEffect.judge = judge; executeDelayCardEffect.judge = judge;
executeDelayCardEffect.judge2 = judge2; executeDelayCardEffect.judge2 = judge2;
executeDelayCardEffect.setContent('executeDelayCardEffect'); executeDelayCardEffect.setContent('executeDelayCardEffect');
@ -759,7 +762,10 @@ export class Player extends HTMLDivElement {
const isArray = Array.isArray(cards); const isArray = Array.isArray(cards);
if (cards && !isArray) gift.cards = [cards]; if (cards && !isArray) gift.cards = [cards];
else if (isArray && cards.length) gift.cards = cards; else if (isArray && cards.length) gift.cards = cards;
else _status.event.next.remove(gift); else {
_status.event.next.remove(gift);
gift.resolve();
}
gift.deniedGifts = []; gift.deniedGifts = [];
gift.setContent('gift'); gift.setContent('gift');
gift._args = Array.from(arguments); gift._args = Array.from(arguments);
@ -825,7 +831,10 @@ export class Player extends HTMLDivElement {
const isArray = Array.isArray(cards); const isArray = Array.isArray(cards);
if (cards && !isArray) recast.cards = [cards]; if (cards && !isArray) recast.cards = [cards];
else if (isArray && cards.length) recast.cards = cards; else if (isArray && cards.length) recast.cards = cards;
else _status.event.next.remove(recast); else {
_status.event.next.remove(recast);
recast.resolve();
}
if (typeof recastingLose != 'function') { if (typeof recastingLose != 'function') {
if (recastingLose === null) console.trace(`recast的recastingLose参数不应传入null,可以用void 0或undefined占位`); if (recastingLose === null) console.trace(`recast的recastingLose参数不应传入null,可以用void 0或undefined占位`);
recastingLose = (player, cards) => player.loseToDiscardpile(cards).log = false; recastingLose = (player, cards) => player.loseToDiscardpile(cards).log = false;
@ -1073,6 +1082,7 @@ export class Player extends HTMLDivElement {
if (!next.source) next.source = _status.event.player; if (!next.source) next.source = _status.event.player;
if (!next.slots.length) { if (!next.slots.length) {
_status.event.next.remove(next); _status.event.next.remove(next);
next.resolve();
} }
next.setContent('disableEquip'); next.setContent('disableEquip');
return next; return next;
@ -1110,6 +1120,7 @@ export class Player extends HTMLDivElement {
if (!next.source) next.source = _status.event.player; if (!next.source) next.source = _status.event.player;
if (!next.slots.length) { if (!next.slots.length) {
_status.event.next.remove(next); _status.event.next.remove(next);
next.resolve();
} }
next.setContent('enableEquip'); next.setContent('enableEquip');
return next; return next;
@ -1147,6 +1158,7 @@ export class Player extends HTMLDivElement {
if (!next.source) next.source = _status.event.player; if (!next.source) next.source = _status.event.player;
if (!next.slots.length) { if (!next.slots.length) {
_status.event.next.remove(next); _status.event.next.remove(next);
next.resolve();
} }
next.setContent('expandEquip'); next.setContent('expandEquip');
return next; return next;
@ -4766,7 +4778,10 @@ export class Player extends HTMLDivElement {
} }
if (get.itemtype(cards) == 'card') next.cards = [cards]; if (get.itemtype(cards) == 'card') next.cards = [cards];
else if (get.itemtype(cards) == 'cards') next.cards = cards.slice(0); else if (get.itemtype(cards) == 'cards') next.cards = cards.slice(0);
else _status.event.next.remove(next); else {
_status.event.next.remove(next);
next.resolve();
}
next.setContent('showCards'); next.setContent('showCards');
next._args = Array.from(arguments); next._args = Array.from(arguments);
return next; return next;
@ -5123,7 +5138,10 @@ export class Player extends HTMLDivElement {
} }
} }
if (next.num == undefined) next.num = 1; if (next.num == undefined) next.num = 1;
if (next.num <= 0) _status.event.next.remove(next); if (next.num <= 0) {
_status.event.next.remove(next);
next.resolve();
}
next.setContent('draw'); next.setContent('draw');
if (lib.config.mode == 'stone' && _status.mode == 'deck' && if (lib.config.mode == 'stone' && _status.mode == 'deck' &&
next.drawDeck == undefined && !next.player.isMin() && next.num > 1) { next.drawDeck == undefined && !next.player.isMin() && next.num > 1) {
@ -5207,7 +5225,10 @@ export class Player extends HTMLDivElement {
next.notBySelf = true; next.notBySelf = true;
} }
} }
if (next.cards == undefined) _status.event.next.remove(next); if (next.cards == undefined) {
_status.event.next.remove(next);
next.resolve();
}
next.setContent('discard'); next.setContent('discard');
return next; return next;
} }
@ -5241,7 +5262,10 @@ export class Player extends HTMLDivElement {
next.blank = true; next.blank = true;
} }
} }
if (next.cards == undefined) _status.event.next.remove(next); if (next.cards == undefined) {
_status.event.next.remove(next);
next.resolve();
}
next.setContent('loseToDiscardpile'); next.setContent('loseToDiscardpile');
return next; return next;
} }
@ -5621,6 +5645,7 @@ export class Player extends HTMLDivElement {
} }
if (!next.cards || !next.cards.length) { if (!next.cards || !next.cards.length) {
_status.event.next.remove(next); _status.event.next.remove(next);
next.resolve();
} }
else { else {
if (next.position == undefined) next.position = ui.discardPile; if (next.position == undefined) next.position = ui.discardPile;
@ -5738,7 +5763,10 @@ export class Player extends HTMLDivElement {
if (next.cards == undefined && !nocard) next.cards = event.cards; if (next.cards == undefined && !nocard) next.cards = event.cards;
if (next.source == undefined && !nosource) next.source = event.customSource || event.player; if (next.source == undefined && !nosource) next.source = event.customSource || event.player;
if (next.num == undefined) next.num = (event.baseDamage || 1) + (event.extraDamage || 0); if (next.num == undefined) next.num = (event.baseDamage || 1) + (event.extraDamage || 0);
if (next.num <= 0) _status.event.next.remove(next); if (next.num <= 0) {
_status.event.next.remove(next);
next.resolve();
}
next.setContent('recover'); next.setContent('recover');
return next; return next;
} }