Exemple #1
0
        public async Task <IActionResult> PutChampionList(Guid id, ChampionList championList)
        {
            if (id != championList.Id)
            {
                return(BadRequest());
            }

            _context.Entry(championList).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ChampionListExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #2
0
        public async Task <ActionResult <ChampionList> > PostChampionList(ChampionList championList)
        {
            _context.ChampionLists.Add(championList);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetChampionList", new { id = championList.Id }, championList));
        }
        /// <summary>
        /// Get the free to play or the not free champions.
        /// </summary>
        /// <param name="freeToPlay">
        /// True if all the free champions should be returned. OPtherwise false to return the not
        /// free champions.
        /// </param>
        /// <returns>A <see cref="ChampionList"/> that holds the champions requested</returns>
        public async Task <ChampionList> GetAsync(bool freeToPlay)
        {
            if (freeToPlay)
            {
                if (_freeChampions == null)
                {
                    var champs = await WebGetAsync <ChampionListDto>(new Uri("?freeToPlay=true", UriKind.Relative));

                    _freeChampions = Mapper.Map <ChampionList>(champs);
                }

                return(_freeChampions);
            }
            else
            {
                if (_notFreeChampions == null)
                {
                    var champs = await WebGetAsync <ChampionListDto>(new Uri("?freeToPlay=false", UriKind.Relative));

                    _notFreeChampions = Mapper.Map <ChampionList>(champs);
                }

                return(_notFreeChampions);
            }
        }
Exemple #4
0
    public void CreateChampBase()
    {
        jsonData = textAsset.ToString();

        ChampionList champList = JsonUtility.FromJson <ChampionList>(jsonData);

        GameObject parent = new GameObject();

        parent.name = "Champions";
        parent.gameObject.AddComponent <ChampionsManager>();
        foreach (ChampData champData in champList.targetObjects)
        {
            GameObject go = Instantiate(champTemp, parent.transform);
            go.GetComponent <ChampionData>().cost      = champData.cost;
            go.GetComponent <ChampionData>().champName = champData.name;

            foreach (TraitsData traitsData in champList.targetObjects[i].traits)
            {
                go.GetComponent <ChampionData>().traitsName1 = traitsData.name1;
                go.GetComponent <ChampionData>().traitsName2 = traitsData.name2;
                if (traitsData.name3 != null)
                {
                    go.GetComponent <ChampionData>().traitsName3 = traitsData.name3;
                }
            }

            go.name = champData.name;
            go.GetComponent <SpriteRenderer>().sprite = championSprites[i];
            i++;
        }
    }
Exemple #5
0
        public void RemoveChampion(Model.Champion champion_)
        {
            if (!loaded)
            {
                return;
            }

            if (!ChampionList.Contains(champion_))
            {
                return;
            }

            App.Server.Request(
                HTTPMethods.Delete,
                "champion/" + champion_.Json["_id"],
                (JSONNode json_) =>
            {
                ChampionList.Remove(champion_);
                foreach (var almostJson in Json["champions"].AsArray)
                {
                    if (almostJson.Value["_id"] == champion_.Json["_id"])
                    {
                        Json["champions"].AsArray.Remove(almostJson.Value);
                        break;
                    }
                }

                ChampionRemoved(champion_);
            }).Send();
        }
Exemple #6
0
    void SetupChampions()
    {
        ChampionList champList = JsonConvert.DeserializeObject <ChampionList>(File.ReadAllText(URLs.GetChampions()));

        foreach (KeyValuePair <string, Champion> keyValue in champList.champions)
        {
            championsList.Add(Int16.Parse(keyValue.Value.key), keyValue.Value);
        }
    }
Exemple #7
0
 public void LoadAllChampionsLocal()
 {
     if (File.Exists(StaticSerializer.FullPath_AllChampions))
     {
         AllChampions = (ChampionList)StaticSerializer.DeSerializeObject(StaticSerializer.FullPath_AllChampions);
     }
     else
     {
         AllChampions = new ChampionList("AllChamps");
     }
 }
        /// <summary>
        /// Gets all champions in the game.
        /// </summary>
        /// <returns>A <see cref="ChampionList"/> that holds all champions</returns>
        public async Task <ChampionList> GetAsync()
        {
            if (_allChampions == null)
            {
                var champs = await WebGetAsync <ChampionListDto>(null);

                _allChampions = Mapper.Map <ChampionList>(champs);
            }

            return(_allChampions);
        }
 public wndAddChampion(ChampionList allChamps) : this()
 {
     if (allChamps != null)
     {
         this._allChamps = allChamps;
     }
     else
     {
         throw new ArgumentNullException();
     }
 }
Exemple #10
0
 private void LoadAllChampions()
 {
     AllChampions = new ChampionList("AllChampions");
     LoadAllChampionsRiotApi(); //Use api to get all champions
     if (AllChampions.getCount() < 1)
     {
         LoadAllChampionsLocal();
     }
     AllChampions.ChampionsChanged += (s, args) => StaticSerializer.SerializeObject(AllChampions, StaticSerializer.FullPath_AllChampions);
     if (!File.Exists(StaticSerializer.FullPath_AllChampions))
     {
         StaticSerializer.SerializeObject(AllChampions, StaticSerializer.FullPath_AllChampions);
     }
 }
        public StaticService(
            ILeagueApiConfiguration config)
            : base(config, VersionEnum.V1Rev2, "static-data", false)
        {
            ChampionList.CreateMap(AutoMapperService);
            ItemList.CreateMap(AutoMapperService);
            MasteryList.CreateMap(AutoMapperService);
            Realm.CreateMap(AutoMapperService);
            RuneList.CreateMap(AutoMapperService);
            SummonerSpellList.CreateMap(AutoMapperService);

#if DEBUG
            AutoMapperService.AssertConfigurationIsValid();
#endif
        }
        public ChampionList GetAllChampions(String Host, regions.Regions selectedRegion)
        {
            try
            {
                String       requestUrl      = Host + Endpoints.API_LOL + selectedRegion + Endpoints.REGION_CHAMPIONS + Endpoints.API_KEY;
                var          requestResult   = request.MakeRequest(requestUrl).Result;
                ChampionList returnChampions = JsonConvert.DeserializeObject <ChampionList>(requestResult);

                return(returnChampions);
            }
            catch (Exception e)
            {
                return(null);
            }
        }
        public async Task ConstructorTest()
        {
            LoLManager.Instance.Initialize("a118bc3c-69d5-4be1-a99a-92a83a954689", ApiRegions.NA);
            ChampionList champs1 = await LoLManager.Instance.Champion.GetAsync();

            ChampionList champs2 = await LoLManager.Instance.Champion.GetAsync(true);

            ChampionList champs3 = await LoLManager.Instance.Champion.GetAsync(false);

            Champion champ1 = await LoLManager.Instance.Champion.GetAsync(1);

            for (int i = 0; i < 50; i++)
            {
                var cha = await LoLManager.Instance.Champion.GetAsync(i);
            }
        }
Exemple #14
0
        private void _groupManager_ChampionList_NameChanged(ChampionList sender, EventArgs e)
        {
            if (sender != null)
            {
                int indexOfSender = _gm.indexOf(sender.getName());

                //if indexOfSender != -1 update that specific group
                if (indexOfSender != -1)
                {
                    System.Windows.Controls.CheckBox chk = new System.Windows.Controls.CheckBox();
                    chk         = (System.Windows.Controls.CheckBox)cboGroups.Items.GetItemAt(indexOfSender);
                    chk.Content = sender.getName();
                    cboGroups.UpdateLayout();
                }
            }
        }
Exemple #15
0
        protected override IEnumerator Build()
        {
            yield return(App.Server.Request(
                             HTTPMethods.Get,
                             "account/" + App.Content.Session.Account,
                             (JSONNode json_) =>
            {
                Json = json_;
                ChampionList.Clear();
                foreach (var almostJson in Json["champions"].AsArray)
                {
                    ChampionList.Add(new Model.Champion(almostJson.Value.AsObject));
                }

                Debug.Log(Json);
            }).Send());
        }
Exemple #16
0
 /// <summary>
 /// Add a new group.
 /// </summary>
 /// <exception cref="ArgumentExcception">Throws an ArgumentException if the group name is not unique.</exception>
 public void AddGroup(ChampionList newGroup)
 {
     if (lstGroupList.Count < intMaxGroups)
     {
         foreach (ChampionList item in lstGroupList)
         {
             if (item.getName().Equals(newGroup.getName()))
             {
                 throw new ArgumentException("Name duplicate!");
             }
         }
         lstGroupList.Add(newGroup);
         if (GroupsChanged != null)
         {
             GroupsChanged(this, new GroupManagerEventArgs(GroupManagerEventOperation.Add, newGroup));
         }
     }
 }
        static void Main(string[] args)
        {
            LeagueOfLegends lol = new LeagueOfLegends();

            Console.WriteLine("Starting");

            //Get a list of the current champions
            ChampionList championList = lol.GetAllChampions(Endpoints.EUW_HOST, regions.Regions.EUW);

            Console.WriteLine("There are currently: " + championList.Champions.Count);

            //Get a champion of the selected index
            Console.WriteLine("Input character ID.");
            int      id = Convert.ToInt32(Console.ReadLine());
            Champion selectedChampion = lol.GetChampionById(Endpoints.EUW_HOST, regions.Regions.EUW, id);

            Console.WriteLine(selectedChampion.rankedPlayEnabled);

            //Get live game
            //int summonerId = Convert.ToInt32(Console.ReadLine());
            //CurrentGameInfo currGameInfo = lol.GetCurrentGameInfo(Endpoints.NA_HOST, regions.Platform_ID.NA1, summonerId);

            //Console.WriteLine(currGameInfo.participants.Count);

            //FeaturedGamesInfo liveFeaturedGames = lol.GetFeaturedGames(Endpoints.EUW_HOST);

            //foreach (var game in liveFeaturedGames.gameList)
            //{
            //    Console.WriteLine(game.gameLength);
            //}

            //RecentGameStats recentGamesStats = lol.GetRecentStats(Endpoints.EUW_HOST, regions.Regions.EUW, 123);
            //if(recentGamesStats != null)
            //{
            //    Console.WriteLine(recentGamesStats.games[0].stats.win);
            //}
            //else
            //{
            //    Console.WriteLine("Error when collecting the recent games");
            //}

            Console.ReadLine();
        }
Exemple #18
0
    public void CreateChampBase()
    {
        jsonData = textAsset.ToString();

        ChampionList champList   = JsonUtility.FromJson <ChampionList>(jsonData);
        int          i           = 0;
        int          spriteIndex = 0;
        int          posX        = 0;
        int          posY        = 0;
        GameObject   parent      = new GameObject();

        parent.name = "Champions";
        parent.gameObject.AddComponent <ChampionsManager>();
        foreach (ChampData champData in champList.targetObjects)
        {
            GameObject go = Instantiate(champTemp, parent.transform);
            go.GetComponent <ChampionData>().cost      = champData.cost;
            go.GetComponent <ChampionData>().champName = champData.name;

            foreach (TraitsData traitsData in champList.targetObjects[i].traits)
            {
                go.GetComponent <ChampionData>().traitsName1 = traitsData.name1;
                go.GetComponent <ChampionData>().traitsName2 = traitsData.name2;
                if (traitsData.name3 != null)
                {
                    go.GetComponent <ChampionData>().traitsName3 = traitsData.name3;
                }
            }

            go.transform.position = Vector3.right * posX + Vector3.down * posY;
            go.name = champData.name;
            go.GetComponent <SpriteRenderer>().sprite = sprites[spriteIndex];
            i++;
            spriteIndex++;
            posX++;
            if (posX > 11)
            {
                posX = 0;
                posY++;
            }
        }
    }
Exemple #19
0
        public void ActivateChampion(Model.Champion champion_)
        {
            if (!loaded)
            {
                return;
            }

            if (champion_ == null || !ChampionList.Contains(champion_))
            {
                return;
            }

            if (ActiveChampion != null)
            {
                ActiveChampion.Detach();
            }

            ActiveChampion = champion_;
            ActiveChampionChanged();
        }
Exemple #20
0
        /// <summary>
        /// Move a group up or down in the list.
        /// </summary>
        /// <exception cref="ArgumentOutOfRangeException">Throws an ArgumentOutOfRangeException
        /// if the newPosition parameter is greater than the amount of groups or &lt; 1</exception>
        public void ReOrder(ChampionList cList, int newPosition)
        {
            if (lstGroupList.IndexOf(cList) == newPosition)
            {
                return; // same index
            }

            if (newPosition < 0 || newPosition >= lstGroupList.Count)
            {
                throw new ArgumentOutOfRangeException("Out of range: " + newPosition.ToString()); // Index out of range - nothing to do
            }

            lstGroupList.Remove(cList);              // Removing removable element
            lstGroupList.Insert(newPosition, cList); // Insert it in new position

            if (GroupsChanged != null)
            {
                GroupsChanged(this, new GroupManagerEventArgs(GroupManagerEventOperation.Reposition, cList));
            }
        }
Exemple #21
0
        private string CreateStringOfChampionsInChampionList(ChampionList c)
        {
            //The client accepts regex commandos

            string returnValue = "";

            for (int i = 0; i < c.getCount(); i++)
            {
                returnValue += c.getChampion(i) + "|";
            }

            //replace whitespace with \s (regex space)
            returnValue = returnValue.Replace(" ", "\\s");

            //remove last |
            if (returnValue.Length > 0)
            {
                returnValue = returnValue.Substring(0, returnValue.Length - 1);
            }

            return(returnValue);
        }
Exemple #22
0
        public void AddChampion(string name, JSONArray classes)
        {
            if (!loaded)
            {
                return;
            }

            JSONObject championJson = new JSONObject();

            championJson["name"]  = name;
            championJson["level"] = 0;
            championJson["specializationPoints"] = 0;
            championJson["classes"] = classes;

            Debug.Log(championJson);

            var request = App.Server.Request(
                HTTPMethods.Post,
                "champion",
                (JSONNode json_) =>
            {
                Model.Champion champion = new Model.Champion(json_.AsObject);
                ChampionList.Add(champion);
                Json["champions"].AsArray.Add(json_);

                ChampionAdded(champion);
            },
                (JSONNode json_) =>
            {
                App.Resource.Prefab.Popup().Setup(
                    "Network error",
                    json_.ToString());
            });

            request.AddHeader("Content-Type", "application/json");
            request.RawData = System.Text.Encoding.UTF8.GetBytes(championJson.ToString());
            request.Send();
        }
Exemple #23
0
        public List <Champion> LoadChampions()
        {
            var Ahri = new Champion("Ahri", 526, 66, 53, 20, 30, 200, 1);

            Ahri.AbilityList.Add(new Ability("Orb of Deception", 65, Ability.Damage_Type.magic, 10));
            Ahri.AbilityList.Add(new Ability("Fox Fire", 50, Ability.Damage_Type.magic, 10));
            Ahri.AbilityList.Add(new Ability("Charm", 85, Ability.Damage_Type.magic, 20)); // stuns enemy allowing Ahri a 2nd attack
            Ahri.AbilityList.Add(new Ability("Spirit Rush", 100, Ability.Damage_Type.magic, 60));

            var Caitlyn = new Champion("Caitlyn", 475, 56, 62, 32, 30, 125, 2);

            Caitlyn.AbilityList.Add(new Ability("Piltover Peacemaker", 50, Ability.Damage_Type.physical, 8));
            Caitlyn.AbilityList.Add(new Ability("Yordle Snap Trap", 20, Ability.Damage_Type.physical, 8)); //chance to stun enemy based on opponent's attackSpeed
            Caitlyn.AbilityList.Add(new Ability("90 Caliber Net", 75, Ability.Damage_Type.magic, 15));     //reduces opponent's attackSpeed by 50%
            Caitlyn.AbilityList.Add(new Ability("Ace in the Hole", 100, Ability.Damage_Type.physical, 60));

            var Darius = new Champion("Darius", 582, 62, 64, 39, 32, 85, 3);

            Darius.AbilityList.Add(new Ability("Decimate", 30, Ability.Damage_Type.physical, 6));
            Darius.AbilityList.Add(new Ability("Crippling Strike", 30, Ability.Damage_Type.physical, 12)); //Darius' next attack deals between 150%-200% damage
            Darius.AbilityList.Add(new Ability("Apprehend", 45, Ability.Damage_Type.physical, 15));        //reduces opponent's attackSpeed by 40% for one round
            Darius.AbilityList.Add(new Ability("Noxian Guillotine", 100, Ability.Damage_Type.physical, 60));

            var Draven = new Champion("Draven", 200, 20, 30, 20, 15, 20, 4);

            Draven.AbilityList.Add(new Ability("Spinning Axe", 5, Ability.Damage_Type.physical, 6));
            Draven.AbilityList.Add(new Ability("Blood Rush", 8, Ability.Damage_Type.magic, 5)); //buff for bonus attack speed
            Draven.AbilityList.Add(new Ability("Stand Aside", 10, Ability.Damage_Type.physical, 12));
            Draven.AbilityList.Add(new Ability("Whirling Death", 15, Ability.Damage_Type.physical, 60));

            var Gragas = new Champion("Gragas", 583, 62, 61, 35, 32, 90, 5);

            Gragas.AbilityList.Add(new Ability("Barrel Roll", 60, Ability.Damage_Type.magic, 10));
            Gragas.AbilityList.Add(new Ability("Drunken Rage", 30, Ability.Damage_Type.magic, 10)); //buff for magic damage and reduce damage for 1 round
            Gragas.AbilityList.Add(new Ability("Body Slam", 50, Ability.Damage_Type.magic, 15));
            Gragas.AbilityList.Add(new Ability("Explosive Cask", 100, Ability.Damage_Type.magic, 60));

            var Lux = new Champion("Lux", 490, 62, 53, 18, 30, 180, 6);

            Lux.AbilityList.Add(new Ability("Light Binding", 50, Ability.Damage_Type.magic, 8));
            Lux.AbilityList.Add(new Ability("Prismatic Barrier", 60, Ability.Damage_Type.magic, 10));  //opponent magic attack reduce by 30% for 2 rounds
            Lux.AbilityList.Add(new Ability("Lucent Singularity", 70, Ability.Damage_Type.magic, 14)); //reduce opponent attackSpeed by 15% for 2 rounds
            Lux.AbilityList.Add(new Ability("Final Spark", 100, Ability.Damage_Type.magic, 60));

            var Malphite = new Champion("Malphite", 574, 63, 61, 37, 32, 90, 7);

            Malphite.AbilityList.Add(new Ability("Seismic Shard", 70, Ability.Damage_Type.magic, 8));
            Malphite.AbilityList.Add(new Ability("Brutal Strikes", 25, Ability.Damage_Type.physical, 12));
            Malphite.AbilityList.Add(new Ability("Ground Slam", 50, Ability.Damage_Type.magic, 14)); //reduce opponent attackSpeed by 15% for 1 round
            Malphite.AbilityList.Add(new Ability("Unstoppable Force", 100, Ability.Damage_Type.magic, 60));

            var Sona = new Champion("Sona", 100, 10, 10, 12, 20, 40, 8);

            Sona.AbilityList.Add(new Ability("Hymn of Valor", 3, Ability.Damage_Type.magic, 5));
            Sona.AbilityList.Add(new Ability("Aria of Perseverence", 5, Ability.Damage_Type.magic, 10));
            Sona.AbilityList.Add(new Ability("Song of Celerity", 8, Ability.Damage_Type.magic, 10));
            Sona.AbilityList.Add(new Ability("Crescendo", 15, Ability.Damage_Type.magic, 60));

            ChampionList.Add(Ahri);
            ChampionList.Add(Caitlyn);
            ChampionList.Add(Darius);
            ChampionList.Add(Draven);
            ChampionList.Add(Gragas);
            ChampionList.Add(Lux);
            ChampionList.Add(Malphite);
            ChampionList.Add(Sona);

            Player1 = ChampionList.ElementAt(0);
            Player2 = ChampionList.ElementAt(1);

            return(ChampionList);
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="evntOp">The performed operation</param>
 /// <param name="hasChanged">The <c>ChampionList</c> undergoing the operation</param>
 public GroupManagerEventArgs(GroupManagerEventOperation evntOp, ChampionList hasChanged)
 {
     this.eventOperation = evntOp;
     this.operationItem  = hasChanged;
 }
Exemple #25
0
 private void MyGroupManager_ChampionList_NameChanged(ChampionList sender, EventArgs e)
 {
     DisplayGroups();
 }
Exemple #26
0
 private void AllChampions_ChampionsChanged(ChampionList sender, EventArgs e)
 {
     DisplayAllChampionsMinusInSelectedGroupAccordingToFilter();
 }