public void SaveDeck(ITracker tracker, SerializableVersion versionIncrease, IEnumerable <CardInstance> cardsCollection) { ErrorMessage = String.Empty; if (Deck.Class == null) { ErrorMessage = "Please select deck class"; return; } if (versionIncrease == new SerializableVersion(0, 0)) { //overwrite //we were working on current version - do nothing } else { //save current cards List <CardInstance> cards = new List <CardInstance>(Deck.SelectedVersion.Cards); //undo changes in curr version //Deck.SelectedVersion points to curret latest Deck.SelectedVersion.Cards = savedState.History.Where(dv => dv.VersionId == Deck.SelectedVersionId).First().Cards; //create new verson wih new cards int major, minor; if (versionIncrease.Major == 1) { major = versionIncrease.Major + GetMaxMajor(); minor = 0; } else if (versionIncrease.Minor == 1) { major = Deck.SelectedVersion.Version.Major; minor = versionIncrease.Minor + GetMaxMinor(major); } else { throw new ArgumentOutOfRangeException(nameof(versionIncrease), "Method accepts only version increase by 0 or 1"); } Deck.CreateVersion( major, minor, trackerFactory.GetDateTimeNow()); //now Deck.SelectedVersion points to new version foreach (CardInstance ci in cards) { Deck.SelectedVersion.Cards.Add((CardInstance)ci.Clone()); } } if (!tracker.Decks.Contains(this.Deck)) { tracker.Decks.Add(this.Deck); } trackerFactory.GetFileManager().SaveDatabase(); this.EndEdit(); messanger.Send(new Utils.Messages.EditDeck() { Deck = this.Deck }, Utils.Messages.EditDeck.Context.EditFinished); }
public string GetScreenShotName(ScreenShotType type, string nameTemplate) { switch (type) { case ScreenShotType.Regular: nameTemplate = nameTemplate.Replace("{d", "{0"); return(string.Format(nameTemplate, trackerFactory.GetDateTimeNow())); case ScreenShotType.Pack: nameTemplate = nameTemplate.Replace("{d", "{0").Replace("{n", "{1"); return(string.Format(nameTemplate, trackerFactory.GetDateTimeNow(), trackerFactory.GetTracker().Packs.Count)); default: throw new NotImplementedException("Unknown screenshot type" + type); } }
internal void UpdateGameData(GameOutcome?outcome) { this.Game.Deck = tracker.ActiveDeck; this.Game.DeckVersionId = tracker.ActiveDeck.SelectedVersionId; this.Game.Outcome = outcome.Value; this.Game.Date = trackerFactory.GetDateTimeNow(); //game date - when it concluded (we dont know when it started) FileVersionInfo fvi = winApi.GetEslFileVersionInfo(); if (fvi != null) { this.Game.ESLVersion = new SerializableVersion(fvi.FileMajorPart, fvi.FileMinorPart, fvi.FileBuildPart, fvi.FilePrivatePart); } else { this.Game.ESLVersion = tracker.Games .Where(g => g.ESLVersion != null) .OrderByDescending(g => g.Date) .Select(g => g.ESLVersion) .FirstOrDefault(); } if (this.Game.Type == GameType.PlayRanked) { if (Game.OpponentRank != PlayerRank.TheLegend) { this.Game.OpponentLegendRank = null; } if (this.Game.PlayerRank != PlayerRank.TheLegend) { this.Game.PlayerLegendRank = null; } settings.PlayerRank = this.Game.PlayerRank.Value; } }
internal Deck(ITrackerFactory tracker) { DeckId = tracker.GetNewGuid(); //if deserialise, will be overriten!, if new generate! DateTime createdDateTime = tracker.GetDateTimeNow(); CreatedDate = createdDateTime; this.trackerFactory = tracker; }
public static Deck CreateNewDeck(ITrackerFactory trackerFactory, string deckName = "") { #pragma warning disable CS0618 // Type or member is obsolete Deck deck = new Deck(trackerFactory); #pragma warning restore CS0618 // Type or member is obsolete deck.CreateVersion(1, 0, trackerFactory.GetDateTimeNow()); deck.Name = deckName; return(deck); }
public void DoneClicked(object param) { var newRewards = Rewards.Where(r => !tracker.Rewards.Contains(r)); //fix up excaly same date DateTime date = trackerFactory.GetDateTimeNow(); foreach (Reward r in newRewards) { r.Date = date; } trackerFactory.GetTracker().Rewards.AddRange(newRewards); trackerFactory.GetFileManager().SaveDatabase(); Rewards.Clear(); RewardReason = null; }
public void DoneClicked(object param) { var newRewards = RewardsAdded.Where(r => !tracker.Rewards.Contains(r)); //fix up excaly same date DateTime date = trackerFactory.GetDateTimeNow(); foreach (Reward r in newRewards) { r.Date = date; r.ArenaDeck = ArenaDeck; } trackerFactory.GetTracker().Rewards.AddRange(newRewards); trackerFactory.GetFileManager().SaveDatabase(); rewards.Clear(); rewards = new PropertiesObservableCollection <Reward>(CreateEmptySet(), Rewards_CollectionChanged); RewardReason = null; RefreshRewardLists(); }
public void SetDateFilters(PredefinedDateFilter value) { DateTime today = trackerFactory.GetDateTimeNow().Date; switch (value) { case PredefinedDateFilter.All: filterDateFrom = null; filterDateTo = null; break; case PredefinedDateFilter.Today: filterDateFrom = today.Date; filterDateTo = today.Date; break; case PredefinedDateFilter.Last7Days: filterDateFrom = today.AddDays(-6); filterDateTo = today.Date; break; case PredefinedDateFilter.ThisMonth: filterDateFrom = new DateTime(today.Year, today.Month, 1); filterDateTo = new DateTime(today.Year, today.Month, DateTime.DaysInMonth(today.Year, today.Month)); break; case PredefinedDateFilter.PreviousMonth: today = today.AddMonths(-1); //as we can change year in process! filterDateFrom = new DateTime(today.Year, today.Month, 1); filterDateTo = new DateTime(today.Year, today.Month, DateTime.DaysInMonth(today.Year, today.Month)); break; default: break; } }
internal Reward(ITrackerFactory factory) { Date = factory.GetDateTimeNow(); }
public Game(ITrackerFactory factory) { Date = factory.GetDateTimeNow(); }