public void CanRefreshAddToExistingTweetsCollection()
        {
            // setup twitter api mock return values
            Statuses statuses = new Statuses();
            statuses.Add(new Status { Id = "000", CreatedAt = DateTime.Today });
            statuses.Add(new Status { Id = "111", CreatedAt = DateTime.Today.AddDays(-2) });
            statuses.Add(new Status { Id = "222", CreatedAt = DateTime.Today.AddDays(-4) });

            // add some tweets to tweet manager
            _tweetsManager.All.Add(new Status { Id = "888", CreatedAt = DateTime.Today.AddDays(-10) });
            _tweetsManager.All.Add(new Status { Id = "999", CreatedAt = DateTime.Today.AddDays(-12) });

            // record
            Expect.Call(_twitterApiClient.FriendsTimelineSince("888")).Return(statuses);

            // playback
            _mocks.ReplayAll();
            _tweetsManager.Refresh();

            // assert
            Assert.AreEqual(5, _tweetsManager.All.Count);
            Assert.AreEqual("000", _tweetsManager.All[0].Id);
            Assert.AreEqual("111", _tweetsManager.All[1].Id);
            Assert.AreEqual("222", _tweetsManager.All[2].Id);
            Assert.AreEqual("888", _tweetsManager.All[3].Id);
            Assert.AreEqual("999", _tweetsManager.All[4].Id);
            _mocks.VerifyAll();
        }
        public void CanRefreshAllReplaceAllTweetsWhenTweetsCollectionIsEmpty()
        {
            // setup twitter api mock return values
            Statuses statuses = new Statuses();

            statuses.Add(new Status {
                Id = "000", CreatedAt = DateTime.Today
            });
            statuses.Add(new Status {
                Id = "111", CreatedAt = DateTime.Today.AddDays(-2)
            });
            statuses.Add(new Status {
                Id = "222", CreatedAt = DateTime.Today.AddDays(-4)
            });

            // record
            Expect.Call(_twitterApiClient.FriendsTimeline()).Return(statuses);

            // playback
            _mocks.ReplayAll();
            _tweetsManager.RefreshAll();

            // assert
            Assert.AreEqual(3, _tweetsManager.All.Count);
            Assert.AreEqual("000", _tweetsManager.All[0].Id);
            Assert.AreEqual("111", _tweetsManager.All[1].Id);
            Assert.AreEqual("222", _tweetsManager.All[2].Id);
            _mocks.VerifyAll();
        }
Пример #3
0
 public virtual void Update(Point position)
 {
     if (CurrentGame.Map.GetCell(position).LightLevel >= LightLevel.Blinding)
     {
         Statuses.Add(new BlindObjectStatus());
     }
 }
Пример #4
0
        private void LoadStatus(string sampleDataPath, TimeSpan offset)
        {
            var files = System.IO.Directory.GetFiles(sampleDataPath, "status-*.json");

            foreach (var f in files)
            {
                var name = System.IO.Path.GetFileNameWithoutExtension(f).Replace("status-", "");

                var statusJson = System.IO.File.ReadAllText(f);
                var curSt      = (BlackMaple.MachineWatchInterface.CurrentStatus)JsonConvert.DeserializeObject(
                    statusJson,
                    typeof(BlackMaple.MachineWatchInterface.CurrentStatus),
                    _jsonSettings
                    );
                curSt.TimeOfCurrentStatusUTC = curSt.TimeOfCurrentStatusUTC.Add(offset);

                foreach (var uniq in curSt.Jobs.Keys)
                {
                    MockServerBackend.OffsetJob(curSt.Jobs[uniq], offset);
                }
                Statuses.Add(name, curSt);
            }

            string statusFromEnv = System.Environment.GetEnvironmentVariable("BMS_CURRENT_STATUS");

            if (string.IsNullOrEmpty(statusFromEnv) || !Statuses.ContainsKey(statusFromEnv))
            {
                CurrentStatus = Statuses.OrderBy(st => st.Key).First().Value;
            }
            else
            {
                CurrentStatus = Statuses[statusFromEnv];
            }
        }
Пример #5
0
 public ProjectViewModel()
 {
     LoadProjects();
     Statuses.Add(Status.NotStarted);
     Statuses.Add(Status.InProgress);
     Statuses.Add(Status.Done);
 }
Пример #6
0
 public void UpdateTimeLines()
 {
     if (!RestInfo.IsRunning && RestInfo.IsEnabled)
     {
         if (RestInfo.NextExecTime < DateTime.Now)
         {
             RestInfo.LastExecTime = DateTime.Now;
             RestInfo.IsRunning    = true;
             try {
                 Status[] statuses = Account.TwitterClient.GetListStatuses(List, _since_id, null, RestInfo.Count, null);
                 _since_id = TwitterClient.GetMaxStatusID(_since_id, statuses);
                 Account.Dispatcher.BeginInvoke(new EmptyDelegate(delegate() {
                     for (int i = 0; i < statuses.Length; i++)
                     {
                         Statuses.Add(statuses[i]);
                     }
                 }));
             } catch {
             } finally {
                 RestInfo.IsRunning    = false;
                 RestInfo.LastExecTime = DateTime.Now;
                 RestInfo.UpdateNextExecTimeRemaining();
             }
         }
         RestInfo.UpdateNextExecTimeRemaining();
     }
 }
Пример #7
0
 public void UpdateTimeLines()
 {
     if (!_rest.IsRunning && _rest.IsEnabled)
     {
         if (_rest.NextExecTime < DateTime.Now)
         {
             _rest.LastExecTime = DateTime.Now;
             _rest.IsRunning    = true;
             try {
                 Status[] statuses = Account.TwitterClient.Search(KeywordForRestAPI, null, null, _rest.Count, null, _since_id, null, null);
                 _since_id = TwitterClient.GetMaxStatusID(_since_id, statuses);
                 Account.Dispatcher.BeginInvoke(new EmptyDelegate(delegate() {
                     for (int i = 0; i < statuses.Length; i++)
                     {
                         Statuses.Add(statuses[i]);
                     }
                 }));
             } catch {
             } finally {
                 _rest.IsRunning    = false;
                 _rest.LastExecTime = DateTime.Now;
                 _rest.UpdateNextExecTimeRemaining();
             }
         }
         _rest.UpdateNextExecTimeRemaining();
     }
 }
Пример #8
0
        void IStreamingHandler.Streaming_StatusArrived(object sender, StatusArrivedEventArgs e)
        {
            StreamingClient c = sender as StreamingClient;

            Account.Dispatcher.BeginInvoke(new EmptyDelegate(delegate() {
                Statuses.Add(e.Status);
            }));
        }
 public void InsertStatus(SingleHttpStatus singleHttpStatus)
 {
     if (!Statuses.Contains(singleHttpStatus))
     {
         Statuses.Add(singleHttpStatus);
         OnStatusChanged(new EventArgs());
     }
 }
Пример #10
0
        async System.Threading.Tasks.Task ExecuteLoadScreen()
        {
            if (Users.Count < 1)
            {
                if (IsBusy)
                {
                    return;
                }

                IsBusy = true;

                try
                {
                    var lookups = await DataService.GetLookups(this.EntryType);

                    if (lookups.Shifts != null)
                    {
                        lookups.Shifts.ForEach(s => Shifts.Add(s));
                        if (Entry.ShiftId != null)
                        {
                            Shift = lookups.Shifts.FirstOrDefault(x => x.ShiftId == Entry.ShiftId);
                        }
                    }
                    if (lookups.Statuses != null)
                    {
                        lookups.Statuses.ForEach(s => Statuses.Add(s));
                    }
                    lookups.Tasks.ForEach(t => Tasks.Add(t));
                    if (Entry.TaskId != null)
                    {
                        Task = lookups.Tasks.FirstOrDefault(t => t.TaskId == Entry.TaskId);
                    }
                    lookups.Users.ForEach(u => Users.Add(u));
                    if (Entry.UserId != null)
                    {
                        User = lookups.Users.FirstOrDefault(u => u.UserId == Entry.UserId);
                    }
                    if (Entry.EnteredById == null)
                    {
                        var usr = AuthService.UserToken.User;
                        Entry.EnteredBy   = usr;
                        Entry.EnteredById = usr.UserId;
                    }
                }
                catch (Exception ex)
                {
                    IsBusy = false;
                    ExceptionHelper.ShowException(ex);
                }
                finally
                {
                    IsBusy = false;
                }
            }
            RefreshEntrySubtasks();

            OnPropertyChanged("Entry");
        }
Пример #11
0
        private void CheckParalyzed(int damage)
        {
            var chance = (int)Math.Round(damage * ParalyzedChanceMultiplier);

            if (RandomHelper.CheckChance(chance))
            {
                Statuses.Add(new ParalyzedObjectStatus());
            }
        }
Пример #12
0
        private void CheckFrozen(int damage)
        {
            var chance = (int)Math.Round(damage * FrozenChanceMultiplier);

            if (RandomHelper.CheckChance(chance))
            {
                Statuses.Add(new FrozenObjectStatus());
            }
        }
Пример #13
0
        public SupplyModelContext()
            : base("DefaultConnection")
        {
            if (Statuses.ToList().Count() == 0)
            {
                Statuses.Add(new Status()
                {
                    Id = 1, Caption = "Срочный"
                });
                Statuses.Add(new Status()
                {
                    Id = 2, Caption = "Нормальный"
                });
                Statuses.Add(new Status()
                {
                    Id = 3, Caption = "В перспективе"
                });
                Statuses.Add(new Status()
                {
                    Id = 4, Caption = "Для анализа"
                });
            }

            if (States.ToList().Count() == 0)
            {
                States.Add(new State()
                {
                    Id = 1, Caption = "Открыт"
                });
                States.Add(new State()
                {
                    Id = 2, Caption = "Закрыт"
                });
                States.Add(new State()
                {
                    Id = 3, Caption = "Заморожен"
                });
                States.Add(new State()
                {
                    Id = 4, Caption = "Отменен"
                });
                States.Add(new State()
                {
                    Id = 5, Caption = "Групповой"
                });
                States.Add(new State()
                {
                    Id = 6, Caption = "Удален"
                });
                States.Add(new State()
                {
                    Id = 7, Caption = "Архив"
                });
            }

            SaveChanges();
        }
Пример #14
0
        private int stunningBlow()
        {
            var multi    = getAttackMultiplier();
            var increase = getAttackModifier();
            var stun     = new AbilityClassLibrary.NPC.StunningBlow();

            Statuses.Add(new CombatLogicClassLibrary.Statuses.AttackDmgMultiplier(100, new List <int>(), 1.02));
            return(stun.Action(Strength, Crit, multi, increase));
        }
Пример #15
0
        private int sweep()
        {
            var multi    = getAttackMultiplier();
            var increase = getAttackModifier();
            var sweep    = new AbilityClassLibrary.Protector.Sweep();

            Statuses.Add(new CombatLogicClassLibrary.Statuses.AttackDmgMultiplier(100, new List <int>(), 1.02));
            return(sweep.Action(Strength - 20, Crit, multi, increase));
        }
Пример #16
0
        private int whirlwind()
        {
            var multi    = getAttackMultiplier();
            var increase = getAttackModifier();
            var whirl    = new AbilityClassLibrary.NPC.Whirlwind();

            Statuses.Add(new CombatLogicClassLibrary.Statuses.AttackDmgMultiplier(100, new List <int>(), 1.02));
            return(whirl.Action(Strength, Crit, multi, increase));
        }
Пример #17
0
        private int attack()
        {
            var multi    = getAttackMultiplier();
            var increase = getAttackModifier();
            var attack   = new AbilityClassLibrary.Warrior.Attack();

            Statuses.Add(new CombatLogicClassLibrary.Statuses.AttackDmgMultiplier(100, new List <int>(), 1.02));
            return(attack.Action(Strength, Crit, multi, increase));
        }
Пример #18
0
 public TaskEditModal()
 {
     Difficulties.Add("Easy");
     Difficulties.Add("Normal");
     Difficulties.Add("Hard");
     Statuses.Add("Todo");
     Statuses.Add("In Progress");
     Statuses.Add("Complete");
     this.InitializeComponent();
 }
Пример #19
0
        private int challengingShout()
        {
            var increase  = getAttackModifier();
            var multi     = getAttackMultiplier();
            var challenge = new ChallengingShout();

            Cooldowns[3] = challenge.Cooldown;
            Statuses.Add(challenge.applySelfStatus());
            return(challenge.Action(Strength, Crit, multi, increase));
        }
Пример #20
0
        public AdditionalInformationService()
        {
            if (File.Exists(IndexConsts.MemeDocumentsFile))
            {
                Log.Information("Meme documents found to load metadata");

                try
                {
                    var lines = File.ReadAllLines(IndexConsts.MemeDocumentsFile);
                    Log.Information($"Found {lines.Length} meme documents. Loading metadata...");
                    foreach (var line in lines)
                    {
                        var meme = JsonConvert.DeserializeObject <Meme>(line);

                        Statuses.Add(meme.Status);

                        var details    = meme.Details.Split(", ");
                        var categories = meme.Category.Split(", ");

                        foreach (var detail in details)
                        {
                            if (Details.ContainsKey(detail))
                            {
                                Details[detail]++;
                            }
                            else
                            {
                                Details.Add(detail, 1);
                            }
                        }

                        foreach (var category in categories)
                        {
                            if (Categories.ContainsKey(category))
                            {
                                Categories[category]++;
                            }
                            else
                            {
                                Categories.Add(category, 1);
                            }
                        }
                    }
                    Log.Information($"Loading metadata finished!");
                }
                catch (Exception ex)
                {
                    Log.Error("Error while loading metadata. Reason: " + ex.Message);
                }
            }
            else
            {
                Log.Warning("Can't find meme documents file to load metadata");
            }
        }
Пример #21
0
        private int execute()
        {
            var multi    = getAttackMultiplier();
            var increase = getAttackModifier();
            var exe      = new Execute();

            RecieveHeal(200);
            Statuses.Add(new CombatLogicClassLibrary.Statuses.AttackDmgMultiplier(100, new List <int>(), 1.04));
            swipeUsed++;
            return(exe.Action(Strength, Crit, multi, increase));
        }
Пример #22
0
 /// <summary>
 /// Applies a status to the player, if he was not already affected by that status
 /// </summary>
 /// <param name="status">The status to add to the player</param>
 /// <exception cref="PlayerStatusAlreadyAppliedException">If the player already had that status</exception>
 public void ApplyStatus(PlayerStatus status)
 {
     if (!Statuses.Any(x => x.Status == status))
     {
         Statuses.Add(new ActivePlayerStatus(this, status));
     }
     else
     {
         throw new PlayerStatusAlreadyAppliedException();
     }
 }
Пример #23
0
 public TaskEditModal(int id)
 {
     Difficulties.Add("Easy");
     Difficulties.Add("Normal");
     Difficulties.Add("Hard");
     Statuses.Add("Todo");
     Statuses.Add("In Progress");
     Statuses.Add("Complete");
     this.InitializeComponent();
     this._id = id;
     Quest    = App.Database.GetQuestAsync(this._id).Result;
 }
Пример #24
0
        public void AddStatus(TaskStatus status, bool isUserSet = false)
        {
            if (Statuses.Any(x => x.Status == status))
            {
                Debug.Assert(false);
                return;
            }

            LastStatus = status;
            Statuses.Add(new TaskStatusData {
                Status = status, IsUserSet = isUserSet
            });
        }
        public void CanRefreshAddToExistingTweetsCollection()
        {
            // setup twitter api mock return values
            Statuses statuses = new Statuses();

            statuses.Add(new Status {
                Id = "000", CreatedAt = DateTime.Today
            });
            statuses.Add(new Status {
                Id = "111", CreatedAt = DateTime.Today.AddDays(-2)
            });
            statuses.Add(new Status {
                Id = "222", CreatedAt = DateTime.Today.AddDays(-4)
            });

            // add some tweets to tweet manager
            _tweetsManager.All.Add(new Status {
                Id = "888", CreatedAt = DateTime.Today.AddDays(-10)
            });
            _tweetsManager.All.Add(new Status {
                Id = "999", CreatedAt = DateTime.Today.AddDays(-12)
            });

            // record
            Expect.Call(_twitterApiClient.FriendsTimelineSince("888")).Return(statuses);

            // playback
            _mocks.ReplayAll();
            _tweetsManager.Refresh();

            // assert
            Assert.AreEqual(5, _tweetsManager.All.Count);
            Assert.AreEqual("000", _tweetsManager.All[0].Id);
            Assert.AreEqual("111", _tweetsManager.All[1].Id);
            Assert.AreEqual("222", _tweetsManager.All[2].Id);
            Assert.AreEqual("888", _tweetsManager.All[3].Id);
            Assert.AreEqual("999", _tweetsManager.All[4].Id);
            _mocks.VerifyAll();
        }
Пример #26
0
 private void StatusesListCreator(IList <Status> list, Delegate lambdaDevice)
 {
     Statuses.Clear();
     foreach (var item in list)
     {
         var devices      = item.Devices;
         var devicesCount = devices.Count();
         if (lambdaDevice != null)
         {
             devicesCount = devices.Where((Func <Device, bool>)lambdaDevice).Count();
         }
         Statuses.Add(new SView(item, devicesCount, Statuses.Count() + 1));
     }
 }
Пример #27
0
        public usrReportStatus()
        {
            InitializeComponent();
            DataContext = this;
            var enums = Enum.GetValues(typeof(ReportStatus));

            foreach (ReportStatus status in enums)
            {
                ReportStatuses.Add(new ListItem <ReportStatus>(EnumLocalizer.Default.Translate(status), status));
            }

            Statuses.Add(new ListItem <EntryObjectStatus>(EnumLocalizer.Default.Translate(EntryObjectStatus.Done), EntryObjectStatus.Done));
            Statuses.Add(new ListItem <EntryObjectStatus>(EnumLocalizer.Default.Translate(EntryObjectStatus.Planned), EntryObjectStatus.Planned));
        }
Пример #28
0
        public TaskViewModel(DTask task)
        {
            Users = new ObservableCollection<User>(MainContext.GetEntities<User>());
            Periods = new ObservableCollection<Period>(MainContext.GetEntities<Period>());
            Tasks = new ObservableCollection<DTask>(MainContext.GetEntities<DTask>());
            Statuses.Add(Status.NotStarted);
            Statuses.Add(Status.InProgress);
            Statuses.Add(Status.Done);

            Weights.Add(Weight.Low);
            Weights.Add(Weight.Big);
            Weights.Add(Weight.High);
            SelectedTask = MainContext.GetEntities<DTask>().Single(a => a.Id == task.Id);

        }
Пример #29
0
        public ClientTabVM()
        {
            Name = "Clients";
            _dao = new SqliteDataAccess();
            RefreshClients();

            Statuses.Add(new ComboBoxItem()
            {
                ComboBoxOption = "Active"
            });
            Statuses.Add(new ComboBoxItem()
            {
                ComboBoxOption = "Inactive"
            });

            SelectedStateOption = Statuses.First();
        }
Пример #30
0
        public TaskViewModel(bool create_new_task = false)
        {
            Users = new ObservableCollection<User>(MainContext.GetEntities<User>());
            Periods = new ObservableCollection<Period>(MainContext.GetEntities<Period>());
            Tasks = new ObservableCollection<DTask>(MainContext.GetEntities<DTask>());
            Statuses.Add(Status.NotStarted);
            Statuses.Add(Status.InProgress);
            Statuses.Add(Status.Done);

            Weights.Add(Weight.Low);
            Weights.Add(Weight.Big);
            Weights.Add(Weight.High);

            if (create_new_task)
            {
                AddTaskCmd();
            }
        }
Пример #31
0
        public virtual bool AddStatus(string typeName, int rank = 0, int timeLeft = 0, Character caster = null, Character target = null, Dictionary <string, string> args = null, bool instantTick = false)
        {
            var s = GameServer.CreateSpell(typeName);

            if (s == null || Statuses.ContainsKey(s.StatusName))
            {
                return(false);
            }

            if (s.RequiresCaster && caster == null)
            {
                return(false);
            }

            s.NextTick = DateTime.UtcNow.AddMilliseconds(s.Speed);

            if (timeLeft > 0)
            {
                s.TimeLeft = timeLeft;
            }

            if (rank > 0)
            {
                s.Rank = rank;
            }

            if (args != null)
            {
                s.Arguments = args;
            }

            s.Caster = caster;
            s.Target = target;

            Statuses.Add(s.StatusName, s);
            s.OnAdd(this);

            if (instantTick)
            {
                s.OnTick(this);
            }

            return(true);
        }
        public void CanRefreshReplaceAllTweetsWhenTweetsCollectionIsEmpty()
        {
            // setup twitter api mock return values
            Statuses statuses = new Statuses();
            statuses.Add(new Status { Id = "000", CreatedAt = DateTime.Today });
            statuses.Add(new Status { Id = "111", CreatedAt = DateTime.Today.AddDays(-2) });
            statuses.Add(new Status { Id = "222", CreatedAt = DateTime.Today.AddDays(-4) });

            // record
            Expect.Call(_twitterApiClient.FriendsTimeline()).Return(statuses);

            // playback
            _mocks.ReplayAll();
            _tweetsManager.Refresh();

            // assert
            Assert.AreEqual(3, _tweetsManager.All.Count);
            Assert.AreEqual("000", _tweetsManager.All[0].Id);
            Assert.AreEqual("111", _tweetsManager.All[1].Id);
            Assert.AreEqual("222", _tweetsManager.All[2].Id);
            _mocks.VerifyAll();
        }