updateHp
This commit is contained in:
parent
6448d50837
commit
2ebcaee257
3
src/global.d.ts
vendored
3
src/global.d.ts
vendored
@ -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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新随从信息
|
* 更新随从信息
|
||||||
|
@ -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});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user