Exemple #1
0
        public async Task <IActionResult> SemiAutoMatchmake([FromBody] SemiAutoMatchmake.Request req)
        {
            await MatchingServerInfo.MultiMatchingServersAsync();

            var requester = new evomatching.ProtocolModels.Matching.SemiAutoMatchmake();

            requester.request = req;
            var res = await requester.PostAsyncXXX(MatchingServerInfo.AreaUri(req.matchingArea.Value));

            return(Ok(res.Payload));
        }
Exemple #2
0
        public async Task <IActionResult> SemiAutoMatchmake(
            [FromBody] SemiAutoMatchmake.Request req, [FromServices] GeneralManager gm)
        {
            var res = new SemiAutoMatchmake.Response
            {
                matchId = req.matchId,
                entries = new List <SemiAutoMatchmake.Entry>(),
            };

            var matchmaker = new Logic.Matchmaker2();

            await gm.EnqueueJob(() =>
            {
                var match = gm.MatchManager.GetMatch(req.matchId);
                if (match == null || match.State != MatchState.Matching)
                {
                    return;
                }

                var entries = new List <IBattleEntry>();
                req.entryIds.ForEach(id =>
                {
                    var entry = gm.BattleEntryManager.GetEntry(id);
                    if (entry != null)
                    {
                        entries.Add(entry);
                    }
                });

                var result = matchmaker.Matchmake(1, entries, Battle.MatchPlayersNum);
                if (1 <= result.Count)
                {
                    result[0].Elements.ForEach(element => res.entries.Add(new SemiAutoMatchmake.Entry
                    {
                        entryId = element.Entry.EntryId,
                        side    = element.Side,
                    }));
                }
            });

            return(Ok(res));
        }