private static void HandleLoad(GameSession session) { session.Send(MesoMarketPacket.LoadMarket()); session.Send(MesoMarketPacket.AccountStats(session.Player.Account.MesoMarketDailyListings, session.Player.Account.MesoMarketMonthlyPurchases)); List <MesoMarketListing> listings = GameServer.MesoMarketManager.GetListingsByAccountId(session.Player.AccountId); session.Send(MesoMarketPacket.MyListings(listings)); }
private static void HandleRefreshListings(GameSession session, PacketReader packet) { // GMS2 has this set at 5m min and max due to it being Meso Tokens instead of mesos long minMesoRange = packet.ReadLong(); long maxMesoRange = packet.ReadLong(); List <MesoMarketListing> listings = GameServer.MesoMarketManager.GetSearchedListings(minMesoRange, maxMesoRange); session.Send(MesoMarketPacket.LoadListings(listings)); }
private static void HandleCancelListing(GameSession session, PacketReader packet) { long listingId = packet.ReadLong(); MesoMarketListing listing = GameServer.MesoMarketManager.GetListingById(listingId); if (listing is null) { session.Send(MesoMarketPacket.Error((int)MesoMarketError.TryAgain)); return; } MailHelper.SendMesoMarketCancellation(listing, session.Player.CharacterId); session.Send(MesoMarketPacket.CancelListing(listing.Id)); GameServer.MesoMarketManager.RemoveListing(listing); DatabaseManager.MesoMarketListings.Delete(listingId); }
private static void HandlePurchase(GameSession session, PacketReader packet) { long listingId = packet.ReadLong(); if (session.Player.Account.MesoMarketMonthlyPurchases >= int.Parse(ConstantsMetadataStorage.GetConstant("MesoMarketMonthlyPurchaseLimit"))) { return; } MesoMarketListing listing = GameServer.MesoMarketManager.GetListingById(listingId); if (listing is null) { session.Send(MesoMarketPacket.Error((int)MesoMarketError.ItemSoldOut)); return; } if (!session.Player.Account.MesoToken.Modify(-listing.Price)) { session.Send(MesoMarketPacket.Error((int)MesoMarketError.NotEnoughMesos)); return; } if (listing.OwnerAccountId == session.Player.AccountId) { session.Send(MesoMarketPacket.Error((int)MesoMarketError.CantPurchaseOwnMeso)); return; } session.Player.Account.MesoMarketMonthlyPurchases++; DatabaseManager.Accounts.Update(session.Player.Account); session.Send(MesoMarketPacket.Purchase(listingId)); session.Send(MesoMarketPacket.AccountStats(session.Player.Account.MesoMarketDailyListings, session.Player.Account.MesoMarketMonthlyPurchases)); MailHelper.MesoMarketTransaction(listing, session.Player.CharacterId); GameServer.MesoMarketManager.RemoveListing(listing); DatabaseManager.MesoMarketListings.Delete(listingId); }
private static void HandleCreateListing(GameSession session, PacketReader packet) { long mesos = packet.ReadLong(); long price = packet.ReadLong(); if (session.Player.Account.MesoMarketDailyListings >= int.Parse(ConstantsMetadataStorage.GetConstant("MesoMarketDailyListingsLimit"))) { session.Send(MesoMarketPacket.Error((int)MesoMarketError.ReachedListingLimit)); return; } if (!session.Player.Wallet.Meso.Modify(-mesos)) { session.Send(MesoMarketPacket.Error((int)MesoMarketError.NotEnoughMesosToList)); return; } MesoMarketListing listing = new(session.Player, price, mesos); session.Player.Account.MesoMarketDailyListings++; DatabaseManager.Accounts.Update(session.Player.Account); session.Send(MesoMarketPacket.CreateListing(listing)); session.Send(MesoMarketPacket.AccountStats(session.Player.Account.MesoMarketDailyListings, session.Player.Account.MesoMarketMonthlyPurchases)); }