Пример #1
0
        /// <inheritdoc/>
        public IEnumerable <DamageCalculation> Calculate(Character user, DamageAction damage, IEnumerable <Character> targets)
        {
            var result = _actionHistory.LastMoveDamageResultAgainst(user);

            var calculations = new List <DamageCalculation>();

            foreach (var target in targets)
            {
                if (result is null)
                {
                    calculations.Add(new DamageCalculation
                    {
                        Target  = target,
                        Success = false,
                        Amount  = 0,
                    });
                }
                else
                {
                    calculations.Add(new DamageCalculation
                    {
                        Target  = target,
                        Success = true,
                        Amount  = Math.Max(1, result.Amount * _percentage / 100),
                    });
                }
            }

            return(calculations);
        }
        /// <inheritdoc />
        public (bool success, IEnumerable <Character> targets) Calculate(Character user, IEnumerable <Character> otherCharacters)
        {
            var result = _actionHistory.LastMoveDamageResultAgainst(user);

            if (result is null)
            {
                return(false, Enumerable.Empty <Character>());
            }

            if (result.User == user)
            {
                // cannot retaliate against oneself
                return(false, Enumerable.Empty <Character>());
            }

            return(true, new[] { result.User });
        }