private void GuestLeaves(Puben pub, PubSettings userPubSettings) { pub.dirtyGlasses.itemCollection.Add(pub.dirtyGlass); LogText?.Invoke($"{Name} leaves the bar", this); pub.chairs.itemBag.Add(pub.chair); pub.guestsInPub--; }
public void BouncerActions(Action <string, object> logText, Puben pub, PubSettings userPubSettings) { while (true) { while (userPubSettings.IsBusWithGuestsComing is true) { if (userPubSettings.OpenCountdown < 100) { userPubSettings.NumberOfEnteringGuests = 15; CreateGuest(logText, pub, userPubSettings); userPubSettings.IsBusWithGuestsComing = false; userPubSettings.NumberOfEnteringGuests = 1; } else if (userPubSettings.OpenCountdown > userPubSettings.BouncerMaxNewGuestTimer) { TimeToWait(pub.random.Next(userPubSettings.BouncerMinNewGuestTimer, userPubSettings.BouncerMaxNewGuestTimer), userPubSettings.PubSimulationSpeed); CreateGuest(logText, pub, userPubSettings); } } if (userPubSettings.OpenCountdown > userPubSettings.BouncerMaxNewGuestTimer) { TimeToWait(pub.random.Next(userPubSettings.BouncerMinNewGuestTimer, userPubSettings.BouncerMaxNewGuestTimer), userPubSettings.PubSimulationSpeed); CreateGuest(logText, pub, userPubSettings); } else if (userPubSettings.OpenCountdown == 0) { logText("Bouncern goes home", this); break; } } }
private void GuestEnter(Puben pub, PubSettings userPubSettings) { pub.guestsInPub++; LogText?.Invoke($"{Name} enters BaBar, and goes to the bar", this); TimeToWait(userPubSettings.GuestWalkToBar, userPubSettings.PubSimulationSpeed); pub.QueueAtBar.Add(this); }
public void CreatePub(PubSettings userPubSettings) { chairs = new ItemsBag <Chair>(); cleanGlasses = new ItemsBag <CleanGlass>(); dirtyGlasses = new ItemsCollection <DirtyGlass>(); trayOfDirtyGlasses = new ItemsBag <GlassOnTray>(); chairs.CreateBagOfItems(new Chair(), userPubSettings.NumOfChairs); cleanGlasses.CreateBagOfItems(new CleanGlass(), userPubSettings.NumOfGlasses); }
public void CreateGuest(Action <string, object> logText, Puben pub, PubSettings pubset) { for (int i = 0; i < pubset.NumberOfEnteringGuests; i++) { Task.Run(() => { Guest guest = new Guest(pub); guest.GuestActions(logText, pub, pubset); Thread.Sleep(10); }); } }
public void GuestActions(Action <string, object> logText, Puben pub, PubSettings userPubSettings) { LogText = logText; GuestEnter(pub, userPubSettings); while (!pub.QueueToChair.Contains(this)) { Thread.Sleep(100); } GuestLookingForChair(pub, userPubSettings); while (pub.chairs.itemBag.Count == 0) { Thread.Sleep(100); } GuestDrinks(pub, userPubSettings); GuestLeaves(pub, userPubSettings); }
private void GuestDrinks(Puben pub, PubSettings userPubSettings) { pub.chairs.itemBag.TryTake(out pub.chair); LogText?.Invoke($"{Name} sits down and drinks the beer", this); TimeToWait(pub.random.Next(userPubSettings.GuestDrinkBeerMinTime, userPubSettings.GuestDrinkBeerMaxTime), userPubSettings.PubSimulationSpeed); }
private void GuestLookingForChair(Puben pub, PubSettings userPubSettings) { LogText?.Invoke($"{Name} takes the beer and looks for a chair", this); TimeToWait(userPubSettings.GuestWalkToChair, userPubSettings.PubSimulationSpeed); }
public void WaiterActions(Action <string, object> printWaiterListBox, Puben pub, PubSettings userPubSettings) { while (userPubSettings.OpenCountdown > 0 || pub.dirtyGlasses.itemCollection.Count > 0 || pub.guestsInPub > 0 || pub.trayOfDirtyGlasses.itemBag.Count > 0) { if (pub.dirtyGlasses.itemCollection.Count == 0) { printWaiterListBox("Waiting for glasses to clean", this); while (pub.dirtyGlasses.itemCollection.Count == 0) { Thread.Sleep(100); } } if (pub.dirtyGlasses.itemCollection.Count > 0) { printWaiterListBox("Picking up dirty glasses", this); TimeToWait(userPubSettings.WaiterPickUpGlassesTime, userPubSettings.PubSimulationSpeed); foreach (var dirtyGlass in pub.dirtyGlasses.itemCollection) { pub.trayOfDirtyGlasses.itemBag.Add(new GlassOnTray()); pub.dirtyGlasses.itemCollection.Take(); } printWaiterListBox("Cleaning glasses", this); TimeToWait(userPubSettings.WaiterCleanGlassesTime, userPubSettings.PubSimulationSpeed); foreach (var glassOnTrayOut in pub.trayOfDirtyGlasses.itemBag) { pub.cleanGlasses.itemBag.Add(new CleanGlass()); pub.trayOfDirtyGlasses.itemBag.TryTake(out pub.glassOnTray); } printWaiterListBox("Putting glasses on shelf", this); } } printWaiterListBox("Waiter goes home", this); userPubSettings.PubOpenButton = true; }
public void BartenderActions(Action <string, object> printBartenderListBox, Puben pub, PubSettings userPubSettings) { while (userPubSettings.OpenCountdown > 0 || pub.guestsInPub > 0) { if (pub.guestsInPub == 0 && userPubSettings.OpenCountdown > 0) { printBartenderListBox("Bartender waiting for guest", this); while (pub.guestsInPub == 0 && userPubSettings.OpenCountdown > 0) { Thread.Sleep(100); } } if (pub.QueueAtBar.Count > 0) { printBartenderListBox("Bartender goes to shelf", this); while (pub.cleanGlasses.itemBag.Count == 0) { Thread.Sleep(100); } if (pub.cleanGlasses.itemBag.Count > 0) { TimeToWait(userPubSettings.BartenderFetchGlassTime, userPubSettings.PubSimulationSpeed); pub.cleanGlasses.itemBag.TryTake(out pub.cleanGlass); printBartenderListBox("Pours beer to " + pub.QueueAtBar.First().Name, this); TimeToWait(userPubSettings.BartenderPourBeerTime, userPubSettings.PubSimulationSpeed); pub.QueueToChair.Add(pub.QueueAtBar.First()); pub.QueueAtBar.Take(); } } if (pub.QueueAtBar.Count == 0 && userPubSettings.OpenCountdown == 0) { printBartenderListBox("Bartender goes home", this); break; } } }