예제 #1
0
        public static Command Parse(string userStatement)
        {
            Command newCommand = null;
            Char[] split = new Char[1];
            split[0] = ' ';
            String[] commands = userStatement.Split(split);
            CommandVerb verb = ParseVerb(commands[0]);
            if (commands.Length < 2)
            {
                newCommand = new Command(verb, String.Empty);
            }
            else
            {
                newCommand = new Command(verb, commands[1]);
            }
            return newCommand;
            

        }
예제 #2
0
 private void ProcessShow(Command command)
 {
     PrintUserMessage(ItemManager.CommandShow(command));
 }
예제 #3
0
        private void ProcessOpen(Command command)
        {
            bool priorLock = false;

            if(currentRoom.Door != null)
            {
                priorLock = currentRoom.Door.Locked;
            }


            PrintUserMessage(ItemManager.CommandOpen(command, player.Position, currentRoom));

            if(priorLock == true)
            {
                if(currentRoom.Door != null)
                {
                    if(currentRoom.Door.Locked == false)
                    {
                        // Erase Lock
                        foreach(Point doorPoint in currentRoom.Door.DoorPoints)
                        {
                            this.CellData.SetCharacter(doorPoint.X, doorPoint.Y, 0, Color.White);
                        }
                    }
                }
            }

            
        }
예제 #4
0
        private void ProcessDropItem(Command command)
        {
            Point dropCoordinates = player.GetFacingPoint(player.CurrentDirection);
            bool collision;
            if (CollisionDetection(dropCoordinates) == ObjectType.None)
            {
                collision = false;
            }
            else
            {
                collision = true;
            }

            UserMessage message = this.ItemManager.CommandDrop(command, dropCoordinates, collision);
            if(message.Character.HasValue)
            {
                this.CellData.SetCharacter(dropCoordinates.X, dropCoordinates.Y, message.Character.Value, Color.White);
            }
            PrintUserMessage(message);

        }
예제 #5
0
 private void ProcessTake(Command command)
 {
     PrintUserMessage(this.ItemManager.CommandTake(command, player.Position));
 }
예제 #6
0
 private void ProcessLook(Command command)
 {
     PrintUserMessage(this.ItemManager.CommandLook(command));
 }
예제 #7
0
파일: Items.cs 프로젝트: drock07/SadConsole
        public UserMessage CommandPlay(Command command, Point position)
        {
            // Run the play command
            var returnMessage = new UserMessage();
            CastleItem item = FindItemInInventory(command.Subject);
            if (item == null)
            {
                returnMessage.AddLine(" You don't");
                returnMessage.AddLine(" have it!");
                return returnMessage;
            }

            Monster monster = FindMonsterInRoom();
            if (monster != null)
            {
                UserMessage monsterMessage = monster.Play(item);
                if(monsterMessage != null)
                {
                    if (monster.IsVisible == false)
                    {
                        CurrentRoomMonsters.Remove(monster);
                    }
                    return monsterMessage;
                }
            }

            returnMessage = RunSpecialCommand(command.Verb, command.Subject, position);
            if (returnMessage != null)
            {
                return returnMessage;
            }


            // Determine if it is a real item
            item = FindItem(command.Subject);
            if (item == null)
            {
                returnMessage.AddLine("You don't have");
                returnMessage.AddLine(String.Format("a {0}!", command.Subject));
            }
            else if (item.IsSpecialCommandSupported(CommandVerb.Play))
            {
                returnMessage.AddLine(" You don't");
                returnMessage.AddLine(" have it!");
            }
            else
            {
                returnMessage.AddLine(String.Format("The {0}", item.InventoryName));
                returnMessage.AddLine("makes Horrible");
                returnMessage.AddLine("music!!");

            }


            return returnMessage;
        }
예제 #8
0
파일: Items.cs 프로젝트: drock07/SadConsole
        public UserMessage CommandLook(Command command)
        {
            UserMessage returnMessage = new UserMessage();

            CastleObject item = null;
            
            // Find all inventory objects
            item = FindItemInInventory(command.Subject);
            if(item != null)
            {
                returnMessage.AddLine(item.Description);
                return returnMessage;
            }

            // Find all Furnature objects
            item = FindFurnatureInRoom(command.Subject);
            if(item != null)
            {
                returnMessage.AddLine(item.Description);
                return returnMessage;
            }

            // Find all items
            item = FindItem(command.Subject);
            if (item != null)
            {
                returnMessage.AddLine(" You Don't");
                returnMessage.AddLine(" Have it!");
                return returnMessage;
            }

            // Find univesral
            item = FindFurnature(command.Subject);
            if (item != null)
            {
                CastleFurnature castleFurnature = item as CastleFurnature;
                if (castleFurnature.LookFailMessage != null)
                {
                    returnMessage.AddLine("I don't see");
                    returnMessage.AddLine(castleFurnature.LookFailMessage);
                    return returnMessage;
                }
            }

            // Find Monster
            Monster monster = FindMonsterInRoom();
            if(monster != null)
            {
                if(monster.IsAlive)
                {
                    returnMessage.AddLine(monster.Description);
                }
                else
                {
                    returnMessage.AddLine(monster.DeadDescription);
                }
                return returnMessage;
            }
            

            returnMessage.AddLine("I don't see");
            returnMessage.AddLine(String.Format("a {0}", command.Subject));
            returnMessage.AddLine("and I don't");
            returnMessage.AddLine("have a");
            returnMessage.AddLine(String.Format("{0}!", command.Subject));
            return returnMessage;
        }
예제 #9
0
파일: Items.cs 프로젝트: drock07/SadConsole
        public UserMessage CommandOpen(Command command, Point position, Room currentRoom)
        {
            // Run the Open command
            UserMessage returnMessage = new UserMessage();
            

            CastleItem key = FindItemInInventory("Key");
            if(key == null)
            {
                returnMessage.AddLine(" You don't");
                returnMessage.AddLine(" have a key!");
                return returnMessage;
            }
            
            if(command.Subject.StartsWith("Door", StringComparison.CurrentCultureIgnoreCase) == false)
            {
                returnMessage.AddLine("Impossible!!");
                return returnMessage;
            }

            // Is door in room 
            if (currentRoom.Door == null)
            {
                returnMessage.AddLine(" I don't");
                returnMessage.AddLine(" see a door.");
                return returnMessage;
            }


            if (currentRoom.Door.Locked)
            {
                foreach (Point point in currentRoom.Door.UnlockPoints)
                {
                    if (position.X == point.X && position.Y == point.Y)
                    {
                        currentRoom.Door.Locked = false;
                        returnMessage.AddLine("Done");
                        return returnMessage;
                    }
                }
            }

            returnMessage.AddLine(" I can't");
            returnMessage.AddLine(" reach it!.");
            return returnMessage;

        }
예제 #10
0
파일: Items.cs 프로젝트: drock07/SadConsole
        public UserMessage CommandWave(Command command, Point position)
        {
            UserMessage returnMessage = RunSpecialCommand(command.Verb, command.Subject, position);
            if(returnMessage == null)
            {
                returnMessage = new UserMessage();
                CastleItem item = FindItemInInventory(command.Subject);
                if(item != null)
                {
                    returnMessage.AddLine("You look awful");
                    returnMessage.AddLine("Silly waving");
                    returnMessage.AddLine(String.Format("that {0}", item.GetDescription));
                }
                else
                {
                    item = FindItem(command.Subject);
                    if(item != null)
                    {
                        returnMessage.AddLine("You don't have");
                        returnMessage.AddLine(String.Format("a {0}", item.GetDescription));
                    }
                    else
                    {
                        returnMessage.AddLine("You don't have");
                        returnMessage.AddLine(String.Format("a {0}", command.Subject));
                    }
                }
            }

            return returnMessage;
        }
예제 #11
0
파일: Items.cs 프로젝트: drock07/SadConsole
        public UserMessage CommandRead(Command command, Point position)
        {
            // Run the read command
            UserMessage returnMessage = RunSpecialCommand(command.Verb, command.Subject, position);
            if (returnMessage == null)
            {
                returnMessage = new UserMessage();
                CastleItem item = FindItem(command.Subject);
                if (item != null)
                {
                    returnMessage.AddLine("You don't");
                    returnMessage.AddLine(" have a book!");
                }
                else
                {
                    returnMessage.AddLine(" You can't");
                    returnMessage.AddLine(" read That!");

                }
            }
            return returnMessage;
        }
예제 #12
0
파일: Items.cs 프로젝트: drock07/SadConsole
        public UserMessage CommandWear(Command command, Point position)
        {
            // Run the wear command
            UserMessage returnMessage = RunSpecialCommand(command.Verb, command.Subject, position);
            if (returnMessage == null)
            {
                returnMessage = new UserMessage();

                CastleItem item = FindItemInInventory(command.Subject);
                if (item == null)
                {
                    returnMessage.AddLine(" You don't");
                    returnMessage.AddLine(" have it!");
                    return returnMessage;
                }
                
                // Determine if it is a real item
                item = FindItem(command.Subject);
                if(item == null)
                {
                    returnMessage.AddLine("You don't have");
                    returnMessage.AddLine(String.Format("a {0}!", command.Subject));
                }
                else if(item.IsSpecialCommandSupported(CommandVerb.Wear))
                {
                    returnMessage.AddLine(" You don't");
                    returnMessage.AddLine(" have it!");
                }
                else
                {
                    returnMessage.AddLine("That could be");
                    returnMessage.AddLine("Difficult!");

                }

            }
            return returnMessage;
        }
예제 #13
0
파일: Items.cs 프로젝트: drock07/SadConsole
        public UserMessage CommandDrink(Command command, Point location)
        {
            UserMessage returnMessage = RunSpecialCommand(command.Verb, command.Subject, location);

            if( returnMessage == null)
            {
                returnMessage = new UserMessage();
                returnMessage.AddLine("You don't have");
                returnMessage.AddLine(String.Format("a {0}!", command.Subject));
                
            }
            return returnMessage;

        }
예제 #14
0
파일: Items.cs 프로젝트: drock07/SadConsole
        public UserMessage CommandDrop(Command command, Point location, bool collision)
        {
            UserMessage returnMessage = new UserMessage();

            // Verify item is in our inventory
            CastleItem item = FindItemInInventory(command.Subject);
            if (item == null)
            {
                returnMessage.AddLine("You don't have");
                returnMessage.AddLine(String.Format("a {0}", command.Subject));
                return returnMessage;
            }

            // Verify that nothing is in the way
            if(collision)
            {
                returnMessage.AddLine(" Something is");
                returnMessage.AddLine(" in the way!");
                return returnMessage;
            }

            // Drop the item
            currentInventory.Remove(item);
            CurrentRoomItems.Add(item);
            item.PutDown(currentRoomIndex, location);
            returnMessage.Character = item.Character;
            returnMessage.AddLine(" Done");
            return returnMessage;
                

        }
예제 #15
0
파일: Items.cs 프로젝트: drock07/SadConsole
        public UserMessage CommandTake(Command command, Point location)
        {
            UserMessage returnMessage = new UserMessage();

            // Look in inventory
            CastleItem item = FindItemInInventory(command.Subject);
            if (item != null)
            {
                returnMessage.AddLine(" You already");
                returnMessage.AddLine(" have it!");
                return returnMessage;
            }


            // Look for hidden items
            CastleFurnatureContainer container = FindHiddenItem(command.Subject);
            if(container != null)
            {
                if (container.CanTakeItem(location))
                {
                    if (currentInventory.Count >= maxItems)
                    {
                        returnMessage.AddLine("Can't carry   any more!");
                        return returnMessage;
                    }

                    CastleItem getItem = container.TakeItem();
                    currentInventory.Add(getItem);
                    getItem.PickUp();
                    returnMessage.AddLine("Done.");
                    return returnMessage;
                }
                else
                {
                    returnMessage.AddLine(" I can't");
                    returnMessage.AddLine(" reach it!");
                    return returnMessage;
                }
            }

            // Look for items in the room we can take
            item = FindItemInRoom(command.Subject);
            if(item != null)
            {
                returnMessage.AddLine(" Get it");
                returnMessage.AddLine(" Yourself!");
                return returnMessage;

            }

            // Look for items in the room we can not take
            item = FindItem(command.Subject);
            if (item != null)
            {
                returnMessage.AddLine(" I don't see");
                returnMessage.AddLine(String.Format(" a {0}", item.GetDescription));
                return returnMessage;
            }

            // Look for furnature in the room
            CastleFurnature castleFurnature = FindFurnatureInRoom(command.Subject);
            if(castleFurnature != null)
            {
                if (castleFurnature.GetDescription != null)
                {
                    returnMessage.AddLine(String.Format("{0}", castleFurnature.GetDescription));
                    returnMessage.AddLine("are too heavy!");
                    return returnMessage;
                }
            }

            // Look for furnature in any room
            castleFurnature = FindFurnature(command.Subject);
            if (castleFurnature != null)
            {
                if (castleFurnature.GetDescription != null)
                {
                    returnMessage.AddLine(String.Format("{0}", castleFurnature.GetDescription));
                    returnMessage.AddLine("are too heavy!");
                    returnMessage.AddLine("and I don't");
                    returnMessage.AddLine("see any!");
                    return returnMessage;
                }
            }

            // Look for monsters in the room
            Monster monster = FindMonsterInRoom();
            if(monster != null)
            {
                returnMessage.AddLine("I don't think");
                returnMessage.AddLine("that would be");
                returnMessage.AddLine("very safe!");
                return returnMessage;

            }

            // Look for special Cases
            foreach(var roomItem in currentRoomFurnatureItems)
            {
                if (roomItem.IsSpecialCommandSupported(CommandVerb.Take))
                {
                    UserMessage message = roomItem.RunCommand(CommandVerb.Take, command.Subject, this.currentRoomIndex, location, FindItemInInventory);
                    if(message != null)
                    {
                        return message;
                    }
                }
            }

            returnMessage.AddLine("Impossible!!");

            return returnMessage;
        }
예제 #16
0
 private void ProcessPlay(Command command)
 {
     PrintUserMessage(ItemManager.CommandPlay(command, player.Position));
 }
예제 #17
0
        private void WarpRoom(Command command)
        {
            int roomId;
            if(Int32.TryParse(command.Subject, out roomId) == false)
            {
                ShowError();
            }
            else
            {
                    currentRoomIndex = roomId;
                    DrawRoom();

            }
        }
예제 #18
0
파일: Items.cs 프로젝트: drock07/SadConsole
        public UserMessage CommandShow(Command command)
        {
            UserMessage returnMessage = new UserMessage();
            CastleItem item = FindItemInInventory(command.Subject);
            if(item == null)
            {
                returnMessage.AddLine("I don't have");
                returnMessage.AddLine(String.Format("a {0}", command.Subject));
                return returnMessage;
            }

            Monster monster = FindMonsterInRoom();
            if(monster == null)
            {
                returnMessage.AddLine("There's not");
                returnMessage.AddLine("anyone to");
                returnMessage.AddLine("show it to!");
                return returnMessage;
            }

            returnMessage = monster.Show(item);
            if (monster.IsVisible == false)
            {
                CurrentRoomMonsters.Remove(monster);
            }
            return returnMessage;


        }