This commit is contained in:
zhl 2020-12-25 16:02:27 +08:00
parent 6448d50837
commit 2ebcaee257
2 changed files with 4 additions and 3 deletions

3
src/global.d.ts vendored
View File

@ -204,8 +204,9 @@ declare module "colyseus" {
* *
* @param dstplayer * @param dstplayer
* @param hp * @param hp
* @param reason
*/ */
updateHp(dstplayer: string, hp: number): number; updateHp(dstplayer: string, hp: number, reason?: string): number;
/** /**
* *

View File

@ -103,7 +103,7 @@ Object.defineProperties(Room.prototype, {
} }
}, },
updateHp: { updateHp: {
value: function (dstplayer: string, hp: number): number { value: function (dstplayer: string, hp: number, reason?: string): number {
let player = this.state.players.get(dstplayer); let player = this.state.players.get(dstplayer);
if (!player) { if (!player) {
error(`updateHp 未找到玩家 ${dstplayer}`); error(`updateHp 未找到玩家 ${dstplayer}`);
@ -113,7 +113,7 @@ Object.defineProperties(Room.prototype, {
return 0; return 0;
} else { } else {
let dstHp = player.hp + (hp | 0); let dstHp = player.hp + (hp | 0);
debugRoom(`更新血量: ${player.id} ${player.hp} -> ${hp}`); debugRoom(`更新血量: ${player.id} ${player.hp} -> ${hp}, reason: ${reason}`);
if (dstHp <= 0) { if (dstHp <= 0) {
dstHp = 0; dstHp = 0;
this.dispatcher.dispatch(new PlayDeadCommand(), {player: player}); this.dispatcher.dispatch(new PlayDeadCommand(), {player: player});