Exemplo n.º 1
0
 /**
  * Print all valid commands to Console.WriteLine.
  */
 public void ShowAll()
 {
     for (int i = 0; i < validCommands.Length; i++)
     {
         Console.WriteLine("╟─ " + validCommands[i]);
         string[] thisDescription = commandDescription[i].Split(new string[] { "<br>" }, StringSplitOptions.None);
         string   output          = "";
         for (int i_ = 0; i_ < thisDescription.Length; i_++)
         {
             output += "║   <S>" + thisDescription[i_] + "<S>\n";
         }
         TextEffects.SecondaryColoredMessage(output, "White", "DarkGray");
     }
 }
Exemplo n.º 2
0
        /**
         * Given a command, process (that is: execute) the command.
         * If this command ends the game, true is returned, otherwise false is
         * returned.
         */
        private bool ProcessCommand(Command command)
        {
            bool wantToQuit = false;

            if (command.IsUnknown())
            {
                TextEffects.ColoredMessage("I don't know what you mean...\n", "DarkRed");
                return(false);
            }

            string commandWord = command.CommandWord;

            switch (commandWord)
            {
            case "help":
                PrintHelp();
                break;

            case "go":
                if (inCombat)
                {
                    TextEffects.ColoredMessage("You can't do that in combat!\n", "DarkRed"); break;
                }
                GoRoom(command);
                break;

            case "quit":
                if (inCombat)
                {
                    TextEffects.ColoredMessage("You can't do that in combat!\n", "DarkRed"); break;
                }
                wantToQuit = true;
                break;

            case "look":
                if (inCombat)
                {
                    TextEffects.ColoredMessage("You can't do that in combat!\n", "DarkRed"); break;
                }
                TextEffects.CheckNullWriteLine(player.CurrentRoom.GetLongDescription());
                break;

            case "inventory":
                TextEffects.ColoredMessage(player.GetHealth(), "Red");
                TextEffects.SecondaryColoredMessage(player.GetInventoryDesc(), "White", "DarkGray");
                break;

            case "take":
                if (inCombat)
                {
                    TextEffects.ColoredMessage("You can't do that in combat!\n", "DarkRed"); break;
                }
                TextEffects.CheckNullWriteLine(player.PickupItem(command));
                break;

            case "drop":
                if (inCombat)
                {
                    TextEffects.ColoredMessage("You can't do that in combat!\n", "DarkRed"); break;
                }
                TextEffects.CheckNullWriteLine(player.DropItem(command));
                break;

            case "use":
                TextEffects.CheckNullWriteLine(player.UseItem(command));
                break;

            case "attack":
                if (inCombat)
                {
                    TextEffects.CheckNullWriteLine(player.AttackEnemy()); break;
                }
                TextEffects.CheckNullWriteLine(player.Attack());
                break;

            case "equip":
                TextEffects.CheckNullWriteLine(player.EquipItem(command));
                break;

            case "unequip":
                TextEffects.CheckNullWriteLine(player.Unequip());
                break;
            }

            return(wantToQuit);
        }