Merge pull request #1135 from libccy/changeHp-related-dev

recover事件和loseHp事件增加检验
This commit is contained in:
Spmario233 2024-03-27 17:32:23 +08:00 committed by GitHub
commit 4862d143f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 42 additions and 14 deletions

View File

@ -7922,6 +7922,12 @@ export const Content = {
if (!event.notrigger) event.trigger('damageSource');
},
recover: function () {
if (num > player.maxHp - player.hp) {
num = player.maxHp - player.hp;
event.num = num;
}
if (num > 0) {
delete event.filterStop;
if (lib.config.background_audio) {
game.playAudio('effect', 'recover');
}
@ -7930,12 +7936,6 @@ export const Content = {
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);
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');
}

View File

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

View File

@ -5929,9 +5929,13 @@ 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;
this.finish();
this._triggered = null;
return true;
}
}
next.setContent('recover');
return next;
@ -5949,6 +5953,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() {

View File

@ -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
*/