コード例 #1
0
        protected override MethodResult canBuy(MarketOffer offer, ITrader seller, ProductTypeEnum productType)
        {
            if (seller.TraderType != TraderTypeEnum.Shop && IsHouseOffer(offer, seller) == false)
            {
                return(new MethodResult(TraderErrors.YouCannotBuyThat));
            }

            if (offer.CountryID.HasValue)
            {
                if (offer.CountryID != citizen.Region.CountryID)
                {
                    return(new MethodResult(TraderErrors.NotSelledInYourCountry));
                }
            }
            else
            {
                if (seller.RegionID != citizen.RegionID)
                {
                    return(new MethodResult(TraderErrors.NotSelledInYourRegion));
                }
            }



            return(MethodResult.Success);
        }
コード例 #2
0
        private TransactionResult makeLocalCountryTransactionForBuy(MarketOffer offer, Entity buyer, Entity sellerEntity, Country localCountry, OfferCost cost, Currency currency, int amount, int walletID)
        {
            if (cost.VatCost.HasValue == false || cost.VatCost == 0)
            {
                return(TransactionResult.Success);
            }

            var localCountryMoney = new Money()
            {
                Amount   = (decimal)(cost.VatCost),
                Currency = currency
            };

            var localCountryTransaction = new Transaction()
            {
                Arg1 = "Local Country Cost - Market",
                Arg2 = string.Format("{0}({1}) bought {2} {3} from {4}({5})", buyer.Name, buyer.EntityID, amount,
                                     ((ProductTypeEnum)offer.ProductID).ToHumanReadable(), sellerEntity.Name, sellerEntity.EntityID),
                DestinationEntityID = localCountry.ID,
                Money           = localCountryMoney,
                SourceEntityID  = sellerEntity.EntityID,
                TransactionType = TransactionTypeEnum.MarketOfferCost,
                SourceWalletID  = walletID
            };

            return(transactionService.MakeTransaction(localCountryTransaction));
        }
コード例 #3
0
        public OfferCost GetOfferCost(MarketOffer offer, int amount, Region destinationRegion, bool useFuel)
        {
            var destinationCountry = destinationRegion.Country;

            OfferCost cost         = new OfferCost();
            var       sellerRegion = offer.Company.Entity.GetCurrentRegion();


            if (useFuel)
            {
                var buyerRegion = destinationRegion;
                var path        = regionService.GetPathBetweenRegions(buyerRegion, sellerRegion, new TradeRegionSelector(offer.Company.Region.Country, destinationCountry, embargoRepository));

                if (path == null)
                {
                    return(null);
                }

                cost.FuelCost = GetFuelCostForOffer(offer, path, amount);
            }

            cost.Set(CalculateProductCost(amount, offer.Price, offer.Company.Region.CountryID, destinationCountry.ID, (ProductTypeEnum)offer.ProductID));
            cost.CurrencyID = offer.CurrencyID;



            cost.FuelCost = Math.Round(cost.FuelCost, 2);

            return(cost);
        }
コード例 #4
0
        public void IsEnoughFuelForTradeSimpleTest()
        {
            MarketOffer offer = offerCreator
                                .SetAmount(10)
                                .Create();

            Assert.IsTrue(marketService.IsEnoughFuelForTrade(fuelInInventory: 10, neededFuel: 10, offer: offer));
        }
コード例 #5
0
        public void IsEnoughFuelForTradeLessThanNeededTest()
        {
            MarketOffer offer = offerCreator
                                .SetAmount(10)
                                .Create();

            Assert.IsFalse(marketService.IsEnoughFuelForTrade(fuelInInventory: 5, neededFuel: 10, offer: offer));
        }
コード例 #6
0
 private static bool IsHouseOffer(MarketOffer offer, ITrader seller)
 {
     if (seller.TraderType == TraderTypeEnum.Company &&
         offer.ProductID == (int)ProductTypeEnum.House)
     {
         return(true);
     }
     return(false);
 }
コード例 #7
0
        protected override MethodResult canBuy(MarketOffer offer, ITrader seller, ProductTypeEnum productType)
        {
            if (seller.TraderType == TraderTypeEnum.Shop)
            {
                return(new MethodResult("You cannot buy that!"));
            }

            return(MethodResult.Success);
        }
コード例 #8
0
        public void IsEnoughFuelForTradeFuelRecompensateJustTest()
        {
            MarketOffer offer = offerCreator
                                .SetAmount(10)
                                .SetProduct(ProductTypeEnum.Fuel)
                                .Create();

            Assert.IsTrue(marketService.IsEnoughFuelForTrade(fuelInInventory: 2, neededFuel: 12, offer: offer));
        }
コード例 #9
0
ファイル: Player.Market.cs プロジェクト: fiowb/RotMG-RPG
        public MarketResult AddToMarket(MarketOffer offer)
        {
            if (Id != offer.Slot.ObjectId)
            {
                return(LogError(MarketResult.InvalidPlayerId));
            }

            return(AddToMarket(offer.Slot.SlotId, offer.Price));
        }
コード例 #10
0
ファイル: HouseService.cs プロジェクト: blendiahmetaj1/SUPSUP
        public MethodResult CanBuyOffer(MarketOffer offer, int amount, House house, Entity entity)
        {
            if (offer == null)
            {
                return(new MethodResult(MarketOfferErrors.OfferNotExist));
            }

            var productType = ((ProductTypeEnum)offer.ProductID);

            if (offer.Amount < amount)
            {
                return(new MethodResult(MarketOfferErrors.NotEnoughProducts));
            }

            if (amount <= 0)
            {
                return(new MethodResult("Are you crazy?"));
            }

            if (productType != ProductTypeEnum.UpgradePoints && productType != ProductTypeEnum.ConstructionMaterials)
            {
                return(new MethodResult(MarketOfferErrors.NotAllowedProduct));
            }

            if (offer.Company.GetCompanyType() != CompanyTypeEnum.Manufacturer)
            {
                return(new MethodResult("You cannot buy that offer!"));
            }

            var cost = marketService.GetOfferCost(offer, entity, amount);

            if (cost == null)
            {
                return(new MethodResult("You cannot buy that offer!"));
            }

            if (walletService.HaveMoney(entity.WalletID, cost.ClientPriceMoney) == false)
            {
                return(new MethodResult(MarketOfferErrors.NotEnoughMoney));
            }

            if (productType == ProductTypeEnum.ConstructionMaterials)
            {
                var chest = houseFurnitureRepository.GetHouseChest(house.ID);

                if (houseChestService.GetUnusedSpace(chest) < amount)
                {
                    return(new MethodResult("You do not have enough space in chest!"));
                }
            }



            return(MethodResult.Success);
        }
コード例 #11
0
        protected override MethodResult canBuy(MarketOffer offer, ITrader seller, ProductTypeEnum productType)
        {
            if (seller.TraderType == TraderTypeEnum.Shop)
            {
                return(new MethodResult("You cannot buy that!"));
            }

            if (equipmentService.GetAllowedProductsForCompany(company).Contains(productType) == false)
            {
                return(new MethodResult("You cannot have that item!"));
            }

            return(MethodResult.Success);
        }
コード例 #12
0
        public MethodResult CanBuy(MarketOffer offer, Entity buyer, Entity seller)
        {
            if (buyer.EntityID == seller.EntityID)
            {
                return(new MethodResult("You cannot buy from yourself!"));
            }

            var traderFactory = new TraderFactory(equipmentService);

            var buyerTrader  = traderFactory.GetTrader(buyer);
            var sellerTrader = traderFactory.GetTrader(seller);

            return(buyerTrader.CanBuy(offer, sellerTrader));
        }
コード例 #13
0
        private TransactionResult makeExportTransactionForBuy(MarketOffer offer, Entity buyer, Entity sellerEntity, OfferCost cost, int amount, int walletID)
        {
            var exportCountry = buyer.GetCurrentCountry();

            var exportTransaction = new Transaction()
            {
                Arg1 = "Export Tax Cost - Market",
                Arg2 = string.Format("{0}({1}) bought {2} {3} from {4}({5})", buyer.Name, buyer.EntityID, amount,
                                     ((ProductTypeEnum)offer.ProductID).ToHumanReadable(), sellerEntity.Name, sellerEntity.EntityID),
                DestinationEntityID = exportCountry.ID,
                Money           = cost.ExportMoney,
                SourceEntityID  = buyer.EntityID,
                TransactionType = TransactionTypeEnum.MarketOfferCost,
                SourceWalletID  = walletID
            };

            return(transactionService.MakeTransaction(exportTransaction));
        }
コード例 #14
0
        public virtual MethodResult CanBuy(MarketOffer offer, ITrader seller)
        {
            var productType = (ProductTypeEnum)offer.ProductID;

            var whoCanBuy = productType.GetEnumAttribute <WhoCanBuyAttribute>();

            if (whoCanBuy.Contains(TraderType) == false)
            {
                return(new MethodResult(TraderErrors.YouCannotBuyThat));
            }

            if (equipmentService.GetAllowedProductsForEntity(EntityType).Contains(productType) == false)
            {
                return(new MethodResult(TraderErrors.YouCannotHaveThat));
            }

            return(canBuy(offer, seller, productType));
        }
コード例 #15
0
        public decimal?GetFuelCostForOffer(MarketOffer offer, Entity buyer)
        {
            var entityType = (EntityTypeEnum)buyer.EntityTypeID;

            if (entityType == EntityTypeEnum.Citizen || entityType == EntityTypeEnum.Newspaper)
            {
                return(null);
            }

            var buyerRegion = buyer.GetCurrentRegion();
            var path        = regionService.GetPathBetweenRegions(buyerRegion, offer.Company.Region, new TradeRegionSelector(offer.Company.Region.Country, buyer.GetCurrentCountry(), embargoRepository));

            if (path == null)
            {
                return(null);
            }

            return(GetFuelCostForOffer(offer, path, 1));
        }
コード例 #16
0
        public MarketOffer AddOffer(AddMarketOfferParameters ps)
        {
            var offer = new MarketOffer()
            {
                Amount    = ps.Amount,
                CompanyID = ps.CompanyID,
                CountryID = ps.CountryID,
                ProductID = (int)ps.ProductType,
                Price     = (decimal)ps.Price,
                Quality   = ps.Quality
            };

            var     company        = companyRepository.GetById(ps.CompanyID);
            Country foreignCountry = null;

            if (ps.CountryID.HasValue)
            {
                foreignCountry = countryRepository.GetById(ps.CountryID.Value);
            }

            offer.CurrencyID = offer.CountryID.HasValue ?
                               Persistent.Countries.GetById(foreignCountry.ID).CurrencyID :
                               Persistent.Countries.GetById(company.Region.CountryID.Value).CurrencyID;

            marketOfferRepository.Add(offer);

            var equipment = equipmentRepository.First(e => e.Entities.FirstOrDefault().EntityID == ps.CompanyID);

            equipmentRepository.RemoveEquipmentItem(equipment.ID, (int)ps.ProductType, ps.Quality, ps.Amount);



            var cost = CalculateProductCost(ps.Amount, ps.Price, company.Region?.CountryID, ps.CountryID, ps.ProductType);



            MakeAddOfferTransactions(cost, company, foreignCountry);

            marketOfferRepository.SaveChanges();

            return(offer);
        }
コード例 #17
0
        protected override void Read(NReader rdr)
        {
            CommandId = rdr.ReadInt32();

            switch (CommandId)
            {
                case (int)Command.ADD_OFFER:
                    NewOffers = new MarketOffer[rdr.ReadInt32()];
                    for (int i = 0; i < NewOffers.Length; i++)
                        NewOffers[i] = MarketOffer.Read(rdr);
                    break;

                case (int)Command.REMOVE_OFFER:
                    OfferId = rdr.ReadUInt32();
                    break;

                case (int)Command.REQUEST_MY_ITEMS:
                default:
                    break;
            }
        }
コード例 #18
0
        private TransactionResult makeCompanyTransactionForBuy(MarketOffer offer, Entity buyer, Entity sellerEntity, OfferCost cost, Currency currency, int amount, int walletID)
        {
            var companyMoney = new Money()
            {
                Amount   = (decimal)(cost.BasePrice),
                Currency = currency
            };


            var companyTransaction = new Transaction()
            {
                Arg1 = "Company Cost - Market",
                Arg2 = string.Format("{0}({1}) bought {2} {3} from {4}({5})", buyer.Name, buyer.EntityID, amount,
                                     ((ProductTypeEnum)offer.ProductID).ToHumanReadable(), sellerEntity.Name, sellerEntity.EntityID),
                DestinationEntityID = sellerEntity.EntityID,
                Money           = companyMoney,
                SourceEntityID  = buyer.EntityID,
                TransactionType = TransactionTypeEnum.MarketOfferCost,
                SourceWalletID  = walletID
            };

            return(transactionService.MakeTransaction(companyTransaction));
        }
コード例 #19
0
        public MethodResult HaveEnoughMoneyToBuy(MarketOffer offer, Entity buyer, int amount)
        {
            MethodResult result = MethodResult.Success;

            var cost = GetOfferCost(offer, buyer, amount);

            var localMoney = walletService.GetWalletMoney(buyer.WalletID, offer.CurrencyID);

            if (localMoney.Amount < cost.BasePrice + cost.ImportTax + cost.VatCost)
            {
                result.AddError("You do not have enough money!");
            }

            if (cost.ExportTax > 0)
            {
                var exportMoney = walletService.GetWalletMoney(buyer.WalletID, cost.ExportCurrencyID);
                if (exportMoney.Amount < cost.ExportTax)
                {
                    result.AddError("You do not have enough money!");
                }
            }

            return(result);
        }
コード例 #20
0
        private void ReloadOffers(GameClient Session)
        {
            int    MinCost     = -1;
            int    MaxCost     = -1;
            string SearchQuery = "";
            int    FilterMode  = 1;


            DataTable     table   = null;
            StringBuilder builder = new StringBuilder();
            string        str     = "";

            builder.Append("WHERE state = '1' AND timestamp >= " + PlusEnvironment.GetGame().GetCatalog().GetMarketplace().FormatTimestampString());
            if (MinCost >= 0)
            {
                builder.Append(" AND total_price > " + MinCost);
            }
            if (MaxCost >= 0)
            {
                builder.Append(" AND total_price < " + MaxCost);
            }
            switch (FilterMode)
            {
            case 1:
                str = "ORDER BY asking_price DESC";
                break;

            default:
                str = "ORDER BY asking_price ASC";
                break;
            }

            using (IQueryAdapter dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT `offer_id`,`item_type`,`sprite_id`,`total_price`,`limited_number`,`limited_stack` FROM `catalog_marketplace_offers` " + builder.ToString() + " " + str + " LIMIT 500");
                dbClient.AddParameter("search_query", "%" + SearchQuery + "%");
                if (SearchQuery.Length >= 1)
                {
                    builder.Append(" AND `public_name` LIKE @search_query");
                }
                table = dbClient.getTable();
            }

            PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItems.Clear();
            PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItemKeys.Clear();
            if (table != null)
            {
                foreach (DataRow row in table.Rows)
                {
                    if (!PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItemKeys.Contains(Convert.ToInt32(row["offer_id"])))
                    {
                        MarketOffer item = new MarketOffer(Convert.ToInt32(row["offer_id"]), Convert.ToInt32(row["sprite_id"]), Convert.ToInt32(row["total_price"]), int.Parse(row["item_type"].ToString()), Convert.ToInt32(row["limited_number"]), Convert.ToInt32(row["limited_stack"]));
                        PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItemKeys.Add(Convert.ToInt32(row["offer_id"]));
                        PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItems.Add(item);
                    }
                }
            }

            Dictionary <int, MarketOffer> dictionary  = new Dictionary <int, MarketOffer>();
            Dictionary <int, int>         dictionary2 = new Dictionary <int, int>();

            foreach (MarketOffer item in PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItems)
            {
                if (dictionary.ContainsKey(item.SpriteId))
                {
                    if (dictionary[item.SpriteId].TotalPrice > item.TotalPrice)
                    {
                        dictionary.Remove(item.SpriteId);
                        dictionary.Add(item.SpriteId, item);
                    }

                    int num = dictionary2[item.SpriteId];
                    dictionary2.Remove(item.SpriteId);
                    dictionary2.Add(item.SpriteId, num + 1);
                }
                else
                {
                    dictionary.Add(item.SpriteId, item);
                    dictionary2.Add(item.SpriteId, 1);
                }
            }

            Session.SendMessage(new MarketPlaceOffersComposer(MinCost, MaxCost, dictionary, dictionary2));
        }
コード例 #21
0
        public MethodResult Buy(MarketOffer offer, Entity buyer, int amount, int walletID)
        {
            using (var scope = transactionScopeProvider.CreateTransactionScope())
            {
                var eqID         = buyer.EquipmentID.Value;
                var sellerEntity = offer.Company.Entity;
                var localCountry = sellerEntity.GetCurrentCountry();

                if (offer.GetProductType() == ProductTypeEnum.House)
                {
                    var houseService = DependencyResolver.Current.GetService <IHouseService>();
                    houseService.CreateHouseForCitizen(buyer.Citizen);
                }
                else
                {
                    equipmentRepository.AddEquipmentItem(eqID, offer.ProductID, offer.Quality, amount);
                }



                var cost = GetOfferCost(offer, buyer, amount);

                if (sellerEntity.Company.CompanyTypeID == (int)CompanyTypeEnum.Shop)
                {
                    equipmentRepository.RemoveEquipmentItem(sellerEntity.EquipmentID.Value, (int)ProductTypeEnum.SellingPower, 1, amount);
                }

                if (buyer.EntityTypeID == (int)EntityTypeEnum.Company)
                {
                    UseFuelInBuyProcess(eqID, cost);
                }

                var currency = Persistent.Currencies.First(c => c.ID == offer.CurrencyID);

                if (makeCompanyTransactionForBuy(offer, buyer, sellerEntity, cost, currency, amount, walletID) != TransactionResult.Success)
                {
                    return(MethodResult.Failure);
                }

                if (makeLocalCountryTransactionForBuy(offer, buyer, sellerEntity, localCountry, cost, currency, amount, walletID) != TransactionResult.Success)
                {
                    return(MethodResult.Failure);
                }

                //there is no vat because company is not paying vat (directly). Citizen is paying the vat.
                ICompanyFinance[] finances = new ICompanyFinance[] {
                    new SellRevenueFinance(cost.BasePrice, currency.ID),
                };

                companyFinanceSummaryService.AddFinances(offer.Company, finances);

                /*if (cost.ExportTax > 0)
                 * {
                 *  makeExportTransactionForBuy(offer, buyer, sellerEntity, cost, amount);
                 * }*/

                offer.Amount -= amount;
                if (offer.Amount <= 0)
                {
                    marketOfferRepository.Remove(offer.ID);
                }

                equipmentRepository.SaveChanges();
                scope.Complete();

                return(MethodResult.Success);
            }
        }
コード例 #22
0
 public MethodResult CanBuyOffer(MarketOffer offer, int amount, Entity entity)
 {
     return(CanBuyOffer(offer, amount, entity, entity.WalletID));
 }
コード例 #23
0
        public MethodResult CanBuyOffer(MarketOffer offer, int amount, Entity entity, int walletID)
        {
            if (offer == null)
            {
                return(new MethodResult(MarketOfferErrors.OfferNotExist));
            }

            var productType = ((ProductTypeEnum)offer.ProductID);

            if (offer.Amount < amount)
            {
                return(new MethodResult(MarketOfferErrors.NotEnoughProducts));
            }

            if (amount <= 0)
            {
                return(new MethodResult("Are you crazy?"));
            }

            if (amount > 1 && offer.GetProductType() == ProductTypeEnum.House)
            {
                return(new MethodResult("You cannot buy more than 1 house at same moment!"));
            }

            if (equipmentService.IsAllowedItemFor(entity, productType) == false)
            {
                return(new MethodResult(MarketOfferErrors.NotAllowedProduct));
            }

            var result = CanBuy(offer, entity, offer.Company.Entity);

            if (result.IsError)
            {
                return(result);
            }


            var cost = GetOfferCost(offer, entity, amount);

            if (cost == null)
            {
                return(new MethodResult("You cannot buy that offer!"));
            }

            if (walletService.HaveMoney(walletID, cost.ClientPriceMoney) == false)
            {
                return(new MethodResult(MarketOfferErrors.NotEnoughMoney));
            }

            if (offer.Company.CompanyTypeID == (int)CompanyTypeEnum.Shop && (equipmentRepository.GetEquipmentItem(offer.Company.Entity.EquipmentID.Value, (int)ProductTypeEnum.SellingPower, 1)?.Amount ?? 0) < amount)
            {
                return(new MethodResult("Shop does not have enough selling power!"));
            }

            if (entity.EntityTypeID != (int)EntityTypeEnum.Citizen && cost.FuelCost > 0)
            {
                var fuel = equipmentRepository.GetEquipmentItem(entity.EquipmentID.Value, (int)ProductTypeEnum.Fuel, 1);

                if (IsEnoughFuelForTrade(fuel?.Amount, cost.IntegerRealCost, offer) == false)
                {
                    return(new MethodResult(MarketOfferErrors.NotEngouhFuel));
                }
            }


            var equipment = entity.Equipment;

            if (equipment.CanAddNewItem(amount) == false)
            {
                return(new MethodResult("You do not have enough space in inventory"));
            }

            if (offer.GetProductType() == ProductTypeEnum.House)
            {
                var houseService = DependencyResolver.Current.GetService <IHouseService>();
                if (houseService.CanCreateHouseForCitizen(entity.Citizen).IsError)
                {
                    return(new MethodResult("You already have house in this region!"));
                }
            }



            return(MethodResult.Success);
        }
コード例 #24
0
        public virtual bool IsEnoughFuelForTrade(int?fuelInInventory, int neededFuel, MarketOffer offer)
        {
            fuelInInventory = fuelInInventory ?? 0;
            if (neededFuel > 0 == false)
            {
                return(true);
            }

            if (offer.GetProductType() == ProductTypeEnum.Fuel)
            {
                neededFuel -= offer.Amount;
            }

            return(fuelInInventory >= neededFuel);
        }
コード例 #25
0
 public OfferCost GetOfferCost(MarketOffer offer, Entity buyer, int amount)
 {
     return(GetOfferCost(offer, amount, buyer.GetCurrentRegion(), CanUseFuel(buyer)));
 }
コード例 #26
0
 public static ProductTypeEnum GetProductType(this MarketOffer offer)
 {
     return((ProductTypeEnum)offer.ProductID);
 }
コード例 #27
0
 private decimal GetFuelCostForOffer(MarketOffer offer, Path path, int amount)
 {
     return(productService.GetFuelCostForTranposrt(path, (ProductTypeEnum)offer.ProductID, offer.Quality, amount));
 }
コード例 #28
0
        private static void ReloadOffers(GameClient session)
        {
            const int minCost     = -1;
            const int maxCost     = -1;
            var       searchQuery = "";
            const int filterMode  = 1;

            DataTable table;
            var       builder = new StringBuilder();
            string    str;

            builder.Append("WHERE `state` = '1' AND `timestamp` >= " + PlusEnvironment.GetGame().GetCatalog().GetMarketplace().FormatTimestampString());

            switch (filterMode)
            {
            case 1:
                str = "ORDER BY `asking_price` DESC";
                break;
            }

            using (var dbClient = PlusEnvironment.GetDatabaseManager().GetQueryReactor())
            {
                dbClient.SetQuery("SELECT `offer_id`,`item_type`,`sprite_id`,`total_price`,`limited_number`,`limited_stack` FROM `catalog_marketplace_offers` " + builder + " " +
                                  str + " LIMIT 500");
                dbClient.AddParameter("search_query", "%" + searchQuery + "%");
                if (searchQuery.Length >= 1)
                {
                    builder.Append(" AND `public_name` LIKE @search_query");
                }
                table = dbClient.GetTable();
            }

            PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItems.Clear();
            PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItemKeys.Clear();

            if (table != null)
            {
                foreach (DataRow row in table.Rows)
                {
                    if (PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItemKeys.Contains(Convert.ToInt32(row["offer_id"])))
                    {
                        continue;
                    }

                    var item = new MarketOffer(Convert.ToInt32(row["offer_id"]), Convert.ToInt32(row["sprite_id"]), Convert.ToInt32(row["total_price"]),
                                               int.Parse(row["item_type"].ToString()), Convert.ToInt32(row["limited_number"]), Convert.ToInt32(row["limited_stack"]));
                    PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItemKeys.Add(Convert.ToInt32(row["offer_id"]));
                    PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItems.Add(item);
                }
            }

            var dictionary  = new Dictionary <int, MarketOffer>();
            var dictionary2 = new Dictionary <int, int>();

            foreach (var item in PlusEnvironment.GetGame().GetCatalog().GetMarketplace().MarketItems)
            {
                if (dictionary.ContainsKey(item.SpriteId))
                {
                    if (dictionary[item.SpriteId].TotalPrice > item.TotalPrice)
                    {
                        dictionary.Remove(item.SpriteId);
                        dictionary.Add(item.SpriteId, item);
                    }

                    var num = dictionary2[item.SpriteId];
                    dictionary2.Remove(item.SpriteId);
                    dictionary2.Add(item.SpriteId, num + 1);
                }
                else
                {
                    dictionary.Add(item.SpriteId, item);
                    dictionary2.Add(item.SpriteId, 1);
                }
            }

            session.SendPacket(new MarketPlaceOffersComposer(minCost, maxCost, dictionary, dictionary2));
        }
コード例 #29
0
 public MethodResult Buy(MarketOffer offer, Entity buyer, int amount)
 {
     return(Buy(offer, buyer, amount, buyer.WalletID));
 }
コード例 #30
0
 protected abstract MethodResult canBuy(MarketOffer offer, ITrader seller, ProductTypeEnum productType);