示例#1
0
        //TODO : Need add BotManager to manage all feature related to multibot,
        public bool ReInitSessionWithNextBot(Account bot = null, double lat = 0, double lng = 0, double att = 0)
        {
            CatchBlockTime = DateTime.Now; //remove any block
            MSniperServiceTask.BlockSnipe();
            VisibleForts.Clear();
            Forts.Clear();

            var manager = TinyIoCContainer.Current.Resolve <MultiAccountManager>();
            var session = TinyIoCContainer.Current.Resolve <ISession>();

            var nextBot = manager.GetSwitchableAccount(bot);

            if (nextBot != null)
            {
                manager.SwitchAccounts(nextBot);
            }

            Settings.DefaultAltitude  = att == 0 ? Client.CurrentAltitude : att;
            Settings.DefaultLatitude  = lat == 0 ? Client.CurrentLatitude : lat;
            Settings.DefaultLongitude = lng == 0 ? Client.CurrentLongitude : lng;
            Stats = new SessionStats(this);
            Reset(Settings, LogicSettings);
            //CancellationTokenSource.Cancel();
            CancellationTokenSource = new CancellationTokenSource();

            EventDispatcher.Send(new BotSwitchedEvent(nextBot)
            {
            });

            if (LogicSettings.MultipleBotConfig.DisplayList)
            {
                manager.DumpAccountList();
            }
            return(true);
        }
示例#2
0
 public Session(ISettings settings, ILogicSettings logicSettings)
 {
     Settings        = settings;
     LogicSettings   = logicSettings;
     EventDispatcher = new EventDispatcher();
     Translation     = Common.Translation.Load(logicSettings);
     Reset(settings, LogicSettings);
     Stats = new SessionStats();
 }
示例#3
0
 public Session(ISettings settings, ILogicSettings logicSettings, ITranslation translation)
 {
     Settings        = settings;
     LogicSettings   = logicSettings;
     EventDispatcher = new EventDispatcher();
     Translation     = translation;
     Reset(settings, LogicSettings);
     Stats = new SessionStats();
 }
示例#4
0
        public Session(GlobalSettings globalSettings, ISettings settings, ILogicSettings logicSettings,
                       IElevationService elevationService, ITranslation translation)
        {
            GlobalSettings          = globalSettings;
            CancellationTokenSource = new CancellationTokenSource();
            Forts             = new List <FortData>();
            VisibleForts      = new List <FortData>();
            Cache             = new MemoryCache("NecroBot2");
            accounts          = new List <AuthConfig>();
            EventDispatcher   = new EventDispatcher();
            LogicSettings     = logicSettings;
            RuntimeStatistics = new Statistics();

            ElevationService = elevationService;

            Settings = settings;

            Translation = translation;
            Reset(settings, LogicSettings);
            Stats = new SessionStats(this);

            AnalyticsService = new AnalyticsService();

            accounts.AddRange(logicSettings.Bots);
            if (!accounts.Any(x => x.AuthType == settings.AuthType && x.Username == settings.Username))
            {
                accounts.Add(new AuthConfig()
                {
                    AuthType = settings.AuthType,
                    Password = settings.Password,
                    Username = settings.Username,
                    AutoExitBotIfAccountFlagged = settings.AutoExitBotIfAccountFlagged,
                    AccountLatitude             = settings.AccountLatitude,
                    AccountLongitude            = settings.AccountLongitude,
                    AccountActive = settings.AccountActive,
                    RunStart      = settings.RunStart,
                    RunEnd        = settings.RunEnd,
                });
            }
            if (File.Exists("runtime.log"))
            {
                var lines = File.ReadAllLines("runtime.log");
                foreach (var item in lines)
                {
                    var arr = item.Split(';');
                    var acc = accounts.FirstOrDefault(p => p.Username == arr[0]);
                    if (acc != null)
                    {
                        acc.RuntimeTotal = Convert.ToDouble(arr[1]);
                    }
                }
            }

            GymState = new GymTeamState();
        }
示例#5
0
        public void CleanOutExpiredStats()
        {
            SessionStats.LoadLegacyData(ownerSession);
            var  manager    = TinyIoC.TinyIoCContainer.Current.Resolve <MultiAccountManager>();
            var  db         = manager.GetDbContext();
            long TSminus24h = DateTime.Now.AddHours(-24).Ticks;
            var  pokestopTimestampsToDelete = db.PokestopTimestamp.Where(t => t.Account == manager.GetCurrentAccount() && t.Timestamp < TSminus24h);

            db.PokestopTimestamp.RemoveRange(pokestopTimestampsToDelete);

            var pokemonTimestampsToDelete = db.PokemonTimestamp.Where(t => t.Account == manager.GetCurrentAccount() && t.Timestamp < TSminus24h);

            db.PokemonTimestamp.RemoveRange(pokemonTimestampsToDelete);
            db.SaveChanges();
        }
示例#6
0
        public Session(ISettings settings, ILogicSettings logicSettings, IElevationService elevationService, ITranslation translation)
        {
            this.Forts        = new List <FortData>();
            this.VisibleForts = new List <FortData>();
            this.Cache        = new MemoryCache("Necrobot2");
            EventDispatcher   = new EventDispatcher();
            LogicSettings     = logicSettings;

            this.ElevationService = elevationService;

            Settings = settings;

            Translation = translation;
            Reset(settings, LogicSettings);
            Stats = new SessionStats(this);
        }
示例#7
0
        public Session(ISettings settings, ILogicSettings logicSettings, ITranslation translation)
        {
            EventDispatcher = new EventDispatcher();
            LogicSettings   = logicSettings;

            ElevationService = new ElevationService(this);

            // Update current altitude before assigning settings.
            settings.DefaultAltitude = ElevationService.GetElevation(settings.DefaultLatitude, settings.DefaultLongitude);

            Settings = settings;

            Translation = translation;
            Reset(settings, LogicSettings);
            Stats = new SessionStats();
        }
示例#8
0
        public Session(IClientSettings clientSettings, ILogicSettings logicSettings, ITranslation translation)
        {
            _logger.Debug("--- Starting new Session ---");

            _elevationService = new ElevationService(logicSettings);
            _clientSettings   = clientSettings;
            _stats            = new SessionStats();
            _translation      = translation;
            _logicSettings    = logicSettings;
            _eventDispatcher  = new EventDispatcher();

            // Update current altitude
            ClientSettings.DefaultAltitude = ElevationService.GetElevation(clientSettings.DefaultLatitude, clientSettings.DefaultLongitude);

            UpdateSessionConfiguration(clientSettings, logicSettings);
        }
示例#9
0
        public void AddPokemonTimestamp(Int64 ts)
        {
            SessionStats.LoadLegacyData(ownerSession);
            var manager  = TinyIoC.TinyIoCContainer.Current.Resolve <MultiAccountManager>();
            var db       = manager.GetDbContext();
            var existing = db.PokemonTimestamp.Where(t => t.Timestamp == ts).FirstOrDefault();

            if (existing == null)
            {
                var currentAccount = manager.GetCurrentAccount();

                var stat = new Model.PokemonTimestamp
                {
                    Timestamp = ts,
                    Account   = manager.GetCurrentAccount()
                };
                db.PokemonTimestamp.Add(stat);
                db.SaveChanges();
            }
        }
示例#10
0
        //TODO : Need add BotManager to manage all feature related to multibot,
        public bool ReInitSessionWithNextBot(Account bot = null, double lat = 0, double lng = 0, double att = 0)
        {
            CatchBlockTime = DateTime.Now; //remove any block
            MSniperServiceTask.BlockSnipe();
            VisibleForts.Clear();
            Forts.Clear();

            var manager = TinyIoCContainer.Current.Resolve <MultiAccountManager>();
            var session = TinyIoCContainer.Current.Resolve <ISession>();
            var nextBot = manager.GetSwitchableAccount(bot);
            var Account = !string.IsNullOrEmpty(nextBot.Nickname) ? nextBot.Nickname : nextBot.Username;
            var TotXP   = 0;

            for (int i = 0; i < nextBot.Level + 1; i++)
            {
                TotXP = TotXP + Statistics.GetXpDiff(i);
            }

            long?XP = nextBot.CurrentXp;

            if (XP == null)
            {
                XP = 0;
            }
            long?SD = nextBot.Stardust;

            if (SD == null)
            {
                SD = 0;
            }
            long?Lvl = nextBot.Level;

            if (Lvl == null)
            {
                Lvl = 0;
            }
            var NLevelXP = nextBot.NextLevelXp;

            if (nextBot.NextLevelXp == null)
            {
                NLevelXP = 0;
            }

            Logger.Write($"Account changed to {Account}", LogLevel.BotStats);

            if (session.LogicSettings.NotificationConfig.EnablePushBulletNotification)
            {
                PushNotificationClient.SendNotification(session, $"Account changed to", $"{Account}\n" +
                                                        $"Lvl: {Lvl}\n" +
                                                        $"XP : {XP:#,##0}({(double)XP / ((double)NLevelXP) * 100:#0.00}%)\n" +
                                                        $"SD : {SD:#,##0}", true).ConfigureAwait(false);
            }

            if (nextBot != null)
            {
                manager.SwitchAccounts(nextBot);
            }

            Settings.DefaultAltitude  = att == 0 ? Client.CurrentAltitude : att;
            Settings.DefaultLatitude  = lat == 0 ? Client.CurrentLatitude : lat;
            Settings.DefaultLongitude = lng == 0 ? Client.CurrentLongitude : lng;
            Stats = new SessionStats(this);
            Reset(Settings, LogicSettings);
            //CancellationTokenSource.Cancel();
            CancellationTokenSource = new CancellationTokenSource();

            EventDispatcher.Send(new BotSwitchedEvent(nextBot)
            {
            });

            if (LogicSettings.MultipleBotConfig.DisplayList)
            {
                manager.DumpAccountList();
            }
            return(true);
        }