// Market public DbMarketData GetMarketData(int id) { DbMarketData ret = new DbMarketData(_db, id); if (ret.IsNull) { return(null); } return(ret); }
public static void CleanMarket(Database db) { var allOffers = db.Conn.HashGetAll("market"); foreach (var i in allOffers) { DbMarketData l = JsonConvert.DeserializeObject <DbMarketData>(i.Value); if (l.TimeLeft < DateTime.UtcNow.ToUnixTimestamp()) // Market has been up its max time, remove it from marketplace. { DbAccount owner = db.GetAccount(l.SellerId); // Owner should never be null, as SellerId should ALWAYS be a valid account id. db.RemoveMarketData(owner, l.Id); db.AddGift(owner, l.ItemType); } } }
public static DbMarketData[] Get(IDatabase db, ushort itemType) { List <DbMarketData> ret = new List <DbMarketData>(); var allOffers = db.HashGetAll("market"); foreach (var i in allOffers) { DbMarketData l = JsonConvert.DeserializeObject <DbMarketData>(i.Value); if (l.ItemType == itemType) { ret.Add(l); } } return(ret.ToArray()); }
// Market public void AddMarketData(DbAccount acc, ushort itemType, int sellerId, string sellerName, int price, int timeLeft, CurrencyType currency) { int marketId = DbMarketData.NextId(Conn); DbMarketData data = new DbMarketData(_db, marketId); data.ItemType = itemType; data.SellerName = sellerName; data.SellerId = sellerId; data.Currency = currency; data.Price = price; data.StartTime = DateTime.UtcNow.ToUnixTimestamp(); data.TimeLeft = timeLeft; data.Flush(); AddPlayerOffer(acc, marketId); }
public void CleanMarket() { DbMarketData.CleanMarket(this); }