revert: umm...

This commit is contained in:
Rintim 2023-12-23 21:07:35 +08:00
parent f047963cc7
commit facfe0ee0d
No known key found for this signature in database
GPG Key ID: BE9E1EA615BACFCF
2 changed files with 20 additions and 17 deletions

View File

@ -6662,7 +6662,8 @@ export default {
"step 5";
ui.clear();
},
draw: function () {
draw: async (event, _trigger, player) => {
const { num } = event;
// if(lib.config.background_audio){
// game.playAudio('effect','draw');
// }
@ -6689,7 +6690,7 @@ export default {
game.log(player, '从牌库中获得了' + get.cnNumber(event.drawDeck) + '张牌');
}
}
var cards;
let cards;
if (num > 0) {
if (event.bottom) cards = get.bottomCards(num);
else if (player.getTopCards) cards = player.getTopCards(num);
@ -6701,24 +6702,26 @@ export default {
if (event.drawDeck) {
cards = cards.concat(player.getDeckCards(event.drawDeck));
}
let next;
if (event.animate != false) {
if (event.visible) {
var next = player.gain(cards, 'gain2');
next = player.gain(cards, 'gain2');
if (event.bottom) game.log(player, '从牌堆底摸了' + get.cnNumber(num) + '张牌(', cards, '');
else game.log(player, '摸了' + get.cnNumber(num) + '张牌(', cards, '');
}
else {
var next = player.gain(cards, 'draw');
next = player.gain(cards, 'draw');
}
}
else {
var next = player.gain(cards);
next = player.gain(cards);
if (event.$draw) {
player.$draw(cards.length);
}
}
if (event.gaintag) next.gaintag.addArray(event.gaintag);
event.result = cards;
await next;
},
discard: function () {
"step 0";

View File

@ -19900,7 +19900,7 @@ export class Library extends Uninstantable {
break;
default:
try {
if (!lib.element.content[item]._parsed) {
if (!(lib.element.content[item] instanceof AsyncFunction) && !lib.element.content[item]._parsed) {
lib.element.content[item] = lib.init.parsex(lib.element.content[item]);
lib.element.content[item]._parsed = true;
}
@ -20492,6 +20492,17 @@ export class Library extends Uninstantable {
if (!_status.event) return;
// game.createEvent的时候还没立即push到next里
Promise.resolve().then(() => {
/*
// 事件自行处理skip情况
if (event.player && event.player.skipList.includes(event.name)) {
_status.event.trigger(event.name + 'Skipped');
event.player.skipList.remove(event.name);
if (lib.phaseName.includes(event.name)) event.player.getHistory('skipped').add(event.name);
const eventPromise = _status.event.next.find(e => e.toEvent() == event);
if (eventPromise) _status.event.next.remove(eventPromise);
return;
}
*/
game.executingAsyncEventMap.set(_status.event.toEvent(), (game.executingAsyncEventMap.get(_status.event.toEvent()) || Promise.resolve()).then(() => {
let eventPromise = _status.event.next.find(e => e.toEvent() == event);
// 如果父级事件也是一个异步的话,那应该立即执行这个事件的
@ -20502,17 +20513,6 @@ export class Library extends Uninstantable {
// 再执行game.loop是因为原有的game.loop被await卡住了
// 得新执行一个只执行这个异步事件的game.loop
// 事件自行处理skip情况
if (event.player && event.player.skipList.contains(event.name)) {
_status.event.trigger(event.name + 'Skipped');
event.player.skipList.remove(event.name);
if (lib.phaseName.contains(event.name)) event.player.getHistory('skipped').add(event.name);
_status.event.next.remove(eventPromise);
event.finish();
resolve();
return eventPromise;
}
if (_status.event != eventPromise) {
eventPromise.parent = _status.event;
_status.event = eventPromise;