コード例 #1
0
        private static async Task CreateJson()
        {
            if (!Directory.Exists("pages"))
            {
                Directory.CreateDirectory("pages");
            }
            var ret     = new List <SimpleSearchItemModel>();
            var current = 1;
            var max     = -1;

            while (true)
            {
                var path = Path.Combine(Directory.GetCurrentDirectory(), "pages\\" + current + ".json");

                if (!File.Exists(path))
                {
                    Console.WriteLine("Downloading page " + current + " from " + max);
                    await Task.Delay(1000);

                    var dl = await DownloadPageAsync(current);

                    File.WriteAllText(path, dl, Encoding.UTF8);
                }
                var txt  = File.ReadAllText(path);
                var json = JsonConvert.DeserializeObject <EADatabaseResultJson>(txt);
                max = json.totalPages;
                foreach (var item in json.items)
                {
                    var obj = new SimpleSearchItemModel();
                    obj.Type     = FUTSearchParameterType.Player;
                    obj.ClubID   = item.club.id;
                    obj.LeagueID = item.league.id;
                    obj.NationID = item.nation.id;
                    obj.RareFlag = 0;
                    obj.Rating   = item.rating;
                    var revID   = ResourceIDManager.GetRevID(int.Parse(item.id));
                    var assetID = ResourceIDManager.GetAssetID(int.Parse(item.id));
                    obj.id         = assetID;
                    obj.RevisionID = revID;
                    obj.c          = item.commonName;
                    obj.f          = item.firstName;
                    obj.l          = item.lastName;
                    obj.n          = item.nation.id;
                    obj.r          = item.rating;
                    ret.Add(obj);
                }
                current++;
                if (current > max)
                {
                    break;
                }
            }

            File.WriteAllText("players.json", JsonConvert.SerializeObject(ret));
        }
コード例 #2
0
        public ItemStatistic()
        {
            this.RequiresAuthentication();
            Get("/itemstatistic", args =>
            {
                var model           = new ItemStatisticModel();
                model.ItemStatistic = new List <SimpleItemStatistic>();
                var listItems       = ItemListManager.GetFUTListItems();
                var allProfits      = FUTLogsDatabase.GetFUTProfitLogs();
                var allTpItems      = Fifa.Managers.BotManager.GetTradepileItems();

                foreach (var futListItem in listItems)
                {
                    var profits = new List <FUTItemProfit>();
                    var tpValue = 0;
                    if (futListItem.ChemistryStyle == ChemistryStyle.All && futListItem.Position == Position.Any)
                    {
                        profits = allProfits.Where(x => x.AssetID == futListItem.AssetID && x.RevisionID == futListItem.RevisionID).ToList();
                        tpValue =
                            (int)allTpItems.Where(
                                x =>
                                ResourceIDManager.GetAssetID(x.itemData.resourceId) == futListItem.AssetID &&
                                ResourceIDManager.GetRevID(x.itemData.resourceId) == futListItem.RevisionID)
                            .Sum(x => x.buyNowPrice * 0.95);
                    }
                    else if (futListItem.ChemistryStyle == ChemistryStyle.All && futListItem.Position != Position.Any)
                    {
                        profits = allProfits.Where(x => x.AssetID == futListItem.AssetID && x.RevisionID == futListItem.RevisionID && x.Position == futListItem.Position).ToList();
                        tpValue =
                            (int)allTpItems.Where(
                                x =>
                                ResourceIDManager.GetAssetID(x.itemData.resourceId) == futListItem.AssetID &&
                                ResourceIDManager.GetRevID(x.itemData.resourceId) == futListItem.RevisionID && x.itemData.preferredPosition == futListItem.Position)
                            .Sum(x => x.buyNowPrice * 0.95);
                    }
                    else if (futListItem.ChemistryStyle != ChemistryStyle.All && futListItem.Position == Position.Any)
                    {
                        profits = allProfits.Where(x => x.AssetID == futListItem.AssetID && x.RevisionID == futListItem.RevisionID && x.ChemistryStyle == futListItem.ChemistryStyle).ToList();
                        tpValue =
                            (int)allTpItems.Where(
                                x =>
                                ResourceIDManager.GetAssetID(x.itemData.resourceId) == futListItem.AssetID &&
                                ResourceIDManager.GetRevID(x.itemData.resourceId) == futListItem.RevisionID && x.itemData.playStyle == (int)futListItem.ChemistryStyle)
                            .Sum(x => x.buyNowPrice * 0.95);
                    }
                    else if (futListItem.ChemistryStyle != ChemistryStyle.All && futListItem.Position == Position.Any)
                    {
                        profits = allProfits.Where(x => x.AssetID == futListItem.AssetID && x.RevisionID == futListItem.RevisionID && x.ChemistryStyle == futListItem.ChemistryStyle && x.Position == futListItem.Position).ToList();
                        tpValue =
                            (int)allTpItems.Where(
                                x =>
                                ResourceIDManager.GetAssetID(x.itemData.resourceId) == futListItem.AssetID &&
                                ResourceIDManager.GetRevID(x.itemData.resourceId) == futListItem.RevisionID && x.itemData.playStyle == (int)futListItem.ChemistryStyle && x.itemData.preferredPosition == futListItem.Position)
                            .Sum(x => x.buyNowPrice * 0.95);
                    }

                    var statistic                  = new SimpleItemStatistic(profits);
                    statistic.TradepileValue       = tpValue;
                    statistic.ItemsLeftOnTradepile = profits.Count(x => x.SellTimestamp == 0);
                    statistic.Name                 = futListItem.DisplayName;
                    statistic.RevisionID           = futListItem.RevisionID;
                    statistic.AssetID              = futListItem.AssetID;
                    statistic.TotalSearched        = futListItem.TimesSearched + 1;
                    statistic.RPMProfit            = (int)(statistic.TotalProfit / (futListItem.TimesSearched + 1));

                    model.ItemStatistic.Add(statistic);
                }

                return(View["ItemStatistic", model]);
            });
        }