public bool IsNewCardsDBAvailable() { var requestErrorPolicy = Policy <bool> .Handle <System.Net.WebException>() .Fallback(false); string url = "https://raw.githubusercontent.com/MarioZG/elder-scrolls-legends-tracker/master/Build/versions.json"; return(requestErrorPolicy.Execute(() => { IHTTPService httpService = (IHTTPService)trackerFactory.GetService <IHTTPService>(); string versionJSON = httpService.SendGetRequest(url); JObject versions = JObject.Parse(versionJSON); Version latest = new Version(versions["CardsDB"].ToString()); return latest > trackerFactory.GetCardsDatabase().Version; })); }
private void ImportFromTextProcess(string importData) { foreach (string cardLine in importData.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) { string[] splitedLine = cardLine.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries); int cardCount = GetCardQty(splitedLine); string cardName = GetCardName(splitedLine); Card card = trackerFactory.GetCardsDatabase().FindCardByName(cardName); CardInstance cardInstance = new CardInstance(card, trackerFactory); cardInstance.Quantity = cardCount; Cards.Add(cardInstance); } }
private void ImportFromTextProcess(string importData) { if (importData == null) { return; } foreach (string cardLine in importData.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) { string cardName = cardLine; int cardCount = 1; Regex regex = new Regex("(|-)[0-9]"); Match match = regex.Match(cardName); if (match.Success) { Int32.TryParse(match.Value, out cardCount); cardName = cardLine.Replace(cardCount.ToString(), ""); } Card card = trackerFactory.GetCardsDatabase().FindCardByName(cardName); // TODO: Rework for premium var found = false; foreach (var itr in Cards) { if (itr.Card == card) { found = true; itr.Quantity += cardCount; } } if (!found) { CardInstance cardInstance = new CardInstance(card, trackerFactory); cardInstance.Quantity = cardCount; Cards.Add(cardInstance); } } HashSet <CardInstance> cards_silent = new HashSet <CardInstance>(); new TriggerChanceUpdater.TriggerChanceUpdater(new ObservableCollection <CardInstance>(Cards), cards_silent); DeckFileReader.DeckFileReader.UpdateGui(cards_silent, false); }
private void LoadCardFromDataBase(Guid value) { this.Card = trackerFactory.GetCardsDatabase().FindCardById(value); }