mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-06 07:37:56 +02:00
tighten messages types wth enums
This commit is contained in:
+4
-21
@@ -1,31 +1,14 @@
|
||||
import { Reviver, Generic_toJSON, Generic_fromJSON } from "../utils/JSONReviver";
|
||||
import { MessageFilenames } from "./MessageHelpers";
|
||||
|
||||
export class Message {
|
||||
// Name of Message file
|
||||
filename = "";
|
||||
filename: MessageFilenames;
|
||||
|
||||
// The text contains in the Message
|
||||
msg = "";
|
||||
msg: string;
|
||||
|
||||
// Flag indicating whether this Message has been received by the player
|
||||
recvd = false;
|
||||
|
||||
constructor(filename = "", msg = "") {
|
||||
constructor(filename: MessageFilenames, msg: string) {
|
||||
this.filename = filename;
|
||||
this.msg = msg;
|
||||
this.recvd = false;
|
||||
}
|
||||
|
||||
// Serialize the current object to a JSON save state
|
||||
toJSON(): any {
|
||||
return Generic_toJSON("Message", this);
|
||||
}
|
||||
|
||||
// Initializes a Message Object from a JSON save state
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
static fromJSON(value: any): Message {
|
||||
return Generic_fromJSON(Message, value.data);
|
||||
}
|
||||
}
|
||||
|
||||
Reviver.constructors.Message = Message;
|
||||
|
||||
Reference in New Issue
Block a user