Exemple #1
0
        public bool Move(Location newLoc)
        {
            var curLoc        = _advHelper.CurrentLocation;
            var curLocLighted = _advHelper.AdventurerHasALitLamp ||
                                _advHelper.IsCurrentLocationLight;
            var newLocLighted = _advHelper.AdventurerHasALitLamp ||
                                _advHelper.IsLocationLight(newLoc);

            if (newLoc.Id == 11 && newLocLighted)
            {
                _advHelper.SetFlag(AdventureContextFlags.KnowsXYZZY);
            }

            bool isMoved = false;

            // Check if the new location has no exits.
            // If so, add msg and go back to old loc.
            if (newLoc.Exits == null)
            {
                if (!newLocLighted)
                {
                    _responseBuilder.AddToResponse(MsgMnemonic.MovePitchDark, 1);
                }
                else
                {
                    _responseBuilder.AddToResponse(
                        newLoc.Description, 1,
                        newLoc.Description + "\n");
                }
                _responseBuilder.AddToResponse(
                    curLoc.Description,
                    curLoc.Description);
            }
            else
            {
                if (newLocLighted)
                {
                    _responseBuilder.AddToResponse(newLoc.Description);
                }
                else
                {
                    _responseBuilder.AddToResponse(MsgMnemonic.MovePitchDark);
                }
                isMoved = true;
                _advHelper.CurrentLocation = newLoc;
                if (newLocLighted)
                {
                    EnumerateItemsHere();
                }
            }

            return(isMoved);
        }