123456789101112131415161718192021222324252627282930 |
- using System.Threading.Tasks;
- using MafiaTelegramBot.Controllers;
- using MafiaTelegramBot.DataBase.EntityDao;
- using MafiaTelegramBot.Game;
- using MafiaTelegramBot.Game.GameRooms;
- using MafiaTelegramBot.Resources;
- using Telegram.Bot.Types;
- namespace MafiaTelegramBot.Models.Inlines
- {
- public class ChangeRolesQuery : Query
- {
- protected override Callback Name => Callback.ChangeRoles;
- protected override async Task<Message> Execute(Update update)
- {
- var user = await UserDao.GetPlayerById(UserId);
- var roomKey = RoomEncrypter.GetCode(user.GetRoomName());
- var room = (ExtendedGameRoom) RoomController.GetRoom(roomKey);
- if(room.CustomRoomSettings.Count == 0) await room.InitSettings();
- var message = $"{strings.current_enabled_roles}";
- foreach (var (role, count) in room.CustomRoomSettings)
- {
- if (role is Roles.Mafia) message += $"\n| {roles.Mafia} \\({count}\\) |";
- if (role is Roles.Villager) message += $"\n| {roles.Villager} \\({count}\\) |";
- else message += $"\n| {roles.ResourceManager.GetString(role.ToString())} \\({count}\\) |";
- }
- return await Bot.SendWithMarkdown2(ChatId, message, Keyboard.ChangeRolesKeyboard(UserId, roomKey, room));
- }
- }
- }
|