Exemple #1
0
        public void SellItemsValidateTransaction(Player player, List <WorldObject> items)
        {
            // todo: filter rejected / accepted send item spec result back to player
            uint payout = 0;
            List <WorldObject> accepted = new List <WorldObject>();
            List <WorldObject> rejected = new List <WorldObject>();

            foreach (WorldObject wo in items)
            {
                // payout scaled by the vendor's buy rate
                payout = payout + (uint)Math.Floor((BuyPrice ?? 1) * (wo.Value ?? 0) * (wo.StackSize ?? 1) + 0.1);

                if (!wo.MaxStackSize.HasValue & !wo.MaxStructure.HasValue)
                {
                    wo.Location               = null;
                    wo.ContainerId            = Guid.Full;
                    wo.PlacementPosition      = null;
                    wo.WielderId              = null;
                    wo.CurrentWieldedLocation = null;
                    // TODO: create enum for this once we understand this better.
                    // This is needed to make items lay flat on the ground.
                    wo.Placement = global::ACE.Entity.Enum.Placement.Resting;
                    uniqueItemsForSale.Add(wo.Guid, wo);
                }
                accepted.Add(wo);
            }

            ApproachVendor(player);
            player.FinalizeSellTransaction(this, true, accepted, payout);
        }
Exemple #2
0
        /// <summary>
        /// Handles validation for player selling items to vendor
        /// </summary>
        public void SellItems_ValidateTransaction(Player player, List <WorldObject> items)
        {
            // todo: filter rejected / accepted send item spec result back to player
            uint payout = 0;
            List <WorldObject> accepted = new List <WorldObject>();
            List <WorldObject> rejected = new List <WorldObject>();

            foreach (WorldObject wo in items)
            {
                var buyRate = BuyPrice ?? 1;
                if (wo.ItemType == ItemType.PromissoryNote)
                {
                    buyRate = 1.0;
                }

                // payout scaled by the vendor's buy rate
                payout += (uint)Math.Floor((wo.Value ?? 0) * buyRate + 0.1);

                if (!wo.MaxStackSize.HasValue & !wo.MaxStructure.HasValue)
                {
                    wo.Location               = null;
                    wo.ContainerId            = Guid.Full;
                    wo.PlacementPosition      = null;
                    wo.WielderId              = null;
                    wo.CurrentWieldedLocation = null;
                    wo.Placement              = ACE.Entity.Enum.Placement.Resting;
                    uniqueItemsForSale.Add(wo.Guid, wo);
                }
                accepted.Add(wo);
            }

            ApproachVendor(player, VendorType.Sell);

            player.FinalizeSellTransaction(this, true, accepted, payout);
        }