internal void AddMatch(MatchListing listing)
 {
     if (listing.JoinLobby(this.Session))
     {
         this._Matches.Add(listing);
     }
 }
Exemple #2
0
    public void Handle(ClientSession session, JsonPacket message)
    {
        MatchListing matchListing = this.matchListingManager.GetLeveOfTheDay();

        if (matchListing != null)
        {
            session.SendPacket(new ReceiveLevelOfTheDayOutgoingMessage(matchListing));
            session.LobbySession.AddMatch(matchListing);
        }
    }
    internal MultiplayerMatch CreateMultiplayerMatch(MatchListing matchListing)
    {
        MultiplayerMatch match = new(this, this.commandManager, this.loggerFactory.CreateLogger <MultiplayerMatch>(), matchListing.Type, matchListing.Type.GetMatchId(this.GetNextMatchId()), matchListing.LevelData);

        if (this.MultiplayerMatches.TryAdd(match.Name, match))
        {
            return(match);
        }

        return(null);
    }
Exemple #4
0
        internal MultiplayerMatch CreateMultiplayerMatch(MatchListing matchListing)
        {
            MultiplayerMatch match = new(matchListing.Type, matchListing.Type.GetMatchId(this.GetNextMatchId()), matchListing.LevelData);

            if (this.MultiplayerMatches.TryAdd(match.Name, match))
            {
                return(match);
            }

            return(null);
        }
        internal override void Handle(ClientSession session, JsonCreateMatchIncomingMessage message)
        {
            if (!session.IsLoggedIn)
            {
                return;
            }

            MatchListing listing = PlatformRacing3Server.MatchListingManager.TryCreateMatchAsync(session, message.LevelId, message.Version, message.MinRank, message.MaxRank, message.MaxMembers, message.OnlyFriends).Result;

            if (listing == null)
            {
                session.SendPacket(new MatchFailedOutgoingMessage());
            }
        }
        internal JsonQuickJoinSuccessOutgoingMessage(MatchListing matchListing)
        {
            this.Name = matchListing.Name;

            this.LevelId      = matchListing.LevelId;
            this.LevelTitle   = matchListing.LevelTitle;
            this.LevelVersion = matchListing.LevelVersion;

            this.CreatorId   = matchListing.CreatorId;
            this.CreatorName = matchListing.CreatorName;

            string mode = matchListing.LevelMod.ToString();

            this.LevelMod = Char.ToLowerInvariant(mode[0]) + mode[1..];
Exemple #7
0
    internal JsonMatchCreatedOutgoingMessage(MatchListing matchListing)
    {
        this.Name = matchListing.Name;

        this.LevelId      = matchListing.LevelId;
        this.LevelTitle   = matchListing.LevelTitle;
        this.LevelVersion = matchListing.LevelVersion;

        this.CreatorId        = matchListing.CreatorId;
        this.CreatorName      = matchListing.CreatorName;
        this.CreatorNameColor = (uint)matchListing.CreatorNameColor.ToArgb();

        string mode = matchListing.LevelMod.ToString();

        this.LevelMod = char.ToLowerInvariant(mode[0]) + mode[1..];
        public void Handle(ClientSession session, JsonPacket message)
        {
            MatchListing matchListing = PlatformRacing3Server.MatchListingManager.GetTournament(session);

            if (matchListing != null)
            {
                session.SendPacket(new TournamnetStatusOutgoingMessage(1));
            }
            else if (PlatformRacing3Server.MatchManager.HasOngoingTournaments)
            {
                session.SendPacket(new TournamnetStatusOutgoingMessage(2));
            }
            else
            {
                session.SendPacket(new TournamnetStatusOutgoingMessage(0));
            }
        }
Exemple #9
0
        internal JsonQuickJoinSuccessOutgoingMessage(MatchListing matchListing)
        {
            this.Name = matchListing.Name;

            this.LevelId    = matchListing.LevelId;
            this.LevelTitle = matchListing.LevelTitle;

            this.CreatorId   = matchListing.CreatorId;
            this.CreatorName = matchListing.CreatorName;

            string mode = matchListing.LevelMod.ToString();

            this.LevelMod = Char.ToLowerInvariant(mode[0]) + mode.Substring(1);

            this.Likes    = matchListing.Likes;
            this.Dislikes = matchListing.Dislikes;

            this.MinRank = matchListing.MinRank;
            this.MaxRank = matchListing.MaxRank;

            this.MaxMembers = matchListing.MaxMembers;
        }
Exemple #10
0
    internal MatchListing GetLeveOfTheDay()
    {
        MatchListing listing = this.MatchListings.Values.Where((m) => m.Type == MatchListingType.LevelOfTheDay).OrderByDescending((l) => l.ClientsCount).FirstOrDefault();

        if (listing == null)
        {
            IReadOnlyCollection <LevelData> levels = LevelManager.GetCampaignLevels().GetAwaiter().GetResult().Levels;
            if (levels.Count > 0)
            {
                LevelData random = levels.ElementAt(new Random().Next(0, levels.Count));

                listing = new MatchListing(this, this.matchManager, MatchListingType.LevelOfTheDay, null, random, MatchListingType.LevelOfTheDay.GetLobbyId(this.GetNextMatchListingId()), 0, uint.MaxValue, 4, false);

                if (!this.MatchListings.TryAdd(listing.Name, listing))
                {
                    return(null);
                }
            }
        }

        return(listing);
    }
        public void Handle(ClientSession session, JsonPacket message)
        {
            if (!session.IsLoggedIn)
            {
                return;
            }

            MatchListing matchListing = PlatformRacing3Server.MatchListingManager.GetTournament(session);

            if (matchListing != null)
            {
                session.SendPacket(new ForceMatchOutgoingMessage(matchListing));
            }
            else if (PlatformRacing3Server.MatchManager.HasOngoingTournaments)
            {
                session.SendMessage("Tournament is running, spectate coming \"soon\"!");
            }
            else
            {
                session.SendMessage("There are no tournaments running");
            }
        }
        internal override void Handle(ClientSession session, JsonJoinRoomIncomingMessage message)
        {
            if (!session.IsLoggedIn)
            {
                return;
            }

            switch (message.RoomType)
            {
            case "chat":
            {
                PlatformRacing3Server.ChatRoomManager.JoinOrCreate(session, message.RoomName, message.Pass, message.Note, out bool status, message.ChatId);
            }
            break;

            case "match_listing":
            {
                MatchListing listing = PlatformRacing3Server.MatchListingManager.Join(session, message.RoomName, out bool status);
                if (listing == null)
                {
                    session.SendPacket(new UserJoinRoomOutgoingMessage(message.RoomName, session.SocketId, session.UserData.Id, session.UserData.Username, session.GetVars("userName", "rank", "hat", "head", "body", "feet", "hatColor", "headColor", "bodyColor", "feetColor", "socketID", "ping")));
                    session.SendPacket(new UserLeaveRoomOutgoingMessage(message.RoomName, session.SocketId));

                    if (!status)
                    {
                        session.SendPacket(new AlertOutgoingMessage("Failed to join the match listing!"));
                    }
                }
            }
            break;

            case "game":
            {
                PlatformRacing3Server.MatchManager.JoinMultiplayerMatch(session, message.RoomName);
            }
            break;
            }
        }
 internal ForceMatchOutgoingMessage(MatchListing listing) : base(new JsonForceMatchOutgoingMessage(listing))
 {
 }
Exemple #14
0
 internal void Die(MatchListing matchListing)
 {
     this.MatchListings.TryRemove(matchListing.Name, out _);
 }
    internal void RemoveMatch(MatchListing listing)
    {
        this._Matches.Remove(listing);

        listing.LeaveLobby(this.Session);
    }
Exemple #16
0
 internal QuickJoinSuccessOutgoingMessage(MatchListing matchListing) : base(new JsonQuickJoinSuccessOutgoingMessage(matchListing))
 {
 }
 internal MatchCreatedOutgoingMessage(MatchListing matchListing) : base(new JsonMatchCreatedOutgoingMessage(matchListing))
 {
 }
Exemple #18
0
        internal override void Handle(ClientSession session, JsonJoinRoomIncomingMessage message)
        {
            if (!session.IsLoggedIn)
            {
                return;
            }

            switch (message.RoomType)
            {
            case "chat":
            {
                PlatformRacing3Server.ChatRoomManager.JoinOrCreate(session, message.RoomName, message.Pass, message.Note, out ChatRoomJoinStatus status);
            }
            break;

            case "match_listing":
            {
                MatchListing listing = PlatformRacing3Server.MatchListingManager.Join(session, message.RoomName, out MatchListingJoinStatus status);
                if (listing == null)
                {
                    session.SendPackets(new UserJoinRoomOutgoingMessage(message.RoomName, session.SocketId, session.UserData.Id, session.UserData.Username, session.GetVars("userName", "rank", "hat", "head", "body", "feet", "hatColor", "headColor", "bodyColor", "feetColor", "socketID", "ping")), new UserLeaveRoomOutgoingMessage(message.RoomName, session.SocketId));

                    switch (status)
                    {
                    case MatchListingJoinStatus.Failed:
                    {
                        session.SendPacket(new AlertOutgoingMessage("Failed to join the match listing due to unknown error, sorry"));
                        break;
                    }

                    case MatchListingJoinStatus.WaitingForHost:
                    {
                        session.SendPacket(new AlertOutgoingMessage("You are trying to join the match too early, chill"));
                        break;
                    }

                    case MatchListingJoinStatus.Banned:
                    {
                        session.SendPacket(new AlertOutgoingMessage("You have been banned from this match listing"));
                        break;
                    }

                    case MatchListingJoinStatus.NoRankRequirement:
                    {
                        session.SendPacket(new AlertOutgoingMessage($"You don't meet the rank requirement, your rank must be at least {listing.MinRank} and not higer than {listing.MaxRank}"));
                        break;
                    }

                    case MatchListingJoinStatus.FriendsOnly:
                    {
                        session.SendPacket(new AlertOutgoingMessage($"You may only join if you are on the hosts friends list"));
                        break;
                    }

                    case MatchListingJoinStatus.Full:
                    {
                        session.SendPacket(new AlertOutgoingMessage($"The match listing is full"));
                        break;
                    }

                    case MatchListingJoinStatus.Started:
                    {
                        session.SendPacket(new AlertOutgoingMessage($"The match listing has been already started"));
                        break;
                    }

                    case MatchListingJoinStatus.Died:
                    {
                        session.SendPacket(new AlertOutgoingMessage($"The match listing has been closed due to everyone leaving"));
                        break;
                    }
                    }
                }
            }
            break;

            case "game":
            {
                PlatformRacing3Server.MatchManager.JoinMultiplayerMatch(session, message.RoomName);
            }
            break;
            }
        }
 internal JsonReceiveLevelOfTheDayOutgoingMessage(MatchListing matchListing)
 {
     this.Lotd = matchListing.GetVars("*");
 }
Exemple #20
0
 internal ReceiveLevelOfTheDayOutgoingMessage(MatchListing listing) : base(new JsonReceiveLevelOfTheDayOutgoingMessage(listing))
 {
 }