Exemplo n.º 1
0
        public void Run()
        {
            pub.Log("Arrived", LogBox.Bartender);

            Task.Run(() =>
            {
                while (pub.IsOpen || (pub.WaitingPatrons.Count + pub.BarDisk.Count) > 0)
                {
                    if (currentPatron == null)
                    {
                        TryGetPatron();
                    }
                    else
                    {
                        if (currentGlass == null)
                        {
                            TryGetGlass();
                        }
                        else
                        {
                            pub.Log($"Pouring beer for {currentPatron.Name}", LogBox.Bartender);
                            Thread.Sleep((int)(pub.Options.BartenderPourTiming / pub.Options.Speed));
                            pub.mainWindow.pauseBartender.WaitOne();
                            lock (pub.BarDisk)
                            {
                                pub.BarDisk.Add(currentPatron, currentGlass);
                            }
                            currentPatron = null;
                            currentGlass  = null;
                        }
                    }
                }
                WaitForPatronsAndLoveInterestWaitress();
            }, pub.mainWindow.token);
        }
Exemplo n.º 2
0
        private void TryGetGlass()
        {
            pub.mainWindow.pauseBartender.WaitOne();

            if (pub.Shelf.TryPeek(out _))
            {
                pub.Log("Getting glass", LogBox.Bartender);
                Thread.Sleep((int)(pub.Options.BartenderGlassTiming / pub.Options.Speed));
                pub.mainWindow.pauseBartender.WaitOne();

                pub.Shelf.TryPop(out Glass glass);
                currentGlass = glass;
                pub.Log("Got glass", LogBox.Bartender);
                return;
            }
        }
Exemplo n.º 3
0
 private void WaitForGlass()
 {
     while (true)
     {
         pub.mainWindow.pauseBouncerAndPatrons.WaitOne();
         if (pub.BarDisk.ContainsKey(this))
         {
             lock (pub.PatronLock)
             {
                 this.glass = pub.BarDisk[this];
                 pub.BarDisk.Remove(this);
             }
             pub.Log($"{Name} got a glass", LogBox.Patron);
             return;
         }
         Thread.Sleep(50);
     }
 }
Exemplo n.º 4
0
 private void ReturnGlass(Glass glass)
 {
     EventMessage = "Returning glass to shelf";
     Instance.Glasses.Enqueue(glass);
 }
Exemplo n.º 5
0
 private void DishGlass(Glass glass)
 {
     EventMessage = "Dishing glass";
     Thread.Sleep(2000);
     ReturnGlass(glass);
 }