Exemple #1
0
 public UtilColors(CacheSingleton <Dictionary <int, Card> > allCards)
 {
     //var value = allCards.Get();
     //if (value != null)
     //    dictAllCards = value.ToDictionary(i => i.grpId, i => i);
     dictAllCards = allCards.Get();
 }
        public AutoMapperRawDeckConverter(CacheSingleton <Dictionary <int, Card> > cacheCards, RawDeckConverter converter)
        {
            //if (allCards == null)
            //    System.Diagnostics.Debugger.Break();

            this.allCards  = cacheCards.Get();
            this.converter = converter;
        }
 public MtgaOutputLogResultsPreparer(
     CacheSingleton <Dictionary <int, Card> > cacheCards,
     IMapper mapper,
     IEventTypeCache eventsScheduleManager)
 {
     dictAllCards = cacheCards.Get();
     this.mapper  = mapper;
     this.eventsScheduleManager = eventsScheduleManager;
     Reset();
 }
 public DraftCardsPicker(
     DraftPicksCalculator draftPicksCalculator,
     IMapper mapper,
     CacheSingleton <Dictionary <string, DraftRatings> > draftRatings
     )
 {
     DraftPicksCalculator = draftPicksCalculator;
     this.mapper          = mapper;
     this.draftRatings    = draftRatings;
 }
Exemple #5
0
 public MtgaOutputLogResultsPreparer2(
     //IOptionsMonitor<ConfigModelApp> configApp,
     CacheSingleton <Dictionary <int, Card> > cacheCards,
     IEventTypeCache eventsScheduleManager)
 {
     //this.configApp = configApp.CurrentValue;
     dictAllCards = cacheCards.Get();
     this.eventsScheduleManager = eventsScheduleManager;
     Reset();
 }
Exemple #6
0
        public MapperProfileEntity(CacheSingleton <Dictionary <int, Card> > cacheCards)
        {
            var dictAllCards = cacheCards.Get();

            // grpId to Card
            CreateMap <int, Card>().ConvertUsing(i => dictAllCards.ContainsKey(i) ? dictAllCards[i] :
                                                 new Card
            {
                grpId        = 0,
                name         = "Unknown",
                imageCardUrl = "https://cdn11.bigcommerce.com/s-0kvv9/images/stencil/1280x1280/products/266486/371622/classicmtgsleeves__43072.1532006814.jpg?c=2&imbypass=on"
            });

            //CreateMap<MtgaDeck, ConfigModelRawDeck>();

            CreateMap <KeyValuePair <int, int>, CardWithAmount>()
            .ConvertUsing(i => new CardWithAmount(dictAllCards[i.Key], i.Value));

            CreateMap <QuestUpdate, PlayerQuest>();
            CreateMap <TrackDiff, PlayerProgress>();
            CreateMap <DraftMakePickRaw, DraftPickProgress>();

            CreateMap <ConfigModelRawDeck, ConfigModelDeck>()
            .ForMember(i => i.ScraperTypeId, i => i.MapFrom(x => Constants.USERDECK_SOURCE_MTGADECK))
            .ForMember(i => i.UrlDeckList, i => i.MapFrom(x => (string)null));

            CreateMap <RankUpdatedRaw, Rank>()
            .ForMember(i => i.Format, i => i.MapFrom(x => Enum.Parse(typeof(RankFormatEnum), x.rankUpdateType)))
            .ForMember(i => i.Class, i => i.MapFrom(x => x.newClass))
            .ForMember(i => i.Level, i => i.MapFrom(x => x.newLevel))
            .ForMember(i => i.Step, i => i.MapFrom(x => x.newStep));

            CreateMap <CardRequiredInfoByCard, CardCompareInfo>()
            .ForMember(i => i.GrpId, i => i.MapFrom(x => x.Card.grpId))
            .ForMember(i => i.MissingWeight, i => i.MapFrom(x => x.MissingWeight))
            .ForMember(i => i.NbDecksMain, i => i.MapFrom(x => x.ByDeck.Count(y => y.Value.NbMissingMain > 0)))
            .ForMember(i => i.NbDecksSideboardOnly, i => i.MapFrom(x => x.NbDecks - x.ByDeck.Count(y => y.Value.NbMissingMain > 0)))
            .ForMember(i => i.NbMissing, i => i.MapFrom(x => x.NbMissing));

            CreateMap <Card, CardForDraftPick>()
            .ForMember(i => i.Rating, i => i.Ignore())
            .ForMember(i => i.Description, i => i.Ignore())
            .ForMember(i => i.Weight, i => i.Ignore())
            .ForMember(i => i.NbDecksUsedMain, i => i.Ignore())
            .ForMember(i => i.NbDecksUsedSideboard, i => i.Ignore())
            .ForMember(i => i.IsRareDraftPick, i => i.Ignore())
            .ForMember(i => i.NbMissingTrackedDecks, i => i.Ignore())
            .ForMember(i => i.NbMissingCollection, i => i.Ignore())
            .ForMember(i => i.TopCommonCard, i => i.Ignore());
        }
Exemple #7
0
 public AutoMapperGrpIdToCardConverter(CacheSingleton <Dictionary <int, Card> > cacheCards)
 {
     this.dictAllCards = cacheCards.Get();
 }
 public UtilColors(CacheSingleton <Dictionary <int, Card> > allCards)
 {
     dictAllCards = allCards.Get();
 }
Exemple #9
0
 public InGameTracker2(CacheSingleton <Dictionary <int, Card> > cardsSingleton)
 {
     cardsByGrpId = cardsSingleton.Get();
 }
        public MainWindow(
            ConfigModel configApp,
            ICollection <Card> allCards,
            MainWindowVM viewModel,
            ProcessMonitor processMonitor,
            LogFileZipper zipper,
            ServerApiCaller api,
            StartupShortcutManager startupManager,
            LogSplitter logSplitter,
            MtgaResourcesLocator resourcesLocator,
            FileMonitor fileMonitor,
            DraftCardsPicker draftHelper,
            ReaderMtgaOutputLog readerMtgaOutputLog,
            InGameTracker2 inMatchTracker,
            ExternalProviderTokenManager tokenManager,
            PasswordHasher passwordHasher,
            CacheSingleton <Dictionary <string, DraftRatings> > draftRatings,
            DraftHelperRunner draftHelperRunner)
        {
            // Set the config model reference
            ConfigModel = configApp;


            Reader = readerMtgaOutputLog;
            processMonitor.OnProcessMonitorStatusChanged += OnProcessMonitorStatusChanged;
            Zipper           = zipper;
            Api              = api;
            StartupManager   = startupManager;
            LogSplitter      = logSplitter;
            ResourcesLocator = resourcesLocator;
            FileMonitor      = fileMonitor;
            fileMonitor.OnFileSizeChangedNewText += OnFileSizeChangedNewText;
            DraftHelper = draftHelper;
            //this.logProcessor = logProcessor;
            InGameTracker     = inMatchTracker;
            TokenManager      = tokenManager;
            PasswordHasher    = passwordHasher;
            DraftRatings      = draftRatings;
            DraftHelperRunner = draftHelperRunner;
            ResourcesLocator.LocateLogFilePath(ConfigModel);
            ResourcesLocator.LocateGameClientFilePath(ConfigModel);

            fileMonitor.SetFilePath(ConfigModel.LogFilePath);

            // Set the view model
            MainWindowVM = viewModel;

            // Set the data context to the view model
            DataContext = MainWindowVM;

            InitializeComponent();

            WelcomeControl.Init(tokenManager);
            PlayingControl.Init(MainWindowVM);
            StatusBarTop.Init(this, MainWindowVM);
            ReadyControl.Init(ConfigModel.GameFilePath);
            DraftingControl.Init(allCards, MainWindowVM.DraftingVM);

            DraftingControl.SetPopupRatingsSource(ConfigModel.ShowLimitedRatings, ConfigModel.ShowLimitedRatingsSource);

            processMonitor.Start(new System.Threading.CancellationToken());

            FileMonitor.Start(new System.Threading.CancellationToken());

            var timer = new DispatcherTimer {
                Interval = TimeSpan.FromMilliseconds(200)
            };

            timer.Tick += (sender, e) =>
            {
                MainWindowVM.SetCardsDraftFromBuffered();
                MainWindowVM.SetCardsInMatchTrackingFromBuffered();
            };
            timer.Start();

            var timerTokenRefresh = new DispatcherTimer {
                Interval = TimeSpan.FromMinutes(9)
            };

            timerTokenRefresh.Tick += (sender, e) =>
            {
                RefreshAccessToken();
            };
            timerTokenRefresh.Start();
        }
 public AutoMapperRawDeckToColorConverter(CacheSingleton <Dictionary <int, Card> > cacheCards, UtilColors utilColors)
 {
     this.dictAllCards = cacheCards.Get();
     this.utilColors   = utilColors;
 }
        public MainWindowVM(StatusBlinker statusBlinker, InMatchTrackerStateVM inMatchState, ConfigModel config, DraftingVM draftingVM,
                            IMapper mapper,
                            ICacheLoader <Dictionary <int, Set> > cacheSets,
                            ProcessMonitor processMonitor,
                            ServerApiCaller api,
                            StartupShortcutManager startupManager,
                            MtgaResourcesLocator resourcesLocator,
                            FileMonitor fileMonitor,
                            DraftCardsPicker draftHelper,
                            ReaderMtgaOutputLog readerMtgaOutputLog,
                            InGameTracker2 inMatchTracker,
                            ExternalProviderTokenManager tokenManager,
                            PasswordHasher passwordHasher,
                            CacheSingleton <Dictionary <string, DraftRatings> > draftRatings,
                            DraftHelperRunner draftHelperRunner,
                            //IEmailProvider emailProvider,
                            ICollection <Card> allCards,
                            CardThumbnailDownloader cardThumbnailDownloader,
                            ServerApiCaller serverApiCaller
                            )
        {
            // Set the status blinker reference
            StatusBlinker = statusBlinker;
            // Set the network status emission handler
            StatusBlinker.EmitStatus += status => { NetworkStatus = status; };

            Sets                               = cacheSets.LoadData().Values.ToArray();
            InMatchState                       = inMatchState;
            Config                             = config;
            DraftingVM                         = draftingVM;
            Mapper                             = mapper;
            ProcessMonitor                     = processMonitor;
            Api                                = api;
            StartupManager                     = startupManager;
            ResourcesLocator                   = resourcesLocator;
            FileMonitor                        = fileMonitor;
            DraftHelper                        = draftHelper;
            ReaderMtgaOutputLog                = readerMtgaOutputLog;
            InMatchTracker                     = inMatchTracker;
            InMatchState.GameEnded            += OnGameEnded;
            InMatchState.OpponentCardsUpdated += OnOpponentCardsUpdated;

            TokenManager      = tokenManager;
            PasswordHasher    = passwordHasher;
            DraftRatings      = draftRatings;
            DraftHelperRunner = draftHelperRunner;
            //this.emailProvider = emailProvider;
            AllCards = allCards;
            CardThumbnailDownloader = cardThumbnailDownloader;
            this.serverApiCaller    = serverApiCaller;

            // Set the library order from the config
            OrderLibraryCardsBy = config.OrderLibraryCardsBy == "Converted Mana Cost"
                ? CardsListOrder.ManaCost
                : CardsListOrder.DrawChance;

            // Create the opponent window view model
            OpponentWindowVM = new OpponentWindowVM("Opponent Cards", this, serverApiCaller);

            // Subscribe to property changes
            PropertyChanged += OnPropertyChanged;

            // Set the animated icon state
            AnimatedIcon = Config?.AnimatedIcon ?? false;

            // Set the initial window settings
            PositionTop   = WindowSettings?.Position.Y ?? 0;
            PositionLeft  = WindowSettings?.Position.X ?? 0;
            WindowOpacity = WindowSettings?.Opacity ?? 0.9;
            WindowTopmost = WindowSettings?.Topmost ?? true;

            // Set the initial window size
            WindowWidth = WindowSettings != null && WindowSettings.Size.X > double.Epsilon
                ? WindowSettings.Size.X
                : 340;
            WindowHeight = WindowSettings != null && WindowSettings.Size.Y > double.Epsilon
                ? WindowSettings.Size.Y
                : 500;
        }
Exemple #13
0
        /// <summary>
        /// Complete constructor
        /// </summary>
        public MainWindow(MainWindowVM viewModel)
        {
            mapper    = viewModel.Mapper;
            ViewModel = viewModel;

            // Set the main window view model actions
            ViewModel.UploadLogAction    = UploadLogAction;
            ViewModel.ShowOptionsAction  = ShowOptionsWindow;
            ViewModel.LaunchArenaAction  = LaunchArenaAction;
            ViewModel.ValidateUserAction = ValidateUserAction;

            // Set the resource locator
            ResourcesLocator = viewModel.ResourcesLocator;

            // Set the problem action
            ResourcesLocator.SetProblem = ViewModel.SetProblem;

            // Locate the log file
            ResourcesLocator.LocateLogFilePath(ViewModel.Config);

            // Locate the game path
            ResourcesLocator.LocateGameClientFilePath(ViewModel.Config);

            // Set the reference to the draft helper
            DraftHelperRunner = viewModel.DraftHelperRunner;


            Reader         = viewModel.ReaderMtgaOutputLog;
            Api            = viewModel.Api;
            StartupManager = viewModel.StartupManager;
            FileMonitor    = viewModel.FileMonitor;
            FileMonitor.OnFileSizeChangedNewText += OnFileSizeChangedNewText;
            DraftHelper = viewModel.DraftHelper;
            //this.logProcessor = logProcessor;
            InGameTracker  = viewModel.InMatchTracker;
            TokenManager   = viewModel.TokenManager;
            PasswordHasher = viewModel.PasswordHasher;
            DraftRatings   = viewModel.DraftRatings;

            FileMonitor.SetFilePath(ViewModel.Config.LogFilePath);

            // Set the data context to the view model
            DataContext = ViewModel;

            InitializeComponent();

            PlayingControl.Init(ViewModel);
            DraftingControl.Init(ViewModel.DraftingVM, ViewModel.Config.LimitedRatingsSource);
            DraftingControl.SetPopupRatingsSource(ViewModel.Config.ShowLimitedRatings, ViewModel.Config.LimitedRatingsSource);

            // Set the process monitor status changed action
            viewModel.ProcessMonitor.OnProcessMonitorStatusChanged = OnProcessMonitorStatusChanged;

            // Start the process monitor without awaiting the task completion
            _ = viewModel.ProcessMonitor.Start(new System.Threading.CancellationToken());

            // Start the file monitor without awaiting the task completion
            _ = FileMonitor.Start(new System.Threading.CancellationToken());

            var timer = new DispatcherTimer {
                Interval = TimeSpan.FromMilliseconds(200)
            };

            timer.Tick += (sender, e) =>
            {
                ViewModel.DraftingVM.SetCardsDraftFromBuffered();
                ViewModel.InMatchState.SetInMatchStateFromBuffered();
            };
            timer.Start();

            var timerTokenRefresh = new DispatcherTimer {
                Interval = TimeSpan.FromMinutes(9)
            };

            timerTokenRefresh.Tick += (sender, e) =>
            {
                RefreshAccessToken();
            };
            timerTokenRefresh.Start();
        }
Exemple #14
0
 public InGameTracker2(CacheSingleton <Dictionary <int, Card> > cardsSingleton, GameEventFactory eventFactory)
 {
     evt          = eventFactory;
     cardsByGrpId = cardsSingleton.Get();
     State        = new InGameTrackerState2(eventFactory);
 }
Exemple #15
0
 public AutoMapperIntToCardArtConverter(CacheSingleton <Dictionary <int, Card> > cache)
 {
     this.cards = cache.Get();
 }
 static ImageCache() {
     imageCache = CacheSingleton<Image>.GetInstance();
     imageCache.OnCallFactory += new CacheableObjectFactory(ImageCache_OnCallFactory);
 }
Exemple #17
0
        public MainWindow(
            //OptionsWindow optionsWindow,
            IOptionsMonitor <ConfigModelApp> configApp,
            ICollection <Card> allCards,
            MainWindowVM viewModel,
            ProcessMonitor processMonitor,
            LogFileZipper zipper,
            ServerApiCaller api,
            StartupShortcutManager startupManager,
            LogSplitter logSplitter,
            MtgaResourcesLocator resourcesLocator,
            FileMonitor fileMonitor,
            DraftHelper draftHelper,
            //LogProcessor logProcessor,
            ReaderMtgaOutputLog readerMtgaOutputLog,
            //CacheSingleton<ICollection<Card>> allCards,
            InGameTracker inMatchTracker,
            ExternalProviderTokenManager tokenManager,
            PasswordHasher passwordHasher,
            NotifyIconManager notifyIconManager,
            CacheSingleton <Dictionary <string, DraftRatings> > draftRatings
            )
        {
            this.configApp = configApp.CurrentValue;
            //optionsWindow.Init(this.configApp);
            //optionsWindow.Owner = Window.GetWindow(this);
            //this.optionsWindow = optionsWindow;

            this.reader         = readerMtgaOutputLog;
            this.processMonitor = processMonitor;
            processMonitor.OnProcessMonitorStatusChanged += OnProcessMonitorStatusChanged;
            this.zipper           = zipper;
            this.api              = api;
            this.startupManager   = startupManager;
            this.logSplitter      = logSplitter;
            this.resourcesLocator = resourcesLocator;
            this.fileMonitor      = fileMonitor;
            fileMonitor.OnFileSizeChangedNewText += OnFileSizeChangedNewText;
            this.draftHelper = draftHelper;
            //this.logProcessor = logProcessor;
            this.inGameTracker     = inMatchTracker;
            this.tokenManager      = tokenManager;
            this.passwordHasher    = passwordHasher;
            this.notifyIconManager = notifyIconManager;
            this.draftRatings      = draftRatings;
            this.resourcesLocator.LocateLogFilePath(this.configApp);
            this.resourcesLocator.LocateGameClientFilePath(this.configApp);

            fileMonitor.SetFilePath(this.configApp.LogFilePath);
            //viewModel.ValidateUserId(this.configApp.UserId);
            viewModel.Opacity = this.configApp.Opacity;
            vm          = viewModel;
            DataContext = vm;

            InitializeComponent();

            ucWelcome.Init(tokenManager);
            ucPlaying.Init(vm, this.configApp.WindowSettingsOpponentCards);

            //trayIcon = new System.Windows.Forms.NotifyIcon { Text = "MTGAHelper Tracker" };
            //trayIcon.Icon = new System.Drawing.Icon(Application.GetResourceStream(new Uri("pack://application:,,,/Assets/Images/wcC.ico")).Stream);
            //trayIcon.MouseClick += new System.Windows.Forms.MouseEventHandler(TrayIcon_MouseClick);
            //trayIcon.ContextMenu = new System.Windows.Forms.ContextMenu(new System.Windows.Forms.MenuItem[]
            //{
            //    new System.Windows.Forms.MenuItem("Quit", new EventHandler(TrayIcon_Quit))
            //});

            statusBarTop.Init(this, vm /*, draftHelper, logProcessor, this.configApp.UserId,*/);
            ucReady.Init(this.configApp.GameFilePath);
            ucDraftHelper.Init(allCards, vm.DraftingVM);
            //ucPlaying.Init(vm);

            ucDraftHelper.SetPopupRatingsSource(this.configApp.ShowLimitedRatings, this.configApp.ShowLimitedRatingsSource);

            this.processMonitor.Start(new System.Threading.CancellationToken());
            this.fileMonitor.Start(new System.Threading.CancellationToken());

            var timer = new DispatcherTimer {
                Interval = TimeSpan.FromMilliseconds(200)
            };

            timer.Tick += (object sender, EventArgs e) =>
            {
                vm.SetCardsDraftFromBuffered();
                vm.SetCardsInMatchTrackingFromBuffered();
            };
            timer.Start();

            var timerTokenRefresh = new DispatcherTimer {
                Interval = TimeSpan.FromMinutes(9)
            };

            timerTokenRefresh.Tick += (object sender, EventArgs e) =>
            {
                RefreshAccessToken();
            };
            timerTokenRefresh.Start();
        }
Exemple #18
0
 public SessionCacheHandler(CacheSingleton cache)
 {
     _cache = cache;
 }
 public AutoMapperCollationToSetConverter(CacheSingleton <Dictionary <int, Set> > cacheSetsByCollation)
 {
     this.cache = cacheSetsByCollation;
 }
 public DeckListConverter(CacheSingleton <Dictionary <int, Card> > cacheCards)
 {
     dictAllCards = cacheCards.Get();
 }
Exemple #21
0
 public RawDeckConverter(CacheSingleton <Dictionary <int, Card> > allCards)
 {
     this.allCards = allCards.Get();
 }