Beispiel #1
0
        public bool Expects()
        {
            var room = getRoom(Context.Story.Location);

            if (room == Context.Story.Location)
            {
                // do nothing
            }
            else if (room == null)
            {
                Print(Context.Story.Location.CantGo);
            }
            else
            {
                MovePlayer.To(room);
            }

            return(true);
        }
Beispiel #2
0
        public void Run()
        {
            var story = Context.Story;

            story.Initialize();

            MovePlayer.To(story.Location);

            while (!story.IsDone)
            {
                var  room   = CurrentRoom.Location;
                bool wasLit = CurrentRoom.IsLit();

                var parser = new CommandLineParser();
                var result = parser.Parse(CommandPrompt.GetInput());

                if (result.Error.HasValue())
                {
                    Output.Print(result.Error);
                }
                else
                {
                    var handler = result.CommandHandler();
                    handler.Run();
                }

                if (!wasLit && CurrentRoom.IsLit() && CurrentRoom.Location == room)
                {
                    CurrentRoom.Look(true);
                }

                if (wasLit && !CurrentRoom.IsLit())
                {
                    Output.Print("\r\nIt is now pitch dark in here!");
                }

                story.Moves++;

                RunDaemons();

                story.AfterTurn();
            }
        }