ShowProfileCommand.cs 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. using System;
  2. using System.Linq;
  3. using System.Threading.Tasks;
  4. using MafiaTelegramBot.DataBase.EntityDao;
  5. using MafiaTelegramBot.Resources;
  6. using Telegram.Bot.Types;
  7. namespace MafiaTelegramBot.Models.Commands
  8. {
  9. public class ShowProfileCommand : Command
  10. {
  11. protected override string Name => keyboard.show_profile;
  12. protected override async Task<Message> Execute(Update update)
  13. {
  14. var user = await UserDao.GetPlayerById(UserId);
  15. var rolesList = Enum.GetValues(typeof(Roles)).Cast<Roles>().ToList();
  16. rolesList.Remove(Roles.None);
  17. rolesList.Remove(Roles.All);
  18. var allStatsRow = user.Statistics[Roles.All];
  19. var message =
  20. $"__*{strings.statistics_for} _{user.NickName}_*__\n" +
  21. $"{strings.games_count} {allStatsRow.Games}\n" +
  22. $"{strings.wins_count} {allStatsRow.Wins}\n" +
  23. $"{strings.winrate} {(int)(allStatsRow.GetWinrate()*100)}%\n" +
  24. $"{strings.rate} {user.RankNumber}";
  25. return await Bot.SendWithMarkdown2(ChatId, message, Keyboard.ProfileKeyboard(UserId));
  26. }
  27. }
  28. }