public void SaveAllPlayers() { Log.Normal(this, $"Saving players."); foreach (var p in PlayerCatalogue.All.Where(p => !p.IsDead()).Select(p => p.Get())) { JsonDb.Save(p.AssertGetPlayer()); } }
private static void LoadAllMatches() { var matches = JsonDb.GetMatches(); foreach (var gr in matches.GroupBy(m => m.HomeGoals == m.AwayGoals)) { Console.WriteLine($"{gr.Key} {gr.Count()}"); } }
static void Main(string[] args) { JsonDb db = JsonDb.Create(); db.AddType <Person>(); db.AddType <Account>(); db.AddType <Item>(); db.AddType <Purchase>(); Person person = new Person() { FirstName = "Blood", LastName = "Thirst" }; db.Add(person); Account acc = new Account() { Username = "******", Password = "******", Person = 1 }; db.Add(acc); Item item = new Item() { ItemName = "D***o" }; db.Add(item); Purchase purchase = new Purchase() { Amount = 3, PurchaseDate = DateTime.Now, Item = item, Person = person, }; db.Add(purchase); db.Remove(acc); string json = db.Save(); File.WriteAllText("D:/jsonDb.txt", json); JsonDb loaded = JsonDb.Open(json); }
private static void Main(string[] args) { var db = new All(JsonDb.Load(), JsonNames.LoadNames()); albionParser = new AlbionParser(); albionParser.AddEventHandler<PlayerCounts>(p => { Console.WriteLine($"Players: {p.Blue} / {p.Red}"); }); albionParser.AddOperationHandler<ConsloeCommand>(p => { Console.WriteLine($"LocId: {p.LocId} {p.Town}"); }); // albionParser.AddOperationHandler<AuctionBuyOffer>(p => // { // if (p.Items.Length==0) return; // var items = p.Items.GroupBy(x=>x.ItemTypeId).ToArray(); // foreach (var item in items) // { // var max = item.Max(x => x.UnitPriceSilver) / 10000; // // var ph = db.GetItem(item.Key).PriceHolder; // // ph.UpdateBye(max, items.Length == 1); // } // }); // // albionParser.AddOperationHandler<AuctionGetRequests>(p => // { // if (p.Items.Length == 0) return; // var items = p.Items.GroupBy(x => x.ItemTypeId).ToArray(); // foreach (var item in items) // { // var min = item.Min(x => x.UnitPriceSilver) / 10000; // // var ph = db.GetItem(item.Key).PriceHolder; // // ph.UpdateSell(min, items.Length == 1); // } // }); Console.WriteLine("Start"); albionParser.Start(); Console.Read(); }
static void Main() { // Read table (6 MB of English words). Reads file if exists and serializes to objects. var words = new JsonDb <Word>($"Database/Words.json"); // Search through 370 099 words. Find "*awkward*". foreach (var awkward in words.Where(n => n.W.Contains("awkward")).OrderByDescending(n => n.W).Reverse()) { Console.WriteLine($"Awkward: { awkward.W } "); } // Find "lose*". var losers = from word in words where word.W.StartsWith("lose") orderby word.W ascending select word; // Show "lose*" search results. foreach (var lose in losers) { Console.WriteLine($"Lose: { lose.W } "); } // Reads file if exists and serializes to objects. var items = new JsonDb <Item>($"Database/Items.json"); // Clear previous items. items.Clear(); // Generate 10 000 items. for (int i = 1; i < 10001; i++) { items.Add(new Item() { Id = i, Name = "Item " + i, Content = new string[] { "C 1", "C 2", "C 3" } }); } // Access database item directly and update. items.Where(i => i.Name.Equals("Item 666")).FirstOrDefault().Content = new string[] { "C 1", "C 2", "C 3", "C 4" }; // Write to disk. items.Save(); }
private static void Predict() { var matches = JsonDb.GetMatches(); ILearningScenario <Match> scenario = new LearningScenario <Match>(); scenario.MaxIterations = 1000; scenario.MaxError = 0.1; scenario.InputParams = new List <IParamDefinition <Match> >(); scenario.InputParams.Add(MatchParams.GetLastFiveHomeMatches(matches)); scenario.InputParams.Add(MatchParams.GetLastFiveAwayMatches(matches)); scenario.OutputParams = new List <IParamDefinition <Match> >(); scenario.OutputParams.Add(MatchParams.GetResultValue(matches)); var network = Training.Train(scenario, matches); Prediction.Compute(network, scenario, matches); }
static void ImportAllSeasons() { List <Match> matches = new List <Match>(); string[] seasonUrls = new[] { //2002/2003 "http://www.90minut.pl/liga/0/liga188.html", //2003/2004 "http://www.90minut.pl/liga/0/liga632.html", //2004/2005 "http://www.90minut.pl/liga/0/liga1329.html", //2005/2006 "http://www.90minut.pl/liga/0/liga1944.html", //2006/2007 "http://www.90minut.pl/liga/0/liga2525.html", //2007/2008 "http://www.90minut.pl/liga/0/liga3155.html", //2008/2009 "http://www.90minut.pl/liga/0/liga3782.html", //2009/2010 "http://www.90minut.pl/liga/0/liga4389.html", //2010/2011 "http://www.90minut.pl/liga/0/liga4991.html", //2011/2012 "http://www.90minut.pl/liga/0/liga5617.html", //2012/2013 "http://www.90minut.pl/liga/0/liga6218.html", //2013/2014 "http://www.90minut.pl/liga/0/liga6826.html", //2014/2015 "http://www.90minut.pl/liga/0/liga7466.html", //2015/2016 "http://www.90minut.pl/liga/0/liga8069.html", //2016/2017 "http://www.90minut.pl/liga/0/liga8694.html" }; foreach (string seasonUrl in seasonUrls) { Console.WriteLine(seasonUrl); matches.AddRange(HandleSeason(seasonUrl)); } JsonDb.SaveMatches(matches); }