예제 #1
0
        public QueueResultAdd AddToTradeQueue(TradeEntry <T> trade, ulong userID, bool sudo = false)
        {
            lock (_sync)
            {
                if (UsersInQueue.Any(z => z.UserID == userID) && !sudo)
                {
                    return(QueueResultAdd.AlreadyInQueue);
                }

                if (Hub.Config.ResetHOMETracker && trade.Trade.TradeData is IHomeTrack t)
                {
                    t.Tracker = 0;
                }

                var priority = sudo ? PokeTradeQueue <PK8> .Tier1 : PokeTradeQueue <PK8> .TierFree;
                var queue    = Hub.GetQueue(trade.Type);

                queue.Enqueue(trade.Trade, priority);
                UsersInQueue.Add(trade);

                trade.Trade.Notifier.OnFinish = r =>
                {
                    r.Connection.Log($"Removing {trade.Username}'s request from the queue.");
                    Remove(trade);
                };
                return(QueueResultAdd.Added);
            }
        }
예제 #2
0
 public QueueCheckResult(bool inQueue = false, TradeEntry <T>?detail = default, int position = -1, int queueCount = -1)
 {
     InQueue    = inQueue;
     Detail     = detail;
     Position   = position;
     QueueCount = queueCount;
 }
예제 #3
0
 public bool Remove(TradeEntry <T> detail)
 {
     lock (_sync)
         return(UsersInQueue.Remove(detail));
 }