From c64712215b9bf005227c1f28631f3371c48da77d Mon Sep 17 00:00:00 2001 From: Luis Mayo Valbuena Date: Thu, 1 Oct 2020 21:15:09 +0000 Subject: [PATCH] Improved how percentage is shown --- src/games/pressTheButton/press-the-button.bean.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/games/pressTheButton/press-the-button.bean.ts b/src/games/pressTheButton/press-the-button.bean.ts index a8217ac..c5533db 100644 --- a/src/games/pressTheButton/press-the-button.bean.ts +++ b/src/games/pressTheButton/press-the-button.bean.ts @@ -6,18 +6,16 @@ import { HTMLEncoder } from "./html-decoder"; export class PressTheButtonBean implements GameObject { private yesPercentage: number; - private noPercentage: number; constructor(public bean: Dilemma) { bean.txt1 = HTMLEncoder.htmlDecode(bean.txt1.trim()); bean.txt2 = HTMLEncoder.htmlDecode(bean.txt2.trim()); this.yesPercentage = Math.round(bean.yes * 100 / (bean.yes + bean.no)); - this.noPercentage = Math.round(bean.no * 100 / (bean.yes + bean.no)); } sendMessage(ctx: Context): void { const keyboardHelper = PressTheButtonService.instance.createNeverKeyboard(); - ctx.reply(`${this.bean.confirmed === 1 ? '' : '⚠'} Would you press the button if\n\n(${this.yesPercentage}%) ${this.bean.txt1}\n\nbut\n\n(${this.noPercentage}%) ${this.bean.txt2}\n=====\n`, + ctx.reply(`${this.bean.confirmed === 1 ? '' : '⚠'} Would you press the button if\n\n${this.bean.txt1}\n\nbut\n\n${this.bean.txt2}\n=====\n${this.yesPercentage}% of users would press the button\n=====\n`, { reply_markup: { inline_keyboard: keyboardHelper.buttons } }).then(message => { PressTheButtonService.instance.saveNewMessage(ctx.chat.id.toString(), message); });