Example #1
0
        /// <summary>
        /// Executes this command
        /// </summary>
        public override void Execute()
        {
            List <string> sb             = new List <string>();
            bool          wantsSellSheet = Subject == null || string.IsNullOrWhiteSpace(Subject.ToString()) || Subject.ToString() != "buy";

            if (Target == null)
            {
                RenderError("There is no merchant in that direction.");
                return;
            }

            INonPlayerCharacter merchant = (INonPlayerCharacter)Target;

            if (merchant == null || (!merchant.DoIBuyThings() && !merchant.DoISellThings()))
            {
                RenderError("There is no merchant in that direction.");
                return;
            }

            string errorMessage;

            if (wantsSellSheet)
            {
                errorMessage = merchant.RenderInventory(Actor);
            }
            else
            {
                errorMessage = merchant.RenderPurchaseSheet(Actor);
            }

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