Exemple #1
0
        public ServiceResponse <HeroModel> ResetTraitsForHero(HeroModel hero)
        {
            var service = new ServiceResponse <HeroModel>();
            var effects = GetForHero(hero).List.Where(x => x.IsAssigned()).SelectMany(x => x.Effects).ToList();

            foreach (var effect in effects)
            {
                effect.Revert();
            }
            hero.ApplyEffectList(effects, false);
            hero.Traits.Reset();
            service.Object = hero;
            return(service);
        }
Exemple #2
0
        public ServiceResponse <HeroModel> AssignTraitToHero(HeroModel hero, int traitId)
        {
            var response = new ServiceResponse <HeroModel>();
            var trait    = GetTraitById(traitId);

            if (trait == null)
            {
                return(response.AddError("Особенность не найдена"));
            }

            if (!hero.Traits.IsAssignable(trait) || !hero.ApplyEffectList(trait.Effects, false))
            {
                return(response.AddError(GenerationError.AbilitiesError.Description()));
            }

            trait.Level = 1;
            hero.Traits.List.Add(trait);
            response.Object = hero;
            return(response);
        }
Exemple #3
0
        public ServiceResponse <HeroModel> Assign(HeroModel hero, int branchId, int pos)
        {
            var response  = new ServiceResponse <HeroModel>();
            var newBranch = Get(branchId);
            var oldBranch = hero.Branches?.List.Skip(pos).FirstOrDefault();
            var effects   = SkillListToEffects(newBranch.Skills.ToList());

            if (oldBranch != null)
            {
                oldBranch = Get(oldBranch.Id);
                effects.AddRange(SkillListToEffects(oldBranch.Skills.ToList(), true));
            }

            hero.ApplyEffectList(effects, false);
            if (oldBranch != null)
            {
                hero.Branches.List.RemoveAt(pos);
            }
            hero.Branches.List.Add(newBranch);
            response.Object = hero;
            return(response);
        }