Skip to content

Commit

Permalink
fix: I broke gameovermsg
Browse files Browse the repository at this point in the history
  • Loading branch information
leia-uwu committed Mar 22, 2024
1 parent fd3409d commit cbbe793
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
14 changes: 2 additions & 12 deletions server/src/objects/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { type Msg } from "../../../shared/netTypings";
import { type Loot } from "./loot";
import { MapObjectDefs } from "../../../shared/defs/mapObjectDefs";
import { type ServerSocket } from "../abstractServer";
import { AliveCountsMsg, type DropItemMsg, GameOverMsg, InputMsg, JoinedMsg, KillMsg, MsgStream, MsgType, PlayerStatsMsg, UpdateMsg } from "../../../shared/net";
import { AliveCountsMsg, type DropItemMsg, GameOverMsg, InputMsg, JoinedMsg, KillMsg, MsgStream, MsgType, UpdateMsg } from "../../../shared/net";

export class Emote {
playerId: number;
Expand Down Expand Up @@ -759,17 +759,7 @@ export class Player extends BaseGameObject {
const gameOverMsg = new GameOverMsg();

gameOverMsg.teamRank = this.game.aliveCount;
const statsMsg = new PlayerStatsMsg();
statsMsg.playerId = this.id;
statsMsg.playerStats = {
playerId: this.id,
timeAlive: this.timeAlive,
kills: this.kills,
dead: this.dead,
damageDealt: this.damageDealt,
damageTaken: this.damageTaken
};
gameOverMsg.playerStats.push(statsMsg);
gameOverMsg.playerStats.push(this);
gameOverMsg.teamId = this.teamId;
gameOverMsg.winningTeamId = -1;
this.msgsToSend.push({ type: MsgType.GameOver, msg: gameOverMsg });
Expand Down
7 changes: 6 additions & 1 deletion shared/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -2092,6 +2092,9 @@ export class PlayerStatsMsg {
constructor() {
/** * @type {number} */
this.playerId = 0;
/**
* @type {{ timeAlive: number, kills: number, dead: boolean, damageDealt: number, damageTaken: number }}
*/
this.playerStats = {
playerId: 0,
timeAlive: 0,
Expand Down Expand Up @@ -2139,7 +2142,9 @@ export class GameOverMsg {
this.gameOver = false;
/** * @type {number} */
this.winningTeamId = 0;
/** * @type {PlayerStatsMsg[]} */
/**
* @type {PlayerStatsMsg["playerStats"][]}
*/
this.playerStats = [];
}

Expand Down

0 comments on commit cbbe793

Please sign in to comment.