Selaa lähdekoodia

Fix connected user room name

Tigran 4 vuotta sitten
vanhempi
commit
43b56c5408

+ 1 - 1
MafiaTelegramBot/Controllers/RoomController.cs

@@ -33,7 +33,7 @@ namespace MafiaTelegramBot.Controllers
             return await Task.Run(async () =>
             {
                 if (OpenedGames[roomKey].IsFilled()) return Constants.ROOM_IS_FILLED;
-                if (! await player.SetCurrentGame(roomKey)) return Constants.USER_ALREADY_IN_GAME;
+                if (! await player.SetCurrentGame(OpenedGames[roomKey].RoomName)) return Constants.USER_ALREADY_IN_GAME;
                 OpenedGames[roomKey].Players.Add(player.Username, player);
                 return Constants.CODE_OK;
             });

+ 2 - 2
MafiaTelegramBot/Models/Commands/ConnectGameCommand.cs

@@ -4,7 +4,6 @@ using Telegram.Bot.Types;
 using Telegram.Bot.Types.Enums;
 using Telegram.Bot.Types.ReplyMarkups;
 
-
 namespace MafiaTelegramBot.Models.Commands
 {
     public class ConnectGameCommand : Command
@@ -18,7 +17,8 @@ namespace MafiaTelegramBot.Models.Commands
             var userId = update.Message.From.Id;
             
             var user = await UserDao.GetUserById(userId);
-            
+            if (user?.GetCurrentGame() != "")
+                return await Bot.SendWithMarkdown2(chatId, $"{strings.user_already_playing} _*{user?.GetCurrentGame()}*_");
             var inlineKeyboard = new InlineKeyboardMarkup(new[]
             {
                 new[] {InlineKeyboardButton.WithCallbackData(strings.connect_to_public_room, $"{strings.connect_to_public_room_callback}|{userId}")},