mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-03 02:28:39 +00:00
Handle UpdatePlayersInRoom match requests
This commit is contained in:
parent
d3378460c2
commit
1c8e2ee007
1 changed files with 20 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Kettu;
|
using Kettu;
|
||||||
|
@ -114,6 +115,25 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
||||||
RoomHelper.CreateRoom(users, gameToken.GameVersion, createRoom.RoomSlot);
|
RoomHelper.CreateRoom(users, gameToken.GameVersion, createRoom.RoomSlot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (matchData is UpdatePlayersInRoom updatePlayersInRoom)
|
||||||
|
{
|
||||||
|
Room? room = RoomHelper.Rooms.FirstOrDefault(r => r.Host == user);
|
||||||
|
|
||||||
|
if (room != null)
|
||||||
|
{
|
||||||
|
List<User> users = new();
|
||||||
|
foreach (string playerUsername in updatePlayersInRoom.Players)
|
||||||
|
{
|
||||||
|
User? player = await this.database.Users.FirstOrDefaultAsync(u => u.Username == playerUsername);
|
||||||
|
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
|
||||||
|
if (player != null) users.Add(player);
|
||||||
|
else return this.BadRequest();
|
||||||
|
}
|
||||||
|
|
||||||
|
room.Players = users;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
return this.Ok("[{\"StatusCode\":200}]");
|
return this.Ok("[{\"StatusCode\":200}]");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue