Beispiel #1
0
        public void New_Guest_Get_Refused_When_Unable_To_Upgrade_Room()
        {
            foreach (Room r in _Hotel.iRoom.OfType <Room>())
            {
                if (r.Available == true && r.Classification == "2 stars" || r.Classification == "3 stars" || r.Classification == "4 stars" || r.Classification == "5 stars")
                {
                    r.Available = false;
                }
            }

            hotelEvent = new HotelEvent()
            {
                Data = new Dictionary <string, string> {
                    { "Gast2", "Checkin 2stars" }
                },
                EventType = HotelEventType.CHECK_IN,
                Message   = "Checkin 2stars",
                Time      = 2000
            };

            hel.Notify(hotelEvent);

            bool actualResult   = _Hotel.Humans.Exists(g => g.Name == "Gast2");
            bool expectedResult = false;

            Assert.AreEqual(expectedResult, actualResult);
        }
Beispiel #2
0
        /// <summary>
        /// Assigns a Room to a Customer if their in the CustomerQueue. Checks if there's a room that fits with the Customer and assigns it to the Customer.
        /// </summary>
        public void GuestCheckIn()
        {
            if (CustomerQueue.Count > 0)
            {
                //Get's the HotelEvent from the Queue
                HotelEvent hotelEvent = CustomerQueue.Dequeue();
                //Creates a temporary List that saves the free rooms that fits the Customer's specifications
                List <Room> AvaiableRooms = new List <Room>();
                //Get's the classification that the Customer wants (saved into the HotelEvent.Data Dictionairy)
                int Classification = PullIntsFromString(hotelEvent.Data.Values.First());

                //The new Customer is created here
                Customer NewCustomer = (Customer)HumanFactory.CreateHuman(EHumanType.Customer);

                //While loop continues to check if there's a room free for the customer with the set Classification (or higher, but lower than 6)
                while (NewCustomer.AssignedRoom == null && Classification <= 5)
                {
                    for (int i = 0; i < GlobalStatistics.Rooms.Count; i++)
                    {
                        if (Classification == 0 && GlobalStatistics.Rooms[i].RoomOwner is null && GlobalStatistics.Rooms[i].IsDirty == false)
                        {
                            AvaiableRooms.Add(GlobalStatistics.Rooms[i]);
                        }
                        else if (GlobalStatistics.Rooms[i].Classification == Classification && GlobalStatistics.Rooms[i].RoomOwner is null && GlobalStatistics.Rooms[i].IsDirty == false)
                        {
                            AvaiableRooms.Add(GlobalStatistics.Rooms[i]);
                        }
                    }
        public void GOTO_FITNESS_Guest_Gets_Notified()
        {
            hotelEvent = new HotelEvent()
            {
                Data = new Dictionary <string, string> {
                    { "Gast7", "Checkin 1stars" }
                },
                EventType = HotelEventType.CHECK_IN,
                Message   = "Checkin 1stars",
                Time      = 2000
            };
            hel.Notify(hotelEvent);

            hotelEvent = new HotelEvent()
            {
                Data = new Dictionary <string, string> {
                    { "Gast", "7" }, { "HTE", "10" }
                },
                EventType = HotelEventType.GOTO_FITNESS,
                Message   = "",
                Time      = 2000
            };
            hel.Notify(hotelEvent);

            bool expectedResult = true;
            bool actualResult   = _Hotel.Humans.OfType <Guest>().Single(g => g.Name == "Gast7").NeedWorkout;

            Assert.AreEqual(expectedResult, actualResult);
        }
        public void NEED_FOOD_Guest_Goes_To_Restaurant()
        {
            hotelEvent = new HotelEvent()
            {
                Data = new Dictionary <string, string> {
                    { "Gast6", "Checkin 1stars" }
                },
                EventType = HotelEventType.CHECK_IN,
                Message   = "Checkin 1stars",
                Time      = 2000
            };
            hel.Notify(hotelEvent);

            hotelEvent = new HotelEvent()
            {
                Data = new Dictionary <string, string> {
                    { "Gast", "6" }
                },
                EventType = HotelEventType.NEED_FOOD,
                Message   = "",
                Time      = 2000
            };
            hel.Notify(hotelEvent);

            string expectedResult = "Restaurant";
            string actualResult   = _Hotel.Humans.OfType <Guest>().Single(g => g.Name == "Gast6").Path.First().AreaType;

            Assert.AreEqual(expectedResult, actualResult);
        }
        public void EVACUATE_Everyone_Gets_Notified()
        {
            hotelEvent = new HotelEvent()
            {
                EventType = HotelEventType.EVACUATE,
                Message   = "Fire on floor 3",
                Time      = 2000
            };
            hel.Notify(hotelEvent);

            bool expectedResult = true;
            bool actualResult   = true;

            foreach (Guest guest in _Hotel.Humans.OfType <Guest>())
            {
                if (!guest.CheckingOut)
                {
                    if (!guest.Evacuating)
                    {
                        actualResult = guest.Evacuating;
                    }
                }
            }
            Assert.AreEqual(expectedResult, actualResult);
        }
        public void GOTO_CINEMA_Guest_Goes_To_Cinema()
        {
            hotelEvent = new HotelEvent()
            {
                Data = new Dictionary <string, string> {
                    { "Gast10", "Checkin 1stars" }
                },
                EventType = HotelEventType.CHECK_IN,
                Message   = "Checkin 1stars",
                Time      = 2000
            };
            hel.Notify(hotelEvent);

            hotelEvent = new HotelEvent()
            {
                Data = new Dictionary <string, string> {
                    { "Gast", "10" }
                },
                EventType = HotelEventType.GOTO_CINEMA,
                Message   = "",
                Time      = 2000
            };
            hel.Notify(hotelEvent);

            string expectedResult = "Cinema";
            string actualResult   = _Hotel.Humans.OfType <Guest>().Single(g => g.Name == "Gast10").Path.First().AreaType;

            Assert.AreEqual(expectedResult, actualResult);
        }
        public void NEED_FOOD_Guest_Gets_Notified()
        {
            hotelEvent = new HotelEvent()
            {
                Data = new Dictionary <string, string> {
                    { "Gast5", "Checkin 1stars" }
                },
                EventType = HotelEventType.CHECK_IN,
                Message   = "Checkin 1stars",
                Time      = 2000
            };
            hel.Notify(hotelEvent);

            hotelEvent = new HotelEvent()
            {
                Data = new Dictionary <string, string> {
                    { "Gast", "5" }
                },
                EventType = HotelEventType.NEED_FOOD,
                Message   = "",
                Time      = 2000
            };
            hel.Notify(hotelEvent);

            bool expectedResult = true;
            bool actualResult   = _Hotel.Humans.OfType <Guest>().Single(g => g.Name == "Gast5").NeedFood;

            Assert.AreEqual(expectedResult, actualResult);
        }
Beispiel #8
0
        public void CheckEventsTest_Need_Food()
        {
            HotelEvent evt = new HotelEvent()
            {
                EventType = HotelEventType.NEED_FOOD, Data = new Dictionary <string, string> {
                    { "Gast", "1" }
                }
            };

            listener.Events.Add(evt);
            hotel.Areas.Add(new Restaurant {
                Position = new Vector2(1, 0), AreaType = "Restaurant"
            });
            Node n1 = new Node(hotel.Areas.Find(type => type.AreaType == "Restaurant").Position);
            Node n2 = new Node(customers.Find(id => id.ID == 1).Position);

            n1.Edges.Add(n2, 1);
            n2.Edges.Add(n1, 1);
            simplePath.Add(n1);
            simplePath.Add(n2);

            eventChecker.CheckEvents(simplePath, hotel, persons, reception, customers, listener, lobby, elevator, cleaner, cleaners, gameTime, RoomQueue);

            Assert.AreEqual(1, ((Restaurant)hotel.Areas.Find(type => type.AreaType == "Restaurant")).HuidigeBezetting);
        }
Beispiel #9
0
        public void CheckEventsTest_Fitness()
        {
            HotelEvent evt = new HotelEvent()
            {
                EventType = HotelEventType.GOTO_FITNESS, Data = new Dictionary <string, string> {
                    { "Gast", "1" }, { "HTE", "8" }
                }
            };

            listener.Events.Add(evt);
            hotel.Areas.Add(new Fitness {
                Position = new Vector2(1, 0), AreaType = "Fitness"
            });
            Node n1 = new Node(hotel.Areas.Find(type => type.AreaType == "Fitness").Position);
            Node n2 = new Node(customers.Find(id => id.ID == 1).Position);

            n1.Edges.Add(n2, 1);
            n2.Edges.Add(n1, 1);
            simplePath.Add(n1);
            simplePath.Add(n2);

            eventChecker.CheckEvents(simplePath, hotel, persons, reception, customers, listener, lobby, elevator, cleaner, cleaners, gameTime, RoomQueue);

            Assert.AreEqual(customers.Find(id => id.ID == 1).Destination, hotel.Areas.Find(type => type.AreaType == "Fitness").Position);
        }
Beispiel #10
0
 /// <summary>
 /// Handles an evacuate event
 /// </summary>
 /// <param name="evt">The given event</param>
 public void Notify(HotelEvent evt)
 {
     if (evt.EventType == HotelEventType.EVACUATE)
     {
         Status = MovableStatus.EVACUATING;
     }
 }
Beispiel #11
0
        public void Rooms_Get_Dirty_After_Checkout()
        {
            hotelEvent = new HotelEvent()
            {
                Data = new Dictionary <string, string> {
                    { "Gast", "Checkin 2stars" }
                },
                EventType = HotelEventType.CHECK_IN,
                Message   = "Checkin 2stars",
                Time      = 2000
            };
            hel.Notify(hotelEvent);


            hotelEvent = new HotelEvent()
            {
                Data = new Dictionary <string, string> {
                    { "Gast", "" }
                },
                EventType = HotelEventType.CHECK_OUT,
                Message   = "Check out",
                Time      = 2000
            };
            hel.Notify(hotelEvent);

            bool expectedResult = true;
            var  gasten         = _Hotel.Humans.OfType <Guest>();
            bool actualResult   = _Hotel.Humans.OfType <Guest>().Single(g => g.Name == "Gast").Room.Dirty;

            Assert.AreEqual(expectedResult, actualResult);
        }
Beispiel #12
0
        /// <summary>
        /// An event that's called everytime the HotelEventManager pushes out an HotelEvent.
        /// </summary>
        /// <param name="Event">The HotelEvent containing event information.</param>
        public void Notify(HotelEvent Event)
        {
            #region START_CINEMA
            //In this case we only need to check for the relevant HotelEventType, which is START_CINEMA
            if (Event.EventType == HotelEventType.START_CINEMA)
            {
                if (Event.Data.Keys.First() == "ID" && PullIntsFromString(Event.Data.Values.ToList())[0] == ID)
                {
                    //Set the progress int to the length of the Movie
                    MovieProgress = MovieTime;

                    //Tell customers that the movie has started and that they can't enter
                    MovieStarted = true;

                    //Change the Sprite of the cinema so it's easier to see if the movie has started or not
                    Sprite = Sprites.Cinema_Start;

                    //Placing all the Customers in line into the Cinema
                    InCinema = new HashSet <Customer>(WaitingLine);
                    WaitingLine.Clear();

                    //Telling all the Customers in the Cinema that the movie has started
                    foreach (Customer customer in InCinema)
                    {
                        customer.InCinema(MovieTime, this);
                    }
                }
            }
            #endregion
        }
Beispiel #13
0
        public void CheckEventsTest_StartCinema()
        {
            HotelEvent evt = new HotelEvent()
            {
                EventType = HotelEventType.START_CINEMA, Data = new Dictionary <string, string> {
                    { "ID", "9" }
                }
            };

            listener.Events.Add(evt);
            hotel.Areas.Add(new Cinema {
                Position = new Vector2(1, 0), AreaType = "Cinema", ID = 9
            });
            Node n1 = new Node(hotel.Areas.Find(type => type.AreaType == "Cinema").Position);
            Node n2 = new Node(customers.Find(id => id.ID == 1).Position);

            n1.Edges.Add(n2, 1);
            n2.Edges.Add(n1, 1);
            simplePath.Add(n1);
            simplePath.Add(n2);

            eventChecker.CheckEvents(simplePath, hotel, persons, reception, customers, listener, lobby, elevator, cleaner, cleaners, gameTime, RoomQueue);

            Assert.AreEqual(true, ((Cinema)hotel.Areas.Find(type => type.AreaType == "Cinema")).Started);
        }
Beispiel #14
0
        public void CheckEventsTest_Evac()
        {
            HotelEvent evt = new HotelEvent()
            {
                EventType = HotelEventType.EVACUATE, Data = new Dictionary <string, string> {
                    { "ID", "9" }
                }
            };

            listener.Events.Add(evt);
            hotel.Areas.Add(lobby);
            Node n1 = new Node(lobby.Position);
            Node n2 = new Node(customers.Find(id => id.ID == 1).Position);
            Node n3 = new Node(person2.Position);

            n1.Edges.Add(n2, 1);
            n2.Edges.Add(n1, 1);
            n3.Edges.Add(n1, 1);
            simplePath.Add(n1);
            simplePath.Add(n2);

            eventChecker.CheckEvents(simplePath, hotel, persons, reception, customers, listener, lobby, elevator, cleaner, cleaners, gameTime, RoomQueue);

            Assert.AreEqual(person2.Destination, lobby.Position);
        }
Beispiel #15
0
        public void CheckEventsTest_CLEANING_EMERGENCY()
        {
            HotelEvent evt = new HotelEvent()
            {
                EventType = HotelEventType.CLEANING_EMERGENCY, Data = new Dictionary <string, string> {
                    { "kamer", "9" }, { "HTE", "9" }
                }
            };

            listener.Events.Add(evt);
            Room room2 = new Room()
            {
                ID       = 9,
                AreaType = "Room",
                Position = new Vector2(1, 1),
            };

            room.State = Room.RoomState.Dirty;
            hotel.Areas.Add(room2);
            Node n1 = new Node(room2.Position);
            Node n2 = new Node(cleaner.Position);

            n1.Edges.Add(n2, 1);
            n2.Edges.Add(n1, 1);

            simplePath.Add(n1);
            simplePath.Add(n2);

            eventChecker.CheckEvents(simplePath, hotel, persons, reception, customers, listener, lobby, elevator, cleaner, cleaners, gameTime, RoomQueue);

            Assert.AreEqual(Room.RoomState.Emergency, room2.State);
        }
Beispiel #16
0
        //public void HireAMaid(int cleaningTime)
        //{
        //    Maid maid = new Maid(new Point(0, (hotel.hotelHeight * hotel.roomHeight)), hotel.hotelArray, cleaningTime);
        //    timer.Tick += new EventHandler(maid.HTEElapsed);
        //    hotel.AddThisEntity(maid);
        //}

        //public void AddAGuest()
        //{
        //    Entity guest = entityFactory.CreateEntity("Guest", new Point(0,0), hotel.hotelArray);
        //    hotel.AddThisEntity(guest);
        //}

        //public Simulation(List<LayoutJsonModel> layout, ConfigJsonModel HTE) // constructor
        //{
        //    //scherm en panel fullscreen maken
        //    InitializeComponent();
        //    Rectangle resolution = Screen.PrimaryScreen.Bounds;
        //    this.Size = resolution.Size;
        //    this.WindowState = FormWindowState.Maximized;

        //    // aanmaken, neerzetten en inrichten van het hotel

        //    hotel = GetHotel(layout);
        //    HireMaid();
        //    //HireMaid();
        //    DrawHotel();
        //    SettleHotel(HTE.ElevatorDistanceHTE, HTE.StairDistanceHTE);
        //    hotelPB.BringToFront();

        //    //methode aan timer hangen en timer tijd instellen na aanleiding van de ingestelde HTE
        //    timer.Tick += new EventHandler(OnTimedEvent);
        //    int tijd = Convert.ToInt32(HTE.HTEinSeconds * 1000); // van seconde milisecondes maken
        //    timer.Interval = tijd;
        //    timer.Enabled = true;

        //    // timer voor scherm updates
        //    FrameTimer.Tick += new EventHandler(OnFrameTimerUpdate);
        //    int FPS = 60; // fps instelbaar
        //    FrameTimer.Interval = 1000 / FPS;
        //    FrameTimer.Enabled = true;

        //} // end constructor

        //public Area[,] GetHotel(List<LayoutJsonModel> layout)
        //{
        //    // berekend de hoogte en breedte van het hotel n.a.v layout file
        //    int layoutFileX = layout.Max(t => t.position.X);
        //    int layoutFileY = layout.Max(t => t.position.Y);
        //    hotelWidth = layoutFileX + 3;
        //    hotelHeight = layoutFileY + 1;


        //    Area[,] hotel = new Area[hotelWidth, hotelHeight];


        //    //Point location = new Point(drawX, drawY);
        //    Point location = new Point(0, hotelHeight * roomHeight);
        //    Point arrayLocation;
        //    int star;

        //    // statische basis plaatsen hotel (lift, receptie en trap)
        //    // liften
        //    int ID = 100;
        //    for (int i = 0; i <= layoutFileY; i++)
        //    {
        //        hotel[0, i] = AreaFactory.createArea("ElevatorShaft", ID++, location, new Point(0, i), 1, 1, 0);
        //        // bij eerste kan lift worden aangemaakt en geplaatst in eerste shaft
        //    }
        //    // receptie
        //    hotel[1, 0] = AreaFactory.createArea("Reception", ID++, location, new Point(1, 0), layoutFileX, 1, 0);

        //    //trappen
        //    for (int i = 0; i <= layoutFileY; i++)
        //    {
        //        hotel[layoutFileX + 1, i] = AreaFactory.createArea("Stairwell", ID++, location, new Point(layoutFileX + 1, i), 1, 1, 0);
        //        // bij eerste kan lift worden aangemaakt en geplaatst in eerste shaft
        //    }
        //    // layout (file) afdrukken
        //    foreach (var item in layout)
        //    {
        //        if (item.ID == 0)
        //            item.ID = ID++;

        //        if (!string.IsNullOrWhiteSpace(item.classification))
        //            star = int.Parse(Regex.Replace(item.classification, "[^0-9]+", string.Empty));
        //        else
        //            star = 0;

        //        arrayLocation = new Point(item.position.X, item.position.Y);
        //        hotel[item.position.X, item.position.Y] = AreaFactory.createArea(item.areaType, item.ID, location, arrayLocation, item.dimension.X, item.dimension.Y, star);
        //    }

        //    drawX = (panel1.Width - ((hotelWidth - 1) * roomWidth)) / 2;
        //    drawY = (panel1.Height - ((hotelHeight) * roomHeight)) / 2;
        //    return hotel;
        //}

        //public void DrawHotel()
        //{
        //    btm = new Bitmap((hotelWidth - 1) * roomWidth, hotelHeight * roomHeight);
        //    cgi = Graphics.FromImage(btm);
        //    RefreshHotel();
        //    hotelPB.Click += new EventHandler(ReceptionClickCheck);
        //    hotelPB.Size = btm.Size;
        //    hotelPB.Location = new Point(drawX, drawY);
        //    panel1.Controls.Add(hotelPB);
        //}

        //public void RefreshHotel()
        //{
        //    foreach (Area place in hotel)
        //    {
        //        if (place != null)
        //        {
        //            place.DrawYourself(cgi);
        //        }
        //    }
        //    DrawObjects();

        //    hotelPB.Image = btm;
        //}

        //public void SettleHotel(double stairDistance, double elevatorDistance)
        //{
        //    for (int i = 0; i < hotelWidth; i++)
        //    {
        //        for (int j = 0; j < hotelHeight; j++)
        //        {
        //            // bij liften top en bottom toevoegen
        //            if (hotel[i, j] is ElevatorShaft)
        //            {
        //                if (j > 0)
        //                {
        //                    (hotel[i, j] as ElevatorShaft).bottom = new Neighbour()
        //                    {
        //                        neighbour = (ElevatorShaft)hotel[i, j - 1],
        //                        distance = elevatorDistance
        //                    };
        //                }
        //                if (j < hotelHeight - 1)
        //                {
        //                    (hotel[i, j] as ElevatorShaft).top = new Neighbour()
        //                    {
        //                        neighbour = (ElevatorShaft)hotel[i, j + 1],
        //                        distance = elevatorDistance
        //                    };
        //                }
        //            }
        //            // bij trappen top en bottom toevoegen
        //            if (hotel[i, j] is Stairwell)
        //            {
        //                if (j > 0)
        //                {
        //                    (hotel[i, j] as Stairwell).bottom = new Neighbour()
        //                    {
        //                        neighbour = (Stairwell)hotel[i, j - 1],
        //                        distance = stairDistance
        //                    };
        //                }
        //                if (j < hotelHeight - 1)
        //                {
        //                    (hotel[i, j] as Stairwell).top = new Neighbour()
        //                    {
        //                        neighbour = (Stairwell)hotel[i, j + 1],
        //                        distance = stairDistance
        //                    };
        //                }
        //            }
        //            // bij alle kamers left toevoegen
        //            if (i > 0 && hotel[i, j] != null)
        //            {
        //                int count = 1;
        //                while (hotel[i, j].left == null)
        //                {
        //                    if (hotel[i - count, j] != null)
        //                    {
        //                        //left aanmaken
        //                        hotel[i, j].left = new Neighbour
        //                        {
        //                            neighbour = hotel[i - count, j],
        //                            distance = count
        //                        };
        //                    }
        //                    else
        //                    {
        //                        if (count > hotelWidth + 1) // om oneindige loop te voorkomen
        //                        {
        //                            MessageBox.Show($"Kamer afstand naar links bij kamer \"{hotel[i, j]}\" is groter dan de hotel breedte. Waarschuw uw IT-Beheer!");
        //                            Application.Exit();
        //                            break; // niet nodig maar ja
        //                        }
        //                        count++;
        //                    }
        //                }
        //            }
        //            // bij alle kamers right toevoegen
        //            if (i <= hotelHeight && hotel[i, j] != null)
        //            {
        //                int count = 1;
        //                while (hotel[i, j].right == null)
        //                {
        //                    if (hotel[i + count, j] != null)
        //                    {
        //                        // right aanmaken
        //                        hotel[i, j].right = new Neighbour
        //                        {
        //                            neighbour = hotel[i + count, j],
        //                            distance = count
        //                        };
        //                    }
        //                    else
        //                    {
        //                        if (count > hotelWidth + 1) // om oneindige loop te voorkomen
        //                        {
        //                            MessageBox.Show($"Kamer afstand naar rechts bij kamer \"{hotel[i, j]}\" is groter dan de hotel breedte. Waarschuw uw IT-Beheer!");
        //                            Application.Exit();
        //                            break; // niet nodig maar ja
        //                        }
        //                        count++;
        //                    }
        //                }
        //            }
        //        }
        //    }
        //}

        //public void HireMaid()
        //{
        //    Maid maid = new Maid(new Point(0, (hotelHeight * roomHeight)), hotel);
        //    timer.Tick += new EventHandler(maid.HTEElapsed);
        //    hotelMaids.Add(maid);
        //}

        //public void DrawObjects()
        //{
        //    foreach (Maid maid in hotelMaids)
        //    {
        //        maid.DrawYourself(cgi);
        //    }
        //}
        #endregion

        /// <summary>
        /// On keyboard press mehtod, runs when you press the keyboard with the simulation open
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Simulation_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.Q:     // q, om te testen

                //var test = new myEventListener(hotel);
                //HotelEvent evt = new HotelEvent();
                //evt.Data = new Dictionary<string, string>();
                //evt.Data.Add("kamer", "103");
                //evt.Data.Add("HTE", "10");
                //evt.EventType = HotelEventType.CLEANING_EMERGENCY;
                //test.Notify(evt);

                //Dijkstra ds = new Dijkstra();
                //ds.GetPath(hotel.hotelArray[1, 0], hotel.hotelArray[1, 0]);

                var test = new myEventListener(hotel);
                int i    = 0;
                foreach (Guest guest in hotel.guests)
                {
                    i++;
                    HotelEvent evt = new HotelEvent();
                    evt.Data = new Dictionary <string, string>();
                    evt.Data.Add("Gast", "" + i);
                    evt.EventType = HotelEventType.NEED_FOOD;
                    test.Notify(evt);
                }
                break;

            case Keys.A:
                hotel.Scroll(Hotel.MoveHotelDirection.Left);
                break;

            case Keys.D:
                hotel.Scroll(Hotel.MoveHotelDirection.Right);
                break;

            case Keys.W:
                hotel.Scroll(Hotel.MoveHotelDirection.Up);
                break;

            case Keys.S:
                hotel.Scroll(Hotel.MoveHotelDirection.Down);
                break;

            case Keys.Up:
                hotel.Scroll(Hotel.MoveHotelDirection.TestUp);
                break;

            case Keys.Down:
                hotel.Scroll(Hotel.MoveHotelDirection.TestDown);
                break;

            default:
                break;
            }
        }
Beispiel #17
0
 /// <summary>
 /// een geïmplenteerde functie van de interface
 /// </summary>
 /// <param name="evt">Het hotelevent object van de dll</param>
 public void Notify(HotelEvent evt)
 {
     //als het event type een check out event is
     if (evt.EventType == HotelEventType.CHECK_OUT)
     {
         //roep de checkout functie aan
         _hotel.CheckoutGuest(evt.Data);
     }
 }
Beispiel #18
0
 /// <summary>
 /// een geïmplenteerde functie van de interface
 /// </summary>
 /// <param name="evt">Het hotelevent object van de dll</param>
 public void Notify(HotelEvent evt)
 {
     //als het event type een check in is en test event bevat
     if (evt.EventType == HotelEventType.CHECK_IN && !evt.Message.Contains("TestEvent"))
     {
         //maak een nieuwe gast aan
         _hotel.WelcomeGuest(evt.Data);
     }
 }
        public void EventHandler(HotelEvent evt, Hotel hotel)
        {
            HumanSchematic ThisGuest = new Guest(null, null, null);

            if (evt.Data != null)
            {
                string guestName = evt.Data.Keys.First() + evt.Data.Values.First();
                ThisGuest = (Guest)hotel.humanList.FirstOrDefault(g => g is Guest guest && guest.name.Equals(guestName));
            }
            switch (evt.EventType)
            {
            case HotelEventType.CHECK_IN:
                HumanSchematic newGuest = new Guest(hotel.lobbyNode, evt.Data, hotel.hotelGraph.HotelNodeSet);
                hotel.lobbyNode.HotelObject = newGuest;
                hotel.humanList.Add(newGuest);
                break;

            case HotelEventType.CHECK_OUT:
                ThisGuest.RoomEventFinder(hotel.lobbyNode, evt);
                break;

            case HotelEventType.CLEANING_EMERGENCY:
                HumanSchematic newCleaner = new Cleaner(hotel.lobbyNode, evt.Data, hotel.hotelGraph.HotelNodeSet);
                hotel.lobbyNode.HotelObject = newCleaner;
                hotel.humanList.Add(newCleaner);
                break;

            case HotelEventType.EVACUATE:
                foreach (IHuman human in hotel.humanList)
                {
                    human.RoomEventFinder(hotel.lobbyNode, evt);
                }
                break;

            case HotelEventType.GODZILLA:
                break;

            case HotelEventType.GOTO_CINEMA:
                ThisGuest.RoomEventFinder(hotel.hotelGraph.HotelNodeSet.FirstOrDefault(n => n.RoomData.AreaType.Equals("Cinema")), evt);
                break;

            case HotelEventType.GOTO_FITNESS:
                ThisGuest.RoomEventFinder(hotel.hotelGraph.HotelNodeSet.FirstOrDefault(n => n.RoomData.AreaType.Equals("Fitness")), evt);
                break;

            case HotelEventType.NEED_FOOD:
                ThisGuest.RoomEventFinder(hotel.hotelGraph.HotelNodeSet.FirstOrDefault(n => n.RoomData.AreaType.Equals("Restaurant")), evt);
                break;

            case HotelEventType.START_CINEMA:
                break;

            case HotelEventType.NONE:
                break;
            }
        }
Beispiel #20
0
 /// <summary>
 /// Performs the event handling
 /// </summary>
 /// <param name="evt">The given event</param>
 public void Notify(HotelEvent evt)
 {
     // Checks for a START_CINEMA event.
     // it changes its status and visualize(plays) a movie
     if (evt.EventType.Equals(HotelEventType.START_CINEMA))
     {
         AreaStatus = AreaStatus.PLAYING_MOVIE;
         Art        = Properties.Resources.cinem_playinga;
     }
 }
Beispiel #21
0
 public void RoomEventFinder(HotelNode GoToNode, HotelEvent evt)
 {
     if (evt.EventType.Equals(HotelEventType.CHECK_OUT) || evt.EventType.Equals(HotelEventType.EVACUATE))                                // Checks if this events has to leave the hotel and make the rooms not full.
     {
         hotelRoom.Occupied = false;
         leaveHotel         = true;
         MyRoom.hotelNode.BackgroundImage = Image.FromFile(@"..\..\Resources\Images\Room.png");
     }
     hotelRoomDestination   = (IHotelRoom)GoToNode.HotelObject;
     specificRoomDirections = RoomPathFinder.PathToRoom(hotelNode, GoToNode, hotelNodes);                                                // Uses Dijkstra to find the shortest path to a room. (Location of Human, location of destination, hotel graph)
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="humanParam"></param>
 public Human(MovableParam humanParam)
 {
     // Defining properties / fields
     Settings               = humanParam.Settings;
     PathFinding            = humanParam.PathFinding;
     Xpos                   = 0;
     Ypos                   = 0;
     Size                   = new Size(20, 50);
     Location               = new Node();
     CurrentEvent           = new HotelEvent();
     CurrentEvent.EventType = HotelEventType.NONE;
 }
Beispiel #23
0
        public void TestListnerCinema()
        {
            // arrange
            Cinema     c   = new Cinema();
            HotelEvent evt = new HotelEvent();

            // act
            evt.EventType = HotelEventType.START_CINEMA;
            c.Notify(evt);

            // assert
            Assert.AreEqual(AreaStatus.PLAYING_MOVIE, c.AreaStatus);
        }
 /// <summary>
 /// An event that's called everytime the HotelEventManager pushes out an HotelEvent. The GlobalEventManager will save all the HotelEvent's
 /// </summary>
 /// <param name="Event">The HotelEvent containing event information.</param>
 public void Notify(HotelEvent Event)
 {
     EventHistory.Add(Event);
     #region GODZILLA
     if (Event.EventType == HotelEventType.GODZILLA)
     {
         //We can perform an action here for the Godzilla event
         //That could the same as an EVACUATE event
         //If it is, we can call this object's own Notify Method with a fake Event
         //this.Notify(new HotelEvent() { EventType = HotelEventType.EVACUATE });
         //All we're missing then is the Time, Message and Data for the Event, but the Evacuation will be performed
     }
     #endregion
 }
        public void TestPullIntsFromString()
        {
            //arrange
            Cleaner cleaner;

            //act
            cleaner = new Cleaner();
            HotelEvent Event = new HotelEvent();

            Event.EventType = HotelEventType.EVACUATE;
            cleaner.Notify(Event);

            //assert
            Assert.IsNotNull(cleaner.Path);
        }
Beispiel #26
0
        public void CheckEventsTest_Checkin()
        {
            HotelEvent evt = new HotelEvent()
            {
                EventType = HotelEventType.CHECK_IN, Data = new Dictionary <string, string> {
                    { "Gast1", "Checkin4Stars" }
                }
            };

            listener.Events.Add(evt);

            eventChecker.CheckEvents(simplePath, hotel, persons, reception, customers, listener, lobby, elevator, cleaner, cleaners, gameTime, RoomQueue);

            Assert.AreEqual(3, customers.Count);
        }
 /// <summary>
 /// Get event from notifyer in Hotel. We save it as the CurrentEvent. You have to see that as the brain of cleaner, what he wants to do.
 /// </summary>
 /// <param name="currentEvent"></param>
 public void GetCurrentEvent(HotelEvent _currentEvent)
 {
     // When cleaner is alive
     if (Alive == true)
     {
         if (CurrentEvent.EventType != HotelEventType.CHECK_IN)
         {
             // When cleaner it's status is not evacuate
             if (StatusHuman != StatusHuman.EVACUATE && (Visible) && StatusHuman != StatusHuman.WAITING || _currentEvent.EventType == HotelEventType.EVACUATE)
             {
                 CurrentEvent = _currentEvent;
             }
         }
     }
 }
Beispiel #28
0
        public void New_Guest_Gets_Assigned_A_Room()
        {
            hotelEvent = new HotelEvent()
            {
                Data = new Dictionary <string, string> {
                    { "Gast", "Checkin 2stars" }
                },
                EventType = HotelEventType.CHECK_IN,
                Message   = "Checkin 2stars",
                Time      = 2000
            };

            hel.Notify(hotelEvent);

            Assert.IsNotNull(_Hotel.Humans.OfType <Guest>().Single(g => g.Name == "Gast").Room);
        }
        public void CLEANING_EMERGENCY_Room_Gets_Added_To_DirtyRooms()
        {
            hotelEvent = new HotelEvent()
            {
                Data = new Dictionary <string, string> {
                    { "kamer", "16" }, { "HTE", "6" }
                },
                EventType = HotelEventType.CLEANING_EMERGENCY,
                Message   = "",
                Time      = 2000
            };
            hel.Notify(hotelEvent);

            bool expectedResult = true;
            bool actualResult   = _Hotel.DirtyRooms.Exists(r => r.ID == 16);

            Assert.AreEqual(expectedResult, actualResult);
        }
Beispiel #30
0
        /// <summary>
        /// Handles checkin events and add the ariving guest to the list
        /// </summary>
        /// <param name="evt">The given event</param>
        public void Notify(HotelEvent evt)
        {
            if (evt.EventType.Equals(HotelEventType.CHECK_IN))
            {
                string name    = string.Empty;
                string request = string.Empty;
                int    requestInt;
                int    id = 0;

                if (!(evt.Data is null))
                {
                    foreach (var DataSet in evt.Data)
                    {
                        if (DataSet.Key.Contains("Gast"))
                        {
                            id = int.Parse(Regex.Match(DataSet.Key, @"\d+").Value);
                        }
                    }

                    name    = evt.Data.FirstOrDefault().Key;
                    request = evt.Data.FirstOrDefault().Value;

                    requestInt = int.Parse(Regex.Match(request, @"\d+").Value);
                }
                else
                {
                    // Kill test events
                    return;
                }

                Guest guest = new Guest(this, name, requestInt, new Point(0, HotelHeight), id)
                {
                    Area = HotelAreas.Find(X => X.Position == new Point(0, HotelHeight))
                };

                guest.Area = HotelAreas.Find(X => X.Position == guest.Position);


                guest.Hotel = this;



                ArivingGuests.Add(guest);
            }