Esempio n. 1
0
        private static void SelectBoostAmount(BoostedObjective boostedObjective)
        {
            Random rand = new Random();

            int ran = rand.Next(100);

            if (ran < 50)
            {
                boostedObjective.BoostAmount = 1.5;
            }
            else if (ran < 75)
            {
                boostedObjective.BoostAmount = 2.0;
            }
            else if (ran < 90)
            {
                boostedObjective.BoostAmount = 2.5;
            }
            else if (ran < 99)
            {
                boostedObjective.BoostAmount = 3;
            }
            else
            {
                boostedObjective.BoostAmount = 5;
            }
        }
Esempio n. 2
0
        public static void RolloverDailyBoosted()
        {
            AppIdentityDbContext context;

            using (context = AppIdentityDbContext.Create())
            {
                IUnitOfWork          unitOfWork          = new UnitOfWork(context);
                IObjectiveRepository objectiveRepository = new ObjectiveRepository(unitOfWork);

                List <BoostedObjective> boostedObjectives = objectiveRepository.GetBoostedObjectives().Where(b => b.IsLive() == false).ToList();

                foreach (BoostedObjective objective in boostedObjectives)
                {
                    objectiveRepository.DeleteBoostedObjective(objective.BoostedObjectiveID);
                }

                BoostedObjective newBoostedObjective = new BoostedObjective();

                // grab an active objective that has a product associated it (objectives without products are special and shouldn't be boosted via this method)
                Objective randomObjective = objectiveRepository.GetObjectives().Where(l => l.IsActive && l.Product != null && l.RequiresAdmin == false).OrderBy(x => Guid.NewGuid()).FirstOrDefault();

                if (randomObjective == null)
                {
                    unitOfWork.Save();
                    return;
                }

                SelectBoostAmount(newBoostedObjective);

                DateTime endDate = GetMidnightEST().AddDays(1);

                newBoostedObjective.EndDate = endDate;
                newBoostedObjective.IsDaily = true;

                randomObjective.AddBoostedObjective(newBoostedObjective);

                objectiveRepository.UpdateObjective(randomObjective);

                ISiteRepository siteRepository = new SiteRepository(unitOfWork);

                String urlAndName = String.Empty;

                if (randomObjective.Product.IsSteamAppID)
                {
                    urlAndName = "[url=https://store.steampowered.com/app/" + randomObjective.Product.AppID + "]" + randomObjective.Title + "[/url]";
                }
                else
                {
                    urlAndName = randomObjective.Title;
                }

                SiteNotification notification = new SiteNotification()
                {
                    Notification = "[boosted][/boosted] Objective [ptext]\"" + randomObjective.ObjectiveName + "\"[/ptext] for " + randomObjective.Title + " is [url=https://theafterparty.azurewebsites.net/objectives/boosted]boosted[/url] by [gtext]" + randomObjective.BoostedObjective.BoostAmount + "x[/gtext] for a boosted award of [gtext]" + randomObjective.FixedReward() + "[/gtext]!", NotificationDate = DateTime.Now
                };
                siteRepository.InsertSiteNotification(notification);

                unitOfWork.Save();
            }
        }
        public void DeleteBoostedObjective(int boostedObjectiveId)
        {
            BoostedObjective targetBoostedObjective = context.BoostedObjectives.Find(boostedObjectiveId);

            if (targetBoostedObjective != null)
            {
                context.BoostedObjectives.Remove(targetBoostedObjective);
            }
        }
Esempio n. 4
0
        public void EditBoostedObjective(BoostedObjective boostedObjective, int days)
        {
            BoostedObjective updatedBoostedObjective = objectiveRepository.GetBoostedObjectiveByID(boostedObjective.BoostedObjectiveID);

            updatedBoostedObjective.BoostAmount = boostedObjective.BoostAmount;
            updatedBoostedObjective.EndDate     = updatedBoostedObjective.EndDate.AddDays(days);

            objectiveRepository.UpdateBoostedObjective(updatedBoostedObjective);
            unitOfWork.Save();
        }
Esempio n. 5
0
        public Objective GetObjectiveWithBoostedDaily()
        {
            BoostedObjective obj = objectiveRepository.GetBoostedObjectives().Where(b => b.IsDaily && b.IsLive()).FirstOrDefault();

            if (obj != null)
            {
                return(obj.Objective);
            }

            return(null);
        }
        public void UpdateBoostedObjective(BoostedObjective boostedObjective)
        {
            BoostedObjective targetBoostedObjective = context.BoostedObjectives.Find(boostedObjective.BoostedObjectiveID);

            if (targetBoostedObjective != null)
            {
                targetBoostedObjective.IsDaily     = boostedObjective.IsDaily;
                targetBoostedObjective.BoostAmount = boostedObjective.BoostAmount;
                targetBoostedObjective.EndDate     = boostedObjective.EndDate;
            }
        }
 public void InsertBoostedObjective(BoostedObjective boostedObjective)
 {
     context.BoostedObjectives.Add(boostedObjective);
 }
 public ApiBoostedObjectiveModel(BoostedObjective boostedObjective)
 {
     BoostedObjectiveID = boostedObjective.BoostedObjectiveID;
     EndDate            = boostedObjective.EndDate;
 }
Esempio n. 9
0
 public void AddBoostedObjective(BoostedObjective boostedObjective)
 {
     objectiveRepository.InsertBoostedObjective(boostedObjective);
     unitOfWork.Save();
 }