diff --git a/src/global.d.ts b/src/global.d.ts index 43df37e..70c79db 100644 --- a/src/global.d.ts +++ b/src/global.d.ts @@ -204,8 +204,9 @@ declare module "colyseus" { * 更新玩家血量 * @param dstplayer * @param hp + * @param reason */ - updateHp(dstplayer: string, hp: number): number; + updateHp(dstplayer: string, hp: number, reason?: string): number; /** * 更新随从信息 diff --git a/src/rooms/RoomExtMethod.ts b/src/rooms/RoomExtMethod.ts index 3c0f262..404c8ed 100644 --- a/src/rooms/RoomExtMethod.ts +++ b/src/rooms/RoomExtMethod.ts @@ -103,7 +103,7 @@ Object.defineProperties(Room.prototype, { } }, updateHp: { - value: function (dstplayer: string, hp: number): number { + value: function (dstplayer: string, hp: number, reason?: string): number { let player = this.state.players.get(dstplayer); if (!player) { error(`updateHp 未找到玩家 ${dstplayer}`); @@ -113,7 +113,7 @@ Object.defineProperties(Room.prototype, { return 0; } else { let dstHp = player.hp + (hp | 0); - debugRoom(`更新血量: ${player.id} ${player.hp} -> ${hp}`); + debugRoom(`更新血量: ${player.id} ${player.hp} -> ${hp}, reason: ${reason}`); if (dstHp <= 0) { dstHp = 0; this.dispatcher.dispatch(new PlayDeadCommand(), {player: player});