Exemple #1
0
        public IResult PerformCommand(IMobileObject performer, ICommand command)
        {
            IPlayerCharacter pc = performer as IPlayerCharacter;

            if (pc == null)
            {
                return(new Result(false, "Only player characters can have craftsman craft items."));
            }

            INonPlayerCharacter craftsman            = null;
            ICraftsman          craftsmanPersonality = null;

            FindCraftsman(performer, ref craftsman, ref craftsmanPersonality);

            if (craftsman == null)
            {
                return(new Result(false, "There is no craftsman to make anything for you."));
            }

            if (command.Parameters.Count < 7)
            {
                return(new Result(false, "Please provide all the parameters needed for the craftsman to make your item."));
            }

            try
            {
                AvalableItemPosition position = GetPosition(command.Parameters[0].ParameterValue);
                if (position == AvalableItemPosition.Wield && command.Parameters.Count < 8)
                {
                    return(new Result(false, "Damage type is required for weapons."));
                }

                int        level               = int.Parse(command.Parameters[1].ParameterValue);
                string     keyword             = command.Parameters[2].ParameterValue;
                string     sentenceDescription = command.Parameters[3].ParameterValue;
                string     shortDescription    = command.Parameters[4].ParameterValue;
                string     longDescription     = command.Parameters[5].ParameterValue;
                string     examineDescription  = command.Parameters[6].ParameterValue;
                DamageType damageType          = DamageType.Acid;
                if (position == AvalableItemPosition.Wield)
                {
                    damageType = GetDamageType(command.Parameters[7].ParameterValue);
                }

                return(craftsmanPersonality.Build(craftsman, pc, position, level, keyword, sentenceDescription, shortDescription, longDescription, examineDescription, damageType));
            }
            catch (Exception ex)
            {
                if (ex is ArgumentException)
                {
                    return(new Result(false, ex.Message));
                }
                else
                {
                    return(new Result(false, "Please verify all parameters and try again."));
                }
            }
        }
Exemple #2
0
        public IResult PerformCommand(IMobileObject performer, ICommand command)
        {
            IResult result = base.PerfomCommand(performer, command);

            if (result != null)
            {
                return(result);
            }

            if (!(performer is IPlayerCharacter pc))
            {
                return(new Result("Only player characters can have craftsman craft items.", true));
            }

            INonPlayerCharacter craftsman            = null;
            ICraftsman          craftsmanPersonality = null;

            FindCraftsman(performer, ref craftsman, ref craftsmanPersonality);

            if (craftsman == null)
            {
                return(new Result("There is no craftsman to make anything for you.", true));
            }

            if (command.Parameters.Count < 7)
            {
                return(new Result("Please provide all the parameters needed for the craftsman to make your item.", true));
            }

            try
            {
                AvalableItemPosition position = GetPosition(command.Parameters[0].ParameterValue);
                if (position == AvalableItemPosition.Wield && command.Parameters.Count < 8)
                {
                    return(new Result("Damage type is required for weapons.", true));
                }

                int        level               = int.Parse(command.Parameters[1].ParameterValue);
                string     keyword             = command.Parameters[2].ParameterValue;
                string     sentenceDescription = command.Parameters[3].ParameterValue;
                string     shortDescription    = command.Parameters[4].ParameterValue;
                string     lookDescription     = command.Parameters[5].ParameterValue;
                string     examineDescription  = command.Parameters[6].ParameterValue;
                DamageType damageType          = DamageType.Acid;
                if (position == AvalableItemPosition.Wield)
                {
                    damageType = GetDamageType(command.Parameters[7].ParameterValue);
                }

                if (level > craftsman.Level)
                {
                    craftsman.EnqueueCommand($"Tell {performer.KeyWords[0]} That is above my skill level.  You will need to find someone a higher level to craft such an item.");
                    return(new Result(null, true));
                }

                return(craftsmanPersonality.Build(craftsman, pc, position, level, keyword, sentenceDescription, shortDescription, lookDescription, examineDescription, damageType));
            }
            catch (Exception ex)
            {
                if (ex is ArgumentException)
                {
                    return(new Result(ex.Message, true));
                }
                else
                {
                    return(new Result("Please verify all parameters and try again.", true));
                }
            }
        }