예제 #1
0
        public Handler DoBuyFromEntity(EntityBase entity, string strKeyword)
        {
            EntityHand hand = entity.Hands.GetHandWithItem(strKeyword);

            if (hand == null)
            {
                // no hand is holding the requested item
                return(Handler.HANDLED(MESSAGE_ENUM.ERROR_BAD_ITEM));
            }
            else
            {
                // hand is holding the requested item
                if (ShopItemTypes.HasFlag(hand.Item.Type))
                {
                    // shop WILL buy this item type
                    int nPrice = (int)(hand.Item.Value * BuysAt);

                    Paragraph itemNameAsParagraph = hand.Item.NameAsParagraph;
                    entity.Gold += nPrice;
                    hand.Item    = null;
                    return(Handler.HANDLED(MESSAGE_ENUM.PLAYER_SELL_ITEM, itemNameAsParagraph, nPrice.ToString().ToParagraph()));
                }
                else
                {
                    // shop WILL NOT buy this item type
                    return(Handler.HANDLED(MESSAGE_ENUM.ERROR_BAD_SHOP));
                }
            }
        }
예제 #2
0
        public Handler DoPriceItem(Item item, string strKeyword)
        {
            if (item == null)
            {
                return(Handler.HANDLED(MESSAGE_ENUM.ERROR_BAD_ITEM));
            }
            if (!item.IsKeyword(strKeyword))
            {
                return(Handler.HANDLED(MESSAGE_ENUM.ERROR_BAD_ITEM));
            }
            if (!ShopItemTypes.HasFlag(item.Type))
            {
                return(Handler.HANDLED(MESSAGE_ENUM.ERROR_BAD_SHOP));
            }

            // shop will buy this item type
            int nPrice = (int)(item.Value * BuysAt);

            return(Handler.HANDLED(MESSAGE_ENUM.PLAYER_PRICE_ITEM, item.NameAsParagraph, nPrice.ToString().ToParagraph()));
        }