Ejemplo n.º 1
0
        public BuyItemError CanPlayerBuyItem(Character chr, VendorItemEntry vendorItem, int count, out uint price)
        {
            // Can the player use this item?
            //if (vendorItem.Template.CheckRequirements(curChar) != InventoryError.OK)
            //{
            //	NPCHandler.SendBuyError(chr.Client, NPC, vendorItem.Template.Id, BuyItemError.CantFindItem);
            //	return false;
            //}

            // Does the player have enough money?
            price = chr.Reputations.GetDiscountedCost(NPC.Faction.ReputationIndex, vendorItem.Template.BuyPrice);
            if (chr.Money < price)
            {
                return BuyItemError.NotEnoughMoney;
            }

            // Does the vendor have enough inventory for this trade?
            if (vendorItem.RemainingStockAmount != UnlimitedSupply && vendorItem.RemainingStockAmount < count)
            {
                return BuyItemError.ItemAlreadySold;
            }

            // Is the player's faction standing high enough with this vendor?
            if (vendorItem.Template.RequiredFaction != null)
            {
                if (chr.Reputations.GetStandingLevel(vendorItem.Template.RequiredFaction.ReputationIndex) < vendorItem.Template.RequiredFactionStanding)
                {
                    return BuyItemError.ReputationRequirementNotMet;
                }
            }

            if (vendorItem.ExtendedCostEntry != null)
            {
                var exCost = vendorItem.ExtendedCostEntry;
                if (chr.HonorPoints < exCost.HonorCost)
                {
                    return BuyItemError.NotEnoughMoney;
                }

                if (chr.ArenaPoints < exCost.ArenaPointCost)
                {
                    return BuyItemError.NotEnoughMoney;
                }

                if (chr.MaxPersonalArenaRating < exCost.ReqArenaRating)
                {
                    return BuyItemError.RankRequirementNotMet;
                }

                foreach (var reqItem in exCost.RequiredItems)
                {
                    if (reqItem.Id == ItemId.None) break;
                    var amt = chr.Inventory.GetItemAmountByItemId(reqItem.Id);
                    if (amt < reqItem.Cost)
                    {
                        return BuyItemError.NotEnoughMoney;
                    }
                }
            }
            return BuyItemError.Ok;
        }
Ejemplo n.º 2
0
        public BuyItemError CanPlayerBuyItem(Character chr, VendorItemEntry vendorItem, int count, out uint price)
        {
            // Can the player use this item?
            //if (vendorItem.Template.CheckRequirements(curChar) != InventoryError.OK)
            //{
            //	NPCHandler.SendBuyError(chr.Client, NPC, vendorItem.Template.Id, BuyItemError.CantFindItem);
            //	return false;
            //}

            // Does the player have enough money?
            price = chr.Reputations.GetDiscountedCost(NPC.Faction.ReputationIndex, vendorItem.Template.BuyPrice);
            if (chr.Money < price)
            {
                return(BuyItemError.NotEnoughMoney);
            }

            // Does the vendor have enough inventory for this trade?
            if (vendorItem.RemainingStockAmount != UnlimitedSupply && vendorItem.RemainingStockAmount < count)
            {
                return(BuyItemError.ItemAlreadySold);
            }

            // Is the player's faction standing high enough with this vendor?
            if (vendorItem.Template.RequiredFaction != null)
            {
                if (chr.Reputations.GetStandingLevel(vendorItem.Template.RequiredFaction.ReputationIndex) < vendorItem.Template.RequiredFactionStanding)
                {
                    return(BuyItemError.ReputationRequirementNotMet);
                }
            }

            if (vendorItem.ExtendedCostEntry != null)
            {
                var exCost = vendorItem.ExtendedCostEntry;
                if (chr.HonorPoints < exCost.HonorCost)
                {
                    return(BuyItemError.NotEnoughMoney);
                }

                if (chr.ArenaPoints < exCost.ArenaPointCost)
                {
                    return(BuyItemError.NotEnoughMoney);
                }

                if (chr.MaxPersonalArenaRating < exCost.ReqArenaRating)
                {
                    return(BuyItemError.RankRequirementNotMet);
                }

                foreach (var reqItem in exCost.RequiredItems)
                {
                    if (reqItem.Id == ItemId.None)
                    {
                        break;
                    }
                    var amt = chr.Inventory.GetItemAmountByItemId(reqItem.Id);
                    if (amt < reqItem.Cost)
                    {
                        return(BuyItemError.NotEnoughMoney);
                    }
                }
            }
            return(BuyItemError.Ok);
        }