Esempio n. 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)
        {
            // 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);
                            vendor.IsBusy = true;

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

                            var postCastTime = vendor.GetPostCastTime();

                            castChain.AddDelaySeconds(postCastTime);
                            castChain.AddAction(vendor, () => vendor.IsBusy = false);

                            castChain.EnqueueChain();
                        }
                        else if (gen.GetProperty(PropertyInt.HomeRealm).HasValue)
                        {
                            var realmId = gen.GetProperty(PropertyInt.HomeRealm).Value;
                            RealmManager.SetHomeRealm(this, realmId);
                        }
                    }
                }

                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);
        }