Esempio n. 1
0
        /// <summary>
        /// Returns a string describing this protect limit change result.
        /// </summary>
        /// <param name="result">The protect limit change result.</param>
        public static string Describe <TSource>(this ProtectLimitChangeActionResult <TSource> result)
        {
            var target = result.Target;

            if (target.IsDead)
            {
                return(null);
            }

            if (result.IsSelfInflicted)
            {
                if (result.Amount > 0)
                {
                    return(result.Source switch
                    {
                        Item item => $"{target.Name}'s {item.Name} increased their protection limit by {result.Amount}!",
                        _ => $"{target.Name} increased their protection limit by {result.Amount}!",
                    });
Esempio n. 2
0
        /// <summary>
        /// Changes the protect limit by the given amount.
        /// </summary>
        /// <param name="amount">The amount.</param>
        /// <param name="user">The character who caused this protect limit change.</param>
        /// <typeparam name="TSource">The type of the source of the incoming protect limit change.</typeparam>
        public ProtectLimitChangeActionResult <TSource> ChangeProtectLimit <TSource>(
            int amount,
            Character user)
        {
            ProtectLimitChangeActionResult <TSource> result;

            if (CanProtectFrom(user))
            {
                var protectUser = ConsumeProtect();

                result = new ProtectLimitChangeActionResult <TSource>
                {
                    Applied         = false,
                    User            = user,
                    Target          = this,
                    TargetProtected = true,
                    ProtectUser     = protectUser,
                    Tags            = new HashSet <string>(),
                };
            }
            else
            {
                ProtectLimit += amount;

                result = new ProtectLimitChangeActionResult <TSource>
                {
                    Applied         = true,
                    User            = user,
                    Target          = this,
                    TargetProtected = false,
                    Amount          = amount,
                    Tags            = new HashSet <string>(),
                };
            }

            return(result);
        }