update hp时判断玩家是否存在

This commit is contained in:
zhl 2020-12-15 13:32:22 +08:00
parent 7ba01534ad
commit ede87e9eb7

View File

@ -106,7 +106,10 @@ Object.defineProperties(Room.prototype, {
updateHp: {
value: function (dstplayer: string, hp: number): number {
let player = this.state.players.get(dstplayer);
if (!player) error("updateHp 未找到玩家")
if (!player) {
error(`updateHp 未找到玩家 ${dstplayer}`);
return 0;
}
if (player.state === PlayerStateConst.PLAYER_DEAD) {
return 0;
} else {