public static ByteArrayContent MakeJsonObject(GameRecord record) { var json = JsonConvert.SerializeObject(record); var buffer = System.Text.Encoding.UTF8.GetBytes(json); var byteContent = new ByteArrayContent(buffer); byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); return(byteContent); }
private static void GetGameRecordData(Entity hero) { _record = new GameRecord(); _record.DateTime = DateTime.Now; _record.Position = hero.GetTag(GameTag.PLAYER_LEADERBOARD_PLACE); _record.Hero = hero.Card.LocalizedName; _record.HeroID = hero.Card.Id; _record.Tribes = _avaiableTribes; _record.GameID = Core.Game.CurrentGameStats.GameId; _record.Player = Core.Game.Player.Name; _record.Region = Core.Game.CurrentRegion; }
public static void WriteGameRecordToFile(string gameHistoryFile, GameRecord record) { if (!File.Exists(gameHistoryFile)) { File.Create(gameHistoryFile); } string output = JsonConvert.SerializeObject(record); using (StreamWriter sw = File.AppendText(gameHistoryFile)) { sw.WriteLine(output); } }
internal static async void GameStart() { if (!Core.Game.Spectator) { //_console.SetConsoleText("Game with the ID " + Core.Game.CurrentGameStats.GameId + " started."); if (String.IsNullOrEmpty(_config.player)) { _config.player = Core.Game.Player.Name; } IsMissingTribeRetrieved = false; _tribeImgSize = _config.tribeSize; int waitTime = 6000; while (!IsMissingTribeRetrieved && waitTime > 0) { Thread.Sleep(3000); waitTime -= 3000; IsMissingTribeRetrieved = SetMissingRace(); } //var avaiableHeroes = await SetPersonalHeroRating(); //_console.SetConsoleText("Getting Game Informations"); try { _peak = GameRecord.GetPeak(_recordList, Core.Game.CurrentRegion); //GameRecord.GetHeroWinRating(_recordList, avaiableHeroes, _avaiableTribes, _console); } catch { } _view.SetPeak(_peak); if (_rating > 0) { _view.SetMMR(_rating); } else { _view.SetMMR(_ratingStart); } } }
public GameHistoryOverlay() { InitializeComponent(); try { _recordList = GameRecord.LoadGameRecordFromFile(_config._gameRecordPath); MakeSeries(); } catch { MessageBox.Show("You cant show Stats yet, maybe you didnt play anygame so far.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); }; }
public HeroStats() { InitializeComponent(); //eventuell wenn leer dann zeig nix an... oder dann funktioniert das feature nicht... oder er zieht sich den namen automatisch und speichert ihn in der config... try { var client = boonApiConnector.InitializeClient(); _recordList = GameRecord.LoadGameRecordFromApi(client, _config.player); showAvgRanks(); imgBg.ImageSource = new BitmapImage(new Uri(Config._statsBackgroundPath)); mostTop3Hero(); } catch { MessageBox.Show("You cant show Stats yet, maybe you didnt play anygame so far.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); }; }
//public List<string> Headers = new List<string> { // "Date & Time","Position","MMR" ,"Hero", "Banned Tribes", "Ending Minions", "Ending Turn", "Game ID", "Player" // }; public static List <GameRecord> LoadGameRecordFromFile(string gameHistoryFile) { List <GameRecord> gameRecords = new List <GameRecord>(); if (File.Exists(gameHistoryFile)) { using (StreamReader streamReader = File.OpenText(gameHistoryFile)) { string dataLine; while ((dataLine = streamReader.ReadLine()) != null) { var singleGameRecord = new GameRecord(); singleGameRecord = JsonConvert.DeserializeObject <GameRecord>(dataLine); gameRecords.Add(singleGameRecord); } } } return(gameRecords); }
private static void GetMmrRecordData(GameRecord record) { record.Mmr = Core.Game.BattlegroundsRatingInfo.Rating; }
private static void WriteGameRecordToFile(GameRecord record) { GameRecord.WriteGameRecordToFile(_config._gameRecordPath, record); }
//internal static async Task<string[]> SetPersonalHeroRating() //{ // string[] avaiableHeroes = null; // for (var i = 0; i < 10; i++) // { // await Task.Delay(500); // var heroes = Core.Game.Player.PlayerEntities.Where(x => x.IsHero && x.HasTag(GameTag.BACON_HERO_CAN_BE_DRAFTED)); // if (heroes.Count() < 2) // continue; // await Task.Delay(500); // avaiableHeroes = heroes.Select(x => x.Card.LocalizedName).ToArray(); // } // return avaiableHeroes; //} private static void LoadGameRecordFromFile() { _recordList = GameRecord.LoadGameRecordFromFile(_config._gameRecordPath); }