Skip to content

Commit

Permalink
Improved how percentage is shown
Browse files Browse the repository at this point in the history
  • Loading branch information
LuisMayo committed Oct 1, 2020
1 parent 878c294 commit c647122
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/games/pressTheButton/press-the-button.bean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down

0 comments on commit c647122

Please sign in to comment.