private void Move(Room room) { Room nextRoom = room; if (!CurrentRoom.IsLit() && !room.Light) { room = Rooms.Get <Darkness>(); } Context.Story.Location = room; if (!room.Visited) { CurrentRoom.Look(true); room.Initial?.Invoke(); } else { if (!CurrentRoom.IsLit() && room.Visited) { nextRoom.DarkToDark(); } CurrentRoom.Look(false); } room.Visited = true; Context.Story.Location = nextRoom; }
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(); } }