From b3d157d1e68fbe7ffd6226dab6590d0873a4ab8b Mon Sep 17 00:00:00 2001 From: Oliver Akins Date: Sat, 12 Mar 2022 22:06:47 -0600 Subject: [PATCH] Add a method to get the JSON-compatible representation of the object --- server/src/objects/Player.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server/src/objects/Player.ts b/server/src/objects/Player.ts index 9e0a6da..c7eb752 100644 --- a/server/src/objects/Player.ts +++ b/server/src/objects/Player.ts @@ -28,4 +28,13 @@ export class Player { throw Error("Cannot overwrite a player's socket that is connected."); }; }; + + /** The properties of the Player object without any of the methods. */ + public json() { + return { + name: this.name, + ship: this.ship, + colour: this.colour, + }; + }; }; \ No newline at end of file