Пример #1
0
        async void CreatePracticeGame()
        {
            this.updateStatus("Looking for HFL games", Accountname);
            PracticeGameSearchResult[] gameList = await connection.ListAllPracticeGames();

            dynamic gameFound = gameList.FirstOrDefault(_ => (_.Name.Contains("thelawkings") && (_.Team1Count < 3 || _.Team2Count < 3)));

            if (gameFound != null)
            {
                this.updateStatus("Joining to custom game", Accountname);
                await connection.JoinGame(gameFound.Id, "hflthelawtheking");
            }
            else
            {
                this.updateStatus("Creating custom game", Accountname);
                LoLLauncher.RiotObjects.Platform.Game.PracticeGameConfig cfg = new LoLLauncher.RiotObjects.Platform.Game.PracticeGameConfig();
                cfg.GameName = "thelawkings" + new Random().Next().ToString();
                LoLLauncher.RiotObjects.Platform.Game.Map.GameMap map = new LoLLauncher.RiotObjects.Platform.Game.Map.GameMap();
                map.Description      = "desc";
                map.DisplayName      = "dummy";
                map.TotalPlayers     = 2;
                map.Name             = "dummy";
                map.MapId            = (int)GameMode.TwistedTreeline;
                map.MinCustomPlayers = 1;
                cfg.GameMap          = map;
                cfg.MaxNumPlayers    = 6;
                cfg.GamePassword     = "******";
                cfg.GameTypeConfig   = 1;
                cfg.AllowSpectators  = "NONE";
                cfg.GameMode         = StringEnum.GetStringValue(GameMode.TwistedTreeline);
                GameDTO game = await connection.CreatePracticeGame(cfg);

                if (game.Id == 0)
                {
                    CreatePracticeGame();
                }
                else
                {
                    this.updateStatus("Game (" + game.Id + ") created.", Accountname);
                }
            }
        }