From f3bb86c5c4b2b9d27eafc668f882a854f86f6272 Mon Sep 17 00:00:00 2001 From: Spmario233 Date: Tue, 26 Mar 2024 17:13:12 +0800 Subject: [PATCH 1/4] =?UTF-8?q?recover=E4=BA=8B=E4=BB=B6=E5=92=8CloseHp?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E5=A2=9E=E5=8A=A0=E6=A3=80=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noname/library/element/content.js | 26 +++++++++++++++++--------- noname/library/element/player.js | 16 +++++++++++++--- noname/library/index.js | 7 +++++-- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/noname/library/element/content.js b/noname/library/element/content.js index 4059b1d29..37626d11e 100644 --- a/noname/library/element/content.js +++ b/noname/library/element/content.js @@ -7922,20 +7922,20 @@ export const Content = { if (!event.notrigger) event.trigger('damageSource'); }, recover: function () { - if (lib.config.background_audio) { - game.playAudio('effect', 'recover'); - } - game.broadcast(function () { - if (lib.config.background_audio) { - game.playAudio('effect', 'recover'); - } - }); if (num > player.maxHp - player.hp) { num = player.maxHp - player.hp; event.num = num; } if (num > 0) { - player.changeHp(num, false); + delete event.filterStop(); + if (lib.config.background_audio) { + game.playAudio('effect', 'recover'); + } + game.broadcast(function () { + if (lib.config.background_audio) { + game.playAudio('effect', 'recover'); + } + }); game.broadcastAll(function (player) { if (lib.config.animation && !lib.config.low_performance) { player.$recover(); @@ -7943,10 +7943,18 @@ export const Content = { }, player); player.$damagepop(num, 'wood'); game.log(player, '回复了' + get.cnNumber(num) + '点体力'); + + player.changeHp(num, false); } + else event._triggered = null; }, loseHp: function () { "step 0"; + if (event.num <= 0){ + event.finish(); + event._triggered = null; + return; + } if (lib.config.background_audio) { game.playAudio('effect', 'loseHp'); } diff --git a/noname/library/element/player.js b/noname/library/element/player.js index 4360c7b20..3782c9fec 100644 --- a/noname/library/element/player.js +++ b/noname/library/element/player.js @@ -5929,9 +5929,11 @@ export class Player extends HTMLDivElement { if (next.cards == undefined && !nocard) next.cards = event.cards; 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 <= 0) { - _status.event.next.remove(next); - next.resolve(); + next.filterStop = function(){ + if (this.num <= 0 || this.player.isHealthy()){ + delete this.filterStop; + return true; + } } next.setContent('recover'); return next; @@ -5949,6 +5951,14 @@ export class Player extends HTMLDivElement { next.player = this; if (next.num == undefined) next.num = 1; next.setContent('loseHp'); + next.filterStop = function(){ + if (this.num <= 0){ + delete this.filterStop; + this.finish(); + this._triggered = null; + return true; + } + } return next; } loseMaxHp() { diff --git a/noname/library/index.js b/noname/library/index.js index 69bbfa30f..6e130d7bd 100644 --- a/noname/library/index.js +++ b/noname/library/index.js @@ -11303,7 +11303,10 @@ export class Library extends Uninstantable { } } }, - _recovercheck: { + /** + * @deprecated + */ + /*_recovercheck: { trigger: { player: 'recoverBefore' }, forced: true, priority: 100, @@ -11316,7 +11319,7 @@ export class Library extends Uninstantable { content: function () { trigger.cancel(); }, - }, + },*/ /** * @deprecated */ From 7044ba0a37f68512a69acd1d9e07d22acdb9fb7a Mon Sep 17 00:00:00 2001 From: Spmario233 Date: Tue, 26 Mar 2024 17:19:51 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0recover=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E7=9A=84=E4=B8=80=E4=B8=AAfinish?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noname/library/element/player.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/noname/library/element/player.js b/noname/library/element/player.js index 3782c9fec..91f3d5ae3 100644 --- a/noname/library/element/player.js +++ b/noname/library/element/player.js @@ -5932,6 +5932,8 @@ export class Player extends HTMLDivElement { next.filterStop = function(){ if (this.num <= 0 || this.player.isHealthy()){ delete this.filterStop; + this.finish(); + this._triggered = null; return true; } } From c072280a054be71e9f8bccaed9f8bbb7fc2f1800 Mon Sep 17 00:00:00 2001 From: Spmario233 Date: Tue, 26 Mar 2024 17:24:45 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=89=A9=E5=A4=A7filterStop=E7=9A=84?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noname/library/element/gameEvent.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/noname/library/element/gameEvent.js b/noname/library/element/gameEvent.js index e4d77f1af..9fbd5bfa6 100644 --- a/noname/library/element/gameEvent.js +++ b/noname/library/element/gameEvent.js @@ -170,6 +170,10 @@ export class GameEvent { * @type { string } */ name; + /** + * @type { Function | void | null } + */ + filterStop; /** * @param {keyof this} key * @param {number} [value] @@ -760,6 +764,7 @@ export class GameEvent { if (!lib.hookmap[name] && !lib.config.compatiblemode) return; if (!game.players || !game.players.length) return; const event = this; + if (event.filterStop && event.filterStop()) return; let start = [_status.currentPhase, event.source, event.player, game.me, game.players[0]].find(i => get.itemtype(i) == 'player'); if (!start) return; if (!game.players.includes(start) && !game.dead.includes(start)) start = game.findNext(start); From fd1bb04ac4fcd3a0d6e2acf0739fa4238051d119 Mon Sep 17 00:00:00 2001 From: Spmario233 Date: Tue, 26 Mar 2024 17:26:52 +0800 Subject: [PATCH 4/4] bugfix --- noname/library/element/content.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noname/library/element/content.js b/noname/library/element/content.js index 37626d11e..b80ed762a 100644 --- a/noname/library/element/content.js +++ b/noname/library/element/content.js @@ -7927,7 +7927,7 @@ export const Content = { event.num = num; } if (num > 0) { - delete event.filterStop(); + delete event.filterStop; if (lib.config.background_audio) { game.playAudio('effect', 'recover'); }