Esempio n. 1
0
        public List <RoundActivateAbilities> ChangeTime(ChangeCharacterTimeDto changeCharacterTimeDto)
        {
            if (Bonuses != null)
            {
                if (Limit != null)
                {
                    var isNoLongerActive = Limit.ChangeTime(changeCharacterTimeDto.TimeUnit, changeCharacterTimeDto.Bonus, ID);
                    if (isNoLongerActive)
                    {
                        var toInaktivate = changeCharacterTimeDto.Bonus.Round.ActivatedAbilities.Where(x => x.AbilityId == ID && x.IsActive).ToList();
                        foreach (var activateAbilitiese in toInaktivate)
                        {
                            activateAbilitiese.IsActive = false;
                        }
                        if (ApplyConditionOnDeactivate != null)
                        {
                            changeCharacterTimeDto.Bonus.Round.ApplyCondition(ApplyConditionOnDeactivate, ID);
                        }
                    }
                    var isActive = IsActive(changeCharacterTimeDto.Bonus, changeCharacterTimeDto.TargetHit);
                    if ((int)Limit.Duration.Unit.GetValueOrDefault() == (int)changeCharacterTimeDto.TimeUnit && isActive)
                    {
                        var hpDmgBonuses = Bonuses.Where(x => x.ShouldApplyTo(new GameId
                        {
                            ID = Configuration.HitPointsDmg
                        }, typeof(HitPoints))).ToList();
                        if (hpDmgBonuses.Any())
                        {
                            var dmgToTake = hpDmgBonuses.MaxBonuesSum(changeCharacterTimeDto.Bonus);
                            if (Limit.Amount != null)
                            {
                                dmgToTake = Limit.Amount.LimitAutoChargesIfNecessary(dmgToTake, changeCharacterTimeDto.Bonus);
                            }
                            changeCharacterTimeDto.Bonus.Character.TakeDamage(true, DamageType.AllWeapons, dmgToTake, true);
                        }

                        var hpDmgNlBonuses = Bonuses.Where(x => x.ShouldApplyTo(new GameId
                        {
                            ID = Configuration.HitPointsDmgNl
                        }, typeof(HitPoints))).ToList();
                        if (hpDmgNlBonuses.Any())
                        {
                            var dmgToTake = hpDmgNlBonuses.MaxBonuesSum(changeCharacterTimeDto.Bonus);
                            if (Limit.Amount != null)
                            {
                                dmgToTake = Limit.Amount.LimitAutoChargesIfNecessary(dmgToTake, changeCharacterTimeDto.Bonus);
                            }
                            changeCharacterTimeDto.Bonus.Character.TakeDamage(false, DamageType.AllWeapons, dmgToTake, true);
                        }

                        var hpHealBonuses = Bonuses.Where(x => x.ShouldApplyTo(new GameId
                        {
                            ID = Configuration.HitPointsHeal
                        }, typeof(HitPoints))).ToList();
                        if (hpHealBonuses.Any())
                        {
                            var dmgToHeal = hpHealBonuses.MaxBonuesSum(changeCharacterTimeDto.Bonus);
                            if (Limit.Amount != null)
                            {
                                dmgToHeal = Limit.Amount.LimitAutoChargesIfNecessary(dmgToHeal, changeCharacterTimeDto.Bonus);
                            }
                            changeCharacterTimeDto.Bonus.Character.HealDamage(dmgToHeal);
                        }
                    }

                    if ((int)changeCharacterTimeDto.TimeUnit >= (int)Limit.Amount.ResetUseTimeLimtUnit.GetValueOrDefault())
                    {
                        return(changeCharacterTimeDto.Bonus.Round.ActivatedAbilities.Where(x => x.AbilityId == ID).ToList());
                    }
                }
            }
            return(new List <RoundActivateAbilities>());
        }