12345678910111213141516171819202122232425262728 |
- 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)
- {
- await DeletePreviousMessage(ChatId, update.CallbackQuery.Message.MessageId);
- var owner = await UserDao.GetPlayerById(UserId);
- var roomKey = RoomEncrypter.GetCode(owner.GetRoomName());
- var room = RoomController.GetRoom(roomKey);
- if(room == null)
- return await Bot.SendWithMarkdown2(ChatId, strings.room_does_not_exists);
- 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);
- room.Start();
- return result;
- }
- }
- }
|