コード例 #1
0
        public void ProcessMatches(string matchlinks, string maplinks, string apiKey)
        {
            PopulateMatchIDs(matchlinks);
            CreatePool(maplinks);
            APIAccessor.ApiKey = apiKey;

            foreach (string matchID in MatchIDs)
            {
                OMP.Model.Match match = new OMP.Model.Match(matchID);
                matches.Add(match);
                JArray matchJSON = APIAccessor.RetrieveMatchDataAsync(matchID).Result;
                match.FillMaps(matchJSON);
            }

            foreach (OMP.Model.Match match in matches)
            {
                foreach (MatchMap map in match.Maps)
                {
                    if (mappool.MapIDs.Contains(map.mapID))
                    {
                        CalculateAllPlayerRatings(map);
                    }
                }
            }

            foreach (MatchPlayer player in players)
            {
                player.CalculateNewElo();
            }

            UpdateElo(players);
        }
コード例 #2
0
        //gets data (rank and name) of a user from the API and seeds them based on pp rank
        public MatchPlayer GetNewPlayer(string playerID, double kfactor)
        {
            JArray playerJSON = APIAccessor.RetrievePlayerDataAsync(playerID).Result;
            string name       = playerJSON[0]["username"].Value <string>();
            int    rank       = playerJSON[0]["pp_rank"].Value <int>();
            double elo        = SeedPlayer(rank);

            return(new MatchPlayer(playerID, name, elo, 0, kfactor));
        }
コード例 #3
0
ファイル: HelpVM.cs プロジェクト: ChaisSt/VaultBuddyMobile
        private void Logout()
        {
            Routing.RegisterRoute(nameof(oAuthPage), typeof(oAuthPage));

            APIAccessor accessor = new APIAccessor();

            accessor.RemoveAuthorization();

            Shell.Current.GoToAsync(nameof(oAuthPage));
        }
コード例 #4
0
        public async Task <MemberModel> GetMemberModelAsync(APIAccessor accessor)
        {
            MemberModel member = new MemberModel();

            MemberAPIModel memberAPI = await GetPlayerAsync(accessor);

            member.MemberID   = memberAPI.Response.DestinyMemberships[0].MembershipId;
            member.MemberType = Convert.ToInt32(memberAPI.Response.DestinyMemberships[0].MembershipType);

            return(member);
        }
コード例 #5
0
        public async Task <MemberAPIModel> GetPlayerAsync(APIAccessor accessor)
        {
            var path  = "/User/GetMembershipsForCurrentUser";
            var query = "/";

            accessor.CreateUri(path, query);

            var res = await APIAccessor.RequestAsync(APIAccessor.ApiClient);

            var memberAPI = JsonConvert.DeserializeObject <MemberAPIModel>(res);

            return(memberAPI);
        }
コード例 #6
0
        private async Task <CharacterAPIModel> ApiGetCharactersAsync(MemberModel member, APIAccessor accessor)
        {
            string path  = "Destiny2/" + member.MemberType.ToString() + "/Profile/";
            string query = member.MemberID + "/?components=100";

            accessor.CreateUri(path, query);

            string response = await APIAccessor.RequestAsync(APIAccessor.ApiClient);

            var characterAPI = JsonConvert.DeserializeObject <CharacterAPIModel>(response);

            return(characterAPI);
        }
コード例 #7
0
ファイル: Form1.cs プロジェクト: Feuerholz/OMTC
        private void button1_Click(object sender, EventArgs e)
        {
            APIAccessor.ApiKey = apikeybox.Text;
            Match  match     = new Match(blueteambox.Text, redteambox.Text, matchidbox.Text);
            JArray matchJSON = APIAccessor.RetrieveMatchDataAsync(matchidbox.Text).Result;

            match.FillMaps(matchJSON);
            string       tablepath = "./" + matchidbox.Text + ".txt";
            StreamWriter file      = new StreamWriter(@tablepath);

            file.Write(CorsaceOpen2018ThreadCreator.CreateThreadText(match));
            file.Close();
        }
コード例 #8
0
        public async Task <PrimaryStat> GetInstanceAsync(Item item, MemberModel member, APIAccessor accessor)
        {
            string path  = "Destiny2/" + member.MemberType.ToString() + "/Profile/" + member.MemberID;
            string query = "/Item/" + item.ItemInstanceId + "/?components=300";

            accessor.CreateUri(path, query);

            string res = await APIAccessor.RequestAsync(APIAccessor.ApiClient);

            var items        = JsonConvert.DeserializeObject <ItemAPIInstance>(res);
            var instancePath = items.Response.Instance.Data.PrimaryStat;

            return(instancePath);
        }
コード例 #9
0
        public async Task <Item[]> GetInventoryItemHashesAsync(MemberModel member, string charId, APIAccessor accessor)
        {
            string path  = "Destiny2/" + member.MemberType.ToString() + "/Profile/" + member.MemberID;
            string query = "/Character/" + charId + "/?components=201";

            accessor.CreateUri(path, query);

            string res = await APIAccessor.RequestAsync(APIAccessor.ApiClient);

            var items         = JsonConvert.DeserializeObject <ItemAPIModel>(res);
            var inventoryPath = items.Response.Inventory.Data.Items;

            return(inventoryPath);
        }
コード例 #10
0
        public async Task <MemberModel> SearchPlayerAsync(string input, MemberModel member)
        {
            string path  = "/Destiny2/SearchDestinyPlayer/-1/";
            string query = input + "/";

            accessor.CreateUri(path, query);

            var res = await APIAccessor.RequestAsync(APIAccessor.ApiClient);

            var result = JsonConvert.DeserializeObject <SearchedPlayerAPI>(res);

            member.MemberID   = result.Response[0].MembershipId;
            member.MemberType = Convert.ToInt32(result.Response[0].MembershipType);

            return(member);
        }
コード例 #11
0
        public async Task <List <ItemModel> > GetCharacterEquippedAsync(MemberModel member, CharacterModel character)
        {
            string path  = "Destiny2/" + member.MemberType.ToString() + "/Profile/" + member.MemberID;
            string query = "/Character/" + character.Id + "/?components=205";

            accessor.CreateUri(path, query);

            string response = await APIAccessor.RequestAsync(APIAccessor.ApiClient);

            var result = JsonConvert.DeserializeObject <ItemAPIModel>(response);

            List <ItemModel> itemList = new List <ItemModel>();
            var itemPath = result.Response.Equipment.Data.Items;

            itemList = await GetItemInfoAsync(itemPath, member, itemList);

            return(itemList);
        }
コード例 #12
0
        public async Task Initialize()
        {
            _aPIAccessor = new APIAccessor();

            MemberModel member = new MemberModel();

            member = await GetMemberAsync();

            member = await GetCharacterListAsync(member);

            AllItems = await GetInventoryAsync(member);

            Member = member;

            await IsFavoriteAsync();

            GetFilteredItems("All");

            Filter = new Command <string>(GetFilteredItems);
        }
コード例 #13
0
        public async Task <List <CharacterModel> > GetCharacterAsync(MemberModel member, APIAccessor accessor)
        {
            var characterList = new List <CharacterModel>();
            CharacterAPIModel characterAPI = await ApiGetCharactersAsync(member, accessor);

            foreach (var characterId in characterAPI.Response.Profile.Data.CharacterIds)
            {
                string path  = "Destiny2/" + member.MemberType.ToString() + "/Profile/" + member.MemberID;
                string query = "/Character/" + characterId + "/?components=200";
                accessor.CreateUri(path, query);

                string response = await APIAccessor.RequestAsync(APIAccessor.ApiClient);

                var characterInfoData = JsonConvert.DeserializeObject <CharacterInfoModel>(response);

                if (characterInfoData != null)
                {
                    characterList.Add(Character(characterId, characterInfoData));
                }
            }
            return(characterList);
        }
コード例 #14
0
 public async Task RequestTransferAsync(TransferModel postBody)
 {
     string uri = "https://www.bungie.net/Platform/Destiny2/Actions/Items/TransferItem/";
     await APIAccessor.TransferAsync <TransferModel>(uri, postBody);
 }
コード例 #15
0
        public async Task <List <ItemModel> > AddItemsListAsync(string inventoryType, Item[] items, MemberModel member,
                                                                ItemsManifestService manifest, APIAccessor accessor)
        {
            var itemList = new List <ItemModel>();

            foreach (var item in items)
            {
                try
                {
                    ItemManifestModel info = manifest.GetManifestItemData(item);
                    BucketModel       type = info != null?manifest.GetManifestBucketData(info, item) : null;

                    PrimaryStat instance = item.ItemInstanceId != null && type != null ? await GetInstanceAsync(item, member, accessor) : null;

                    //DamageModel damage = new DamageModel();
                    //if (info != null && type.DisplayProperties.Name == "Energy Weapons")
                    //{
                    //    damage = manifest.GetDamageTypeData(info);
                    //}
                    //DamageModel damage = info != null && type.DisplayProperties.Name == "Energy Weapons" ? manifest.GetDamageTypeData(info) : null;

                    if (info != null && type != null)
                    {
                        itemList.Add(AddModelItem(inventoryType, item, type, info, instance));
                    }
                }
                catch (Exception e) { }
            }
            return(itemList);
        }
コード例 #16
0
ファイル: Match.cs プロジェクト: Feuerholz/OMP
        public void FillMaps(JArray matchJSON)
        {
            Set set = new Set();

            for (int i = 0; i < matchJSON.Count; i++)
            {
                JArray   mapJSON    = APIAccessor.RetrieveMapDataAsync(matchJSON[i]["beatmap_id"].ToString()).Result;
                string   mapID      = matchJSON[i]["beatmap_id"].ToString();
                string   setID      = MapIDFromJArray(mapJSON);
                string   mapName    = MapNameFromJArray(mapJSON, mapID);
                Mod      mapMod     = MapModsFromJArray(matchJSON, i);
                MatchMap map        = new MatchMap(mapID, setID, mapName, mapMod);
                JArray   scoreArray = (JArray)matchJSON[i]["scores"];
                for (int k = 0; k < scoreArray.Count; k++)
                {
                    string playerID = scoreArray[k]["user_id"].ToString();
                    int    score    = Int32.Parse(scoreArray[k]["score"].ToString());
                    if (scoreArray[k]["team"].ToString().Equals("1"))
                    {
                        if (scoreArray[k]["pass"].ToString().Equals("0"))
                        {
                            map.AddScore(new PlayerScore(playerID, score, Team.Blue, false));
                        }
                        else
                        {
                            map.AddScore(new PlayerScore(playerID, score, Team.Blue, true));
                        }
                    }

                    else
                    {
                        if (scoreArray[k]["pass"].ToString().Equals("0"))
                        {
                            map.AddScore(new PlayerScore(playerID, score, Team.Red, false));
                        }
                        else
                        {
                            map.AddScore(new PlayerScore(playerID, score, Team.Red, true));
                        }
                    }
                }

                map.ComputeTeamScores();
                if (map.RedScore > 0 || map.BlueScore > 0)
                {
                    Maps.Add(map);
                    if (map.RedScore > map.BlueScore)
                    {
                        set.RedWin();
                    }
                    else
                    {
                        set.BlueWin();
                    }
                    if (set.BlueScore == 4 || set.RedScore == 4)
                    {
                        if (set.BlueScore == 4)
                        {
                            set.Winner = Team.Blue;
                            this.BlueScore++;
                        }
                        else
                        {
                            set.Winner = Team.Red;
                            this.RedScore++;
                        }
                        Sets.Add(set);
                        set = new Set();
                    }
                }
                if (i == matchJSON.Count - 1)
                {
                    if (set.BlueScore != 0 || set.RedScore != 0)           //handle unfinished sets that can happen due to disconnects etc
                    {
                        Sets.Add(set);
                    }
                }
            }
        }