private static LobbyInstance GetLobbyInstance(UserConnection userConnection) { var lobbyInstance = m_lobbyTables.FirstOrDefault(lt => lt.LobbyId == userConnection.GroupId); if (lobbyInstance == null) { lobbyInstance = new LobbyInstance(userConnection.GroupId, 250, 2); m_lobbyTables.Add(lobbyInstance); } return lobbyInstance; }
internal bool RemoveUserFromSeat(UserConnection userConnection, int tableIndex, int seatIndex) { // TODO: Validate the indexes var seat = Tables[tableIndex].Seats[seatIndex]; // Make sure it's the right user being removed if (seat.User != userConnection) return false; seat.User = null; seat.ThumbsUp = false; // Needs to be evented return true; }
internal bool AddUserToSeat(UserConnection userConnection, int tableIndex, int seatIndex) { // TODO: Validate the indexes var table = Tables[tableIndex]; // Make sure we don't sit on a table we're already present on. if (table.ContainsUser(userConnection)) return false; // Make sure we don't sit on top of someone! var seat = table.Seats[seatIndex]; if (seat.User != null) return false; seat.User = userConnection; return true; }
internal void RemoveUserFromAllSeats(UserConnection userConnection, Action<Removal> removal) { for (int tableIndex = 0; tableIndex < Tables.Count; tableIndex++) { var table = Tables[tableIndex]; for (int seatIndex = 0; seatIndex < table.Seats.Count; seatIndex++) { var seat = table.Seats[seatIndex]; if (seat.User != userConnection) continue; seat.User = null; seat.ThumbsUp = false; // This needs to be evented removal(new Removal(tableIndex, seatIndex)); } } }
internal bool ContainsUser(UserConnection userConnection) { return Seats.Any(s => s.User == userConnection); }