예제 #1
0
        public ActionResult Index()
        {
            var userId = User.Identity.GetUserId();

            ViewBag.Gold = db.Users.Find(userId).Gold;
            ViewBag.User = db.Users.Find(userId);

            var auctionService = new AuctionService();

            auctionService.CheckAuctions();

            return(View("Index", db.AuctionCreatures.Where(ac => !ac.Finished && ac.OwnerId != userId).OrderBy(ac => ac.EndTime).ToList()));
        }
예제 #2
0
        public ActionResult Targets()
        {
            var userId = User.Identity.GetUserId();

            ViewBag.Gold = db.Users.Find(userId).Gold;
            ViewBag.User = db.Users.Find(userId);

            var auctionService = new AuctionService();

            auctionService.CheckAuctions();

            var auctionTargets = db.AuctionTargets.Where(at => at.UserId == userId).Select(at => at.AuctionCreatureId);

            return(View("Index", db.AuctionCreatures.Where(ac => auctionTargets.Contains(ac.Id) && ac.OwnerId != userId || ac.CurrentBidderId == userId && !ac.Finished).OrderBy(ac => ac.EndTime).OrderBy(ac => ac.Finished).ToList()));
        }
예제 #3
0
        void RunServices()
        {
            var db = new ApplicationDbContext();

            var userId = User.Identity.GetUserId();
            var user   = db.Users.Find(userId);

            if ((DateTimeOffset.Now - user.LastRainbowGemTime).TotalHours >= 24)
            {
                user.RainbowGems++;
                user.LastRainbowGemTime = DateTimeOffset.Now;
            }

            user.LastActive = DateTimeOffset.Now;
            db.SaveChanges();

            if (db.Travels.Any(t => t.UserId == userId))
            {
                var travelService = new TravelService();
                travelService.CheckArrivalTime(userId);
            }

            if (user.Stamina < user.MaxStamina)
            {
                var staminaService = new StaminaService();
                staminaService.UpdateStamina(userId);
            }

            var battleService = new BattleService();

            battleService.RunBattles();

            var auctionService = new AuctionService();

            auctionService.CheckAuctions();
        }