Example #1
0
        public MetaStats(MetaConfig conf)
        {
            try
            {
                //_mainWindow = new OpDeckWindow();

                _appConfig           = conf;
                _opponentCardsPlayed = new List <Card>();
                bool showBubble = false;

                if (showBubble)
                {
                    try
                    {
                        NotificationWindow notify = new NotificationWindow();
                        notify.Show();
                    }
                    catch (Exception ex)
                    {
                        MetaLog.Error(ex);
                    }
                }

                MetaLog.Initialize();

                MetaLog.Info("Meta Stats Initialized", "MetaStats");
            }
            catch (Exception ex)
            {
                MetaLog.Error(ex);
            }
        }
        public void OnLoad()
        {
            try
            {
                if (!Directory.Exists(pluginDir))
                {
                    Directory.CreateDirectory(pluginDir);
                }

                _appConfig = MetaConfig.Load();
                _appConfig.Save();

                _MetaStats            = new MetaStats(_appConfig);
                _MetaDetectorMenuItem = new PluginMenu(_appConfig.userKey);

                GameEvents.OnGameStart.Add(_MetaStats.GameStart);
                GameEvents.OnGameEnd.Add(_MetaStats.GameEnd);

                GameEvents.OnTurnStart.Add(_MetaStats.TurnStart);

                GameEvents.OnOpponentPlay.Add(_MetaStats.OpponentPlay);
                GameEvents.OnOpponentDraw.Add(_MetaStats.OpponentDraw);

                GameEvents.OnOpponentCreateInPlay.Add(_MetaStats.OpponentCreateInPlay);
                GameEvents.OnOpponentCreateInDeck.Add(_MetaStats.OpponentCreateInDeck);
                GameEvents.OnOpponentHeroPower.Add(_MetaStats.OpponentHeroPower);
                GameEvents.OnOpponentSecretTriggered.Add(_MetaStats.OpponentSecretTriggered);
                GameEvents.OnOpponentPlayToGraveyard.Add(_MetaStats.OpponentPlayToGraveyard);
                GameEvents.OnOpponentMulligan.Add(_MetaStats.OpponentMulligan);

                GameEvents.OnPlayerDraw.Add(_MetaStats.PlayerDraw);
                GameEvents.OnPlayerPlay.Add(_MetaStats.PlayerPlay);
                GameEvents.OnPlayerCreateInPlay.Add(_MetaStats.PlayerCreateInPlay);
                GameEvents.OnPlayerCreateInDeck.Add(_MetaStats.PlayerCreateInDeck);
                GameEvents.OnPlayerHeroPower.Add(_MetaStats.PlayerHeroPower);
                GameEvents.OnPlayerMulligan.Add(_MetaStats.PlayerMulligan);

                CheckForUpdate();

                //_MainWindow.Show();
                //_MainWindow.Visibility = System.Windows.Visibility.Hidden;
                MetaLog.Info("Plugin Load Successful");
            }
            catch (Exception ex)
            {
                MetaLog.Error(ex);
                MetaLog.Info("Plugin Load Unsuccessful");
            }
        }
Example #3
0
        public static MetaConfig Load()
        {
            var userAddr =
                (
                    from nic in NetworkInterface.GetAllNetworkInterfaces()
                    where nic.OperationalStatus == OperationalStatus.Up
                    select nic.GetPhysicalAddress().ToString()
                ).FirstOrDefault();

            userAddr = System.Convert.ToBase64String(Encoding.UTF8.GetBytes(userAddr));

            try
            {
                if (File.Exists(configPath))
                {
                    var serializer = new XmlSerializer(typeof(MetaConfig));

                    using (var reader = new StreamReader(configPath))
                    {
                        MetaConfig temp = (MetaConfig)serializer.Deserialize(reader);
                        if (temp.userKey == null)
                        {
                            temp.userKey = userAddr;
                        }
                        return(temp);
                    }
                }
                else
                {
                    return(new MetaConfig("1", DateTime.Now, DateTime.Now, userAddr));
                }
            }
            catch (Exception ex)
            {
                MetaLog.Error(ex);
                return(new MetaConfig("1", DateTime.Now, DateTime.Now, userAddr));
                //return null;
            }
        }