Example #1
0
        /// <summary>
        /// Vendor has validated the transactions and sent a list of items for processing.
        /// </summary>
        public void FinalizeBuyTransaction(Vendor vendor, List <WorldObject> uqlist, List <WorldObject> genlist, uint goldcost, uint altcost)
        {
            // todo research packets more for both buy and sell. ripley thinks buy is update..
            // vendor accepted the transaction

            var valid = ValidateBuyTransaction(vendor, goldcost, altcost);

            if (valid)
            {
                SpendCurrency(goldcost, WeenieType.Coin);

                foreach (WorldObject wo in uqlist)
                {
                    wo.RemoveProperty(PropertyFloat.SoldTimestamp);
                    TryCreateInInventoryWithNetworking(wo);
                }

                foreach (var gen in genlist)
                {
                    var service = gen.GetProperty(PropertyBool.VendorService) ?? false;

                    if (!service)
                    {
                        TryCreateInInventoryWithNetworking(gen);
                    }
                    else
                    {
                        var spell = new Spell(gen.SpellDID ?? 0);
                        TryCastSpell(spell, this, null, false, false);
                    }
                }

                if (altcost > 0)
                {
                    var altCurrency = vendor.AlternateCurrency ?? 0;

                    TryConsumeFromInventoryWithNetworking(altCurrency, (int)altcost);
                }

                Session.Network.EnqueueSend(new GameMessageSound(Guid, Sound.PickUpItem));

                if (PropertyManager.GetBool("player_receive_immediate_save").Item)
                {
                    RushNextPlayerSave(5);
                }
            }

            vendor.BuyItems_FinalTransaction(this, uqlist, valid);
        }
Example #2
0
        /// <summary>
        /// Vendor has validated the transactions and sent a list of items for processing.
        /// </summary>
        public void FinalizeBuyTransaction(Vendor vendor, List <WorldObject> uqlist, List <WorldObject> genlist, uint goldcost, uint altcost)
        {
            // vendor accepted the transaction

            var valid = ValidateBuyTransaction(vendor, goldcost, altcost);

            if (valid)
            {
                if (altcost > 0)
                {
                    var altCurrencyWCID = vendor.AlternateCurrency ?? 0;

                    SpendCurrency(altCurrencyWCID, altcost, true);
                }
                else
                {
                    SpendCurrency(Vendor.CoinStackWCID, goldcost, true);
                }

                foreach (WorldObject wo in uqlist)
                {
                    wo.RemoveProperty(PropertyFloat.SoldTimestamp);
                    TryCreateInInventoryWithNetworking(wo);
                }

                foreach (var gen in genlist)
                {
                    var service = gen.GetProperty(PropertyBool.VendorService) ?? false;

                    if (!service)
                    {
                        TryCreateInInventoryWithNetworking(gen);
                    }
                    else
                    {
                        var spell = new Spell(gen.SpellDID ?? 0);
                        if (!spell.NotFound)
                        {
                            var preCastTime = vendor.PreCastMotion(this);

                            var castChain = new ActionChain();
                            castChain.AddDelaySeconds(preCastTime);
                            castChain.AddAction(vendor, () =>
                            {
                                vendor.TryCastSpell(spell, this, vendor);
                                vendor.PostCastMotion();
                            });
                            castChain.EnqueueChain();
                        }
                    }
                }

                Session.Network.EnqueueSend(new GameMessageSound(Guid, Sound.PickUpItem));

                if (PropertyManager.GetBool("player_receive_immediate_save").Item)
                {
                    RushNextPlayerSave(5);
                }
            }

            vendor.BuyItems_FinalTransaction(this, uqlist, valid, altcost);
        }