Example #1
0
        // Move action handler
        // It uses the Maze integration service for fetching the room data
        public void Move(int id, char direction)
        {
            string dir    = direction.ToString().ToUpper();
            var    RoomId = MazeService.GetRoom(id, direction);

            // Null is an edge
            if (RoomId == null)
            {
                DisallowDirection(dir);
                return;
            }
            CurrentRoom = RoomId.Value;
            ResetAllowedDirections();
            var RoomDesc   = MazeService.GetDescription(CurrentRoom);
            var isTrap     = MazeService.CausesInjury(CurrentRoom);
            var isTreasure = MazeService.HasTreasure(CurrentRoom);

            PlayerSteps++;

            Console.WriteLine("[Room Description: {0} ]", RoomDesc);


            if (isTrap)
            {
                VisitedMaze.SetRoom(CurrentRoom, 'O');
                Console.WriteLine("You trapped and your score has been decreased by one.");
                PlayerScore--;
            }
            else if (isTreasure)
            {
                VisitedMaze.SetRoom(CurrentRoom, '€');
                Won = true;
            }
            else if (CurrentRoom != Enterance)
            {
                VisitedMaze.SetRoom(CurrentRoom, 'X');
            }
        }