import type { MessagesServiceInterface } from "entities/messages/messages.service"; import { createLogger } from "lib/logger"; import { getRandomInt } from "lib/utils"; export class WaterMeService { waterLevel: number; private logger = createLogger("WaterMeService"); private thirsty = 3 as const; private enough = 10 as const; messagesService: MessagesServiceInterface; constructor(messagesService: MessagesServiceInterface) { this.waterLevel = 0; this.messagesService = messagesService; } getReply() { const thirstyReplies = [ "... wow das wars schon??? ich brauche noch mehr wasser :(", "dankeeeee!!!! ich waer fast verdurstet :(((", "*roelpssssss*", ]; const fullReplies = [ "langsam reicht es :o", "poah, das hat gut getan", "das ist krass :3", ]; const tooMuchReplies = [ "ES REICHT!!!!", "bitte hoer auf, ich platze gleich :(", ]; if (this.waterLevel <= this.thirsty) { return thirstyReplies[getRandomInt(0, thirstyReplies.length - 1)]; } if (this.waterLevel > this.thirsty && this.waterLevel <= this.enough) { return fullReplies[getRandomInt(0, fullReplies.length - 1)]; } if (this.waterLevel > this.enough) { return tooMuchReplies[getRandomInt(0, tooMuchReplies.length - 1)]; } } async notifyIfThirsty() { if (this.waterLevel <= this.thirsty) { await this.messagesService.sendToChannel( { id: "channelId" }, { content: "ich brauche wasser :(" }, ); } } waterMe() { const reply = this.getReply(); this.waterLevel++; this.logger.info(`Water level increased to ${this.waterLevel}`); return { reply, }; } }