Merge pull request #1135 from libccy/changeHp-related-dev
recover事件和loseHp事件增加检验
This commit is contained in:
commit
4862d143f4
|
@ -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');
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue