예제 #1
0
        public void Direction_commands_change_location(CmdDirection direction, int newX, int newY)
        {
            var newCoord = new Coord(newX, newY);

            player.MoveTo((2, 2));
            var cmd = new Command(CmdAction.Direction, direction, null);

            _controls.CommandBeing(player, cmd);

            Assert.That(player.GetPosition(), Is.EqualTo(newCoord));
            var mapPosition = _gameState.Map.BeingMap.GetPosition(player);

            Assert.That(mapPosition, Is.EqualTo(newCoord));
        }
예제 #2
0
        /// <summary> 0.2:  Currently, grab the topmost.  Later, choose. </summary>
        public Command PickUp(IBeing being)
        {
            var items   = gameState.Map.ItemMap.GetItems(being.GetPosition());
            var topItem = items.LastOrDefault();

            if (topItem == null)
            {
                return(CancelMultiStep("Nothing to pick up here."));
            }

            return(FinishedCommand(CmdAction.PickUp, CmdDirection.None, topItem));
        }
예제 #3
0
        private Command Direction(IBeing being, CmdDirection dir)
        {
            var newPosition = Controls.CoordInDirection(being.GetPosition(), dir);

            var targetRot = gameState.Map.RotMap.GetItem(newPosition);

            if (targetRot != null)
            {
                //0.1.STORY  increase impact--this is an early landmark in the story
                if (!Story.HasClearedRot)
                {
                    rotDirection = dir;
                    Messager.WriteLine("The filth covering the ground sets my teeth on edge.  I'm growling.");
                    return(NextStepIs(Direction_decide_to_Clear_Rot, "Am I going after this stuff bare-handed? ", being));
                }
            }

            return(FinishedCommand(CmdAction.Direction, dir));
        }
예제 #4
0
        public Command Direction_decide_to_Clear_Rot(AsciiKey press, IBeing being)
        {
            //  Decision mechanic: hit 'y', or travel in a direction
            // towards rot (in which case, the decision direction will
            // be the attack direction, even if different from the original
            // direction).  Any other response cancels move/attack.
            bool affirm = press.Key == Keys.Y;

            if (!affirm)
            {
                var dir = DirectionOf(press);
                if (dir != CmdDirection.None)
                {
                    var dirCoord = Controls.CoordInDirection(being.GetPosition(), dir);
                    var dirRot   = gameState.Map.RotMap.GetItem(dirCoord);

                    affirm = (dirRot != null);
                    if (affirm)
                    {
                        rotDirection = dir;
                    }
                }
            }

            if (affirm)
            {
                Story.HasClearedRot = true;
                WriteLine("Yes.  Now.");
                Log.Info("Decided to clear Rot.");
                return(FinishedCommand(CmdAction.Direction, rotDirection));
            }
            else
            {
                return(CancelMultiStep("Not yet."));
            }
        }