private Task LeaveServer() { return(Task.Run(async() => { toolStripStatusLabel1.Text = "Leaving server..."; BattlelogResponse leave = await DeserializeResponseAsync <BattlelogResponse>(await DoHttpRequestAsync(String.Format(URL.BF3LeaveServer, Globals.PersonaId, Globals.CurrentGameId))); })); }
public bool GetBattlelogWeaponStats(string game, string personaId, out BattlelogResponse <WeaponStats> outputModel) { try { var result = GetWeaponStats(new RequestParams { Game = game, PersonaId = personaId }, out var output); var mainWeaponStats = output.Model .SelectMany(x => x.Weapons) .Select(x => { var weaponInfo = WeaponConverter.WeaponInfo(x.Guid); return(new MainWeaponStat { Guid = x.Guid, ServiceStars = (int)x.Stats.Values.Kills / 100, ServiceStarsProgress = x.Stats.Values.Kills % 100, Category = weaponInfo?.Category, CategorySID = weaponInfo?.CategorySID, Slug = weaponInfo?.Slug, Name = weaponInfo?.Name, Kills = x.Stats.Values.Kills, ShotsFired = x.Stats.Values.Shots, ShotsHit = x.Stats.Values.Hits, Accuracy = x.Stats.Values.Accuracy / 100, Headshots = x.Stats.Values.Headshots, TimeEquipped = x.Stats.Values.Seconds }); }) .Where(x => !string.IsNullOrEmpty(x.Name)) .ToList(); outputModel = new BattlelogResponse <WeaponStats> { Type = "success", Message = "OK", Data = new WeaponStats { PersonaId = ulong.Parse(personaId), MainWeaponStats = mainWeaponStats } }; return(true); } catch (Exception ex) { Console.WriteLine(ex.Message); outputModel = new BattlelogResponse <WeaponStats> { Type = "error", Message = "FAIL" }; return(false); } }