Ejemplo n.º 1
0
        /// <summary>
        /// Execute a sale
        /// </summary>
        /// <param name="item">the item in question</param>
        /// <param name="price">the sale price</param>
        /// <returns>error or blank</returns>
        public string MakeSale(IMobile customer, IInanimate item, int price)
        {
            string returnString = string.Empty;

            if (customer == null)
            {
                return("Invalid customer");
            }

            if (item == null || !Inventory.Contains(item))
            {
                return("I don't have that item in stock.");
            }

            int customerWallet = customer.GetQuality("Bells");

            if (customerWallet < price)
            {
                return("Insufficient Funds.");
            }

            customer.SetQuality(-1 * price, "Bells", true);
            item.TryMoveTo(customer.GetContainerAsLocation());

            return(returnString);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Executes this command
        /// </summary>
        public override void Execute()
        {
            IInanimateTemplate newObject = (IInanimateTemplate)Subject;
            IMobile            initator  = (IMobile)Actor;
            List <string>      sb        = new List <string>();
            IInanimate         entityObject;

            //No target = spawn to inventory
            if (Target != null)
            {
                IGlobalPosition spawnTo = (IGlobalPosition)Target;
                entityObject = Activator.CreateInstance(newObject.EntityClass, new object[] { newObject }) as IInanimate;
                sb.Add(string.Format("{0} spawned to {1}.", entityObject.TemplateName, spawnTo.CurrentZone.Keywords[0]));
            }
            else
            {
                entityObject = Activator.CreateInstance(newObject.EntityClass, new object[] { newObject, initator.GetContainerAsLocation() }) as IInanimate;
                sb.Add(string.Format("{0} spawned to your inventory.", entityObject.TemplateName));
            }

            //TODO: keywords is janky, location should have its own identifier name somehow for output purposes - DISPLAY short/long NAME

            ILexicalParagraph toActor = new LexicalParagraph(sb.ToString());

            ILexicalParagraph toOrigin = new LexicalParagraph("$S$ appears in the $T$.");

            ILexicalParagraph toSubject = new LexicalParagraph("You are ALIVE");

            ILexicalParagraph toTarget = new LexicalParagraph("You have been given $S$");

            Message messagingObject = new Message(toActor)
            {
                ToOrigin = new List <ILexicalParagraph> {
                    toOrigin
                },
                ToSubject = new List <ILexicalParagraph> {
                    toSubject
                },
                ToTarget = new List <ILexicalParagraph> {
                    toTarget
                }
            };

            messagingObject.ExecuteMessaging(Actor, entityObject, OriginLocation.CurrentZone, OriginLocation.CurrentZone, null);
        }