1234567891011121314151617181920212223242526 |
- using System.Threading.Tasks;
- using MafiaTelegramBot.Controllers;
- using MafiaTelegramBot.DataBase.EntityDao;
- using MafiaTelegramBot.Game;
- using MafiaTelegramBot.Resources;
- using Telegram.Bot.Types;
- namespace MafiaTelegramBot.Models.Inlines
- {
- public class StartGameQuery : Query
- {
- protected override Callback Name => Callback.StartGame;
- protected override async Task<Message> Execute(Update update)
- {
- var owner = await UserDao.GetPlayerById(UserId);
- var roomKey = RoomEncrypter.GetCode(owner.GetRoomName());
- var room = RoomController.GetRoom(roomKey);
- var result = await Bot.SendWithMarkdown2(owner.ChatId, strings.game_process_started);
- var resultCode = await room.Prepare();
- if (resultCode != ResultCode.CodeOk) return await Utilities.GetResultCodeMessage(resultCode, ChatId);
- await room.SendRolesToUsers();
- room.Start();
- return result;
- }
- }
- }
|