Пример #1
0
        public async Task <CollectedResourcesViewModel> Collect()
        {
            CollectedResourcesViewModel collectedResources = new CollectedResourcesViewModel();
            Hero hero = await this.heroService.GetHero();

            HeroAmulet heroAmulet = hero.EquippedSet.Amulet;

            this.CheckIfHeroWorkedInMine(hero);

            Random random = new Random();

            collectedResources.Crystals = random.Next(1, 5);

            if (heroAmulet?.Name == AmuletNames.CrystalDigger)
            {
                double chance = random.Next(0, 100);

                if (heroAmulet.Bonus >= chance)
                {
                    collectedResources.Crystals       *= 2;
                    collectedResources.AmuletActivated = true;
                }
            }

            hero.Statistics.EarnedInMines += collectedResources.Crystals;

            await this.resourcePouchService.IncreaseResource(ResourceNames.Crystals, collectedResources.Crystals);

            await this.chronometerService.NullifyWorkUntil();

            await this.statisticsService.UpdateStatistics(hero.Statistics);

            return(collectedResources);
        }
Пример #2
0
        public async Task <CollectedResourcesViewModel> Collect()
        {
            CollectedResourcesViewModel collectedResources = new CollectedResourcesViewModel();
            Hero hero = await this.heroService.GetHero();

            this.CheckIfHeroIsPatrolling(hero);

            collectedResources.Experience = BattlefieldFormulas.CalculatePatrolExperience(hero.Level.CurrentLevel);
            collectedResources.Gold       = BattlefieldFormulas.CalculatePatrolGold(hero.Level.CurrentLevel);

            hero.Statistics.EarnedOnPatrol += collectedResources.Gold;
            hero.DailyLimits.PatrolsDone++;

            await this.levelService.GiveHeroExperience(collectedResources.Experience);

            await this.resourcePouchService.IncreaseResource(ResourceNames.Gold, collectedResources.Gold);

            await this.chronometerService.NullifyWorkUntil();

            await this.statisticsService.UpdateStatistics(hero.Statistics);

            await this.dailyLimitsService.UpdateDailyLimits(hero.DailyLimits);

            Notification notification = new Notification()
            {
                ImageUrl   = PatrolNotificationImageUrl,
                Title      = PatrolNotificationTitle,
                Content    = PatrolNotificationContent,
                Gold       = collectedResources.Gold,
                Experience = collectedResources.Experience,
                Type       = NotificationType.Patrol,
                Hero       = hero,
            };

            await this.notificationService.AddNotification(notification);

            return(collectedResources);
        }
Пример #3
0
        public async Task <CollectedResourcesViewModel> Collect()
        {
            CollectedResourcesViewModel collectedResources = new CollectedResourcesViewModel();
            Hero hero = await this.heroService.GetHero();

            this.CheckIfHeroWorkedOnFarm(hero);

            HeroAmulet heroAmulet = hero.EquippedSet.Amulet;

            collectedResources.Experience = FarmFormulas.CalculateExperience(hero.Level.CurrentLevel, WorkDurationInHours);
            collectedResources.Gold       = FarmFormulas.CalculateGoldEarned(hero.Level.CurrentLevel, WorkDurationInHours, heroAmulet?.Name == AmuletNames.Laborium ? heroAmulet.Bonus : 0);

            hero.Statistics.EarnedOnFarm += collectedResources.Gold;

            await this.levelService.GiveHeroExperience(collectedResources.Experience);

            await this.resourcePouchService.IncreaseResource(ResourceNames.Gold, collectedResources.Gold);

            await this.chronometerService.NullifyWorkUntil();

            await this.statisticsService.UpdateStatistics(hero.Statistics);

            Notification notification = new Notification()
            {
                ImageUrl   = FarmNotificationImageUrl,
                Title      = FarmNotificationTitle,
                Content    = FarmNotificationContent,
                Gold       = collectedResources.Gold,
                Experience = collectedResources.Experience,
                Type       = NotificationType.Farm,
                Hero       = hero,
            };

            await this.notificationService.AddNotification(notification);

            return(collectedResources);
        }