コード例 #1
0
        protected virtual bool CanActivateSkill(User user, ICombatable target, string channel, out DougResponse response)
        {
            var totalCooldown = Cooldown * (1 - user.CooldownReduction());

            if (!user.HasWeaponType(RequiredWeapon) && RequiredWeapon != null)
            {
                response = new DougResponse(string.Format(DougMessages.WrongWeaponForSkill, RequiredWeapon.Name));
                return(false);
            }

            if (user.IsSkillOnCooldown())
            {
                response = new DougResponse(string.Format(DougMessages.CommandOnCooldown, user.CalculateStealCooldownRemaining()));
                return(false);
            }

            if (!user.HasEnoughEnergyForCost(EnergyCost))
            {
                response = new DougResponse(DougMessages.NotEnoughEnergy);
                return(false);
            }

            user.Energy -= EnergyCost;
            StatsRepository.FireSkill(user.Id, TimeSpan.FromSeconds(totalCooldown), user.Energy);
            response = new DougResponse();
            return(true);
        }