mirror of
https://github.com/cloudmaker97/TikTok-mGBA-Emulator.git
synced 2025-12-06 07:58:38 +00:00
46 lines
No EOL
1.3 KiB
TypeScript
46 lines
No EOL
1.3 KiB
TypeScript
export class Message {
|
|
private messageId: string;
|
|
private createdAt: Date;
|
|
private content: string;
|
|
|
|
/**
|
|
* Create a new Message object
|
|
* @param data { messageId: string, content: string }
|
|
*/
|
|
constructor(data: { messageId: string, content: string }) {
|
|
this.messageId = data.messageId;
|
|
this.content = data.content;
|
|
this.createdAt = new Date();
|
|
}
|
|
|
|
/**
|
|
* Try to get the game key from the message content, otherwise return false
|
|
* @returns {string|boolean} Returns the game key for the GBA or false if it is not a valid game key
|
|
*/
|
|
public getMessageGameKey(): string|boolean {
|
|
switch(this.content.toLowerCase().trim()) {
|
|
case "start":
|
|
return "Start";
|
|
case "select":
|
|
return "Select";
|
|
case "a":
|
|
return "A";
|
|
case "b":
|
|
return "B";
|
|
case "r":
|
|
return "Right";
|
|
case "l":
|
|
return "Left";
|
|
case "u":
|
|
return "Up";
|
|
case "d":
|
|
return "Down";
|
|
case "rt":
|
|
return "R";
|
|
case "lt":
|
|
return "L";
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
} |