/// <summary>
        /// Creates a CombatEntity using an EnemyEntityBase. The result is an ai-controlled CombatEntity.
        /// </summary>
        /// <param name="entityBase">The base to use for the resultant CombatEntity.</param>
        /// <returns></returns>
        public CombatEntity Create(AiEntityBase entityBase)
        {
            var secondaryStats = StatsCalculator.GetSecondaryStats(entityBase.Stats);

            secondaryStats += entityBase.SecondaryStats;

            int health    = entityBase.Resources.MaxHealth + StatsCalculator.GetHealth(entityBase.Stats);
            int mana      = entityBase.Resources.MaxMana + StatsCalculator.GetMana(entityBase.Stats);
            var resources = new ResourceStats
            {
                CurrentHealth       = health,
                CurrentMana         = mana,
                MaxHealth           = health,
                MaxMana             = mana,
                UnmodifiedMaxHealth = health,
                UnmodifiedMaxMana   = mana
            };

            var iconUris = new CharacterIconSet(entityBase.IconUris);
            var entity   = new CombatEntity
            {
                Id              = _id++,
                Name            = entityBase.Name,
                OwnerId         = GameplayConstants.AiId,
                IconUris        = iconUris,
                Abilities       = entityBase.Abilities,
                ComboCounter    = 0,
                OwnerName       = entityBase.FactionName,
                Stats           = entityBase.Stats.Copy(),
                SecondaryStats  = entityBase.SecondaryStats,
                StatusEffects   = new List <AppliedStatusEffect>(),
                UnmodifiedStats = entityBase.Stats,
                Resources       = resources
            };

            _statusEffectManager.Apply(entity, entity, entityBase.StatusEffects);

            return(entity);
        }
        /// <summary>
        /// Creates a player combat entity from a given character template asynchronously.
        /// </summary>
        /// <param name="template">The template containing specifications on how to create the entity.</param>
        /// <returns>Returns the combat entity if the operation was successful, else returns null.</returns>
        public async Task <CombatEntity> CreateAsync(CharacterTemplate template)
        {
            if (!await IsValidTemplateAsync(template))
            {
                return(null);
            }

            var hairData = await _characterHairRepo.GetDataAsync();

            var baseData = await _characterBaseRepo.GetDataAsync();

            var classTemplates = await _classTemplateRepo.GetDataAsync();

            ClassTemplate    cTemplate;
            CharacterIconSet iconUris;

            try
            {
                // Find the corresponding iconUris and arrange them in the correct order from
                // bottom layer to top
                var hair  = hairData.First(h => h.Id == template.HairId).IconUri;
                var cBase = baseData.First(b => b.Id == template.BaseId).IconUri;
                cTemplate = classTemplates.First(temp => temp.Id == template.ClassTemplateId);

                iconUris = new CharacterIconSet
                {
                    BaseIconUri = cBase,
                    HairIconUri = hair
                };
            }
            catch (InvalidOperationException e)
            {
                return(null);
            }

            int health    = StatsCalculator.GetHealth(cTemplate.Stats);
            int mana      = StatsCalculator.GetMana(cTemplate.Stats);
            var resources = new ResourceStats
            {
                CurrentHealth       = health,
                CurrentMana         = mana,
                MaxHealth           = health,
                MaxMana             = mana,
                UnmodifiedMaxHealth = health,
                UnmodifiedMaxMana   = mana
            };

            // Todo: Calculate secondary stats
            var character = new CombatEntity
            {
                Id              = _id++,
                Name            = template.Name,
                OwnerId         = template.OwnerId,
                IconUris        = iconUris,
                GroupId         = template.GroupId,
                OwnerName       = template.OwnerName,
                GrowthPoints    = template.AllocatedStats,
                Abilities       = cTemplate.Abilities.ToList(),
                Resources       = resources,
                SecondaryStats  = cTemplate.SecondaryStats.Copy(),
                StatusEffects   = new List <AppliedStatusEffect>(),
                UnmodifiedStats = cTemplate.Stats.Copy(),
                Stats           = cTemplate.Stats.Copy(),
                EquippedItems   = new List <Item>()
            };

            foreach (var equipment in cTemplate.EquippedItems)
            {
                _equipmentManager.Equip(character, equipment);
            }

            // Todo: Add to dbset here after creating EFCore migration

            return(character);
        }