示例#1
0
        /// <summary>
        /// Executes this command
        /// </summary>
        internal override bool ExecutionBody()
        {
            INonPlayerCharacter trainer = (INonPlayerCharacter)Subject;

            if (trainer == null || !trainer.DoITeachThings())
            {
                RenderError("There is no trainer that teaches in that direction.");
                return(false);
            }

            //Do the list
            if (Target.GetType() == typeof(string))
            {
                string listings = trainer.RenderInstructionList(Actor);

                Message listingMessage = new Message(new LexicalParagraph(listings));

                listingMessage.ExecuteMessaging(Actor, null, null, null, null);
            }

            int price = -1;

            string errorMessage = "The trainer can not train that.";

            //We have an ability
            if (Target is IQuality proficency)
            {
                int profLevel = Actor.GetQuality(proficency.Name);

                if (profLevel >= 0)
                {
                    errorMessage = trainer.Instruct((IMobile)Actor, proficency.Name, profLevel + 1, price);
                }
            }

            if (!string.IsNullOrWhiteSpace(errorMessage))
            {
                RenderError(errorMessage);
            }

            ILexicalParagraph toArea = new LexicalParagraph("$A$ trains with $S$.");

            //TODO: language outputs
            Message messagingObject = new Message(new LexicalParagraph(string.Format("You learn from $S$ for {0}blz.", price)))
            {
                ToOrigin = new List <ILexicalParagraph> {
                    toArea
                }
            };

            messagingObject.ExecuteMessaging(Actor, trainer, null, OriginLocation.CurrentZone, null);

            return(true);
        }