示例#1
0
    public void Configure(List <string> arguments)
    {
        try
        {
            if (arguments.Count < 1)
            {
                string message = "The command '<color=" + ConsoleConfiguration.HighlightColour + ">configure default-maze</color>' needs an additional argument with the name of the level that should be the new default.json";

                message += ConfigureCommand.GetConfigurableArguments();
                throw new NotEnoughArgumentsConsoleException(message);
            }

            string sanatisedLevelName = arguments[0].ToLower().Replace(" ", "-");

            bool levelExists = MazeLevelLoader.MazeLevelExists(sanatisedLevelName);

            if (!levelExists)
            {
                string message = $"Could not find a maze level with the name {sanatisedLevelName}.";
                throw new CouldNotFindMazeLevelConsoleException(message);
            }

            MazeLevelLoader.ReplaceMazeLevel(sanatisedLevelName, "default");

            Console.Instance.PrintToReportText($"{sanatisedLevelName} is now the default maze level.");
        }
        catch (System.Exception)
        {
            throw;
        }
    }
示例#2
0
    public void Configure(List <string> arguments)
    {
        try
        {
            if (arguments.Count < 2)
            {
                string message = "The command '<color=" + ConsoleConfiguration.HighlightColour + ">configure maze</color>' needs additional arguments. \nMake sure that the 2nd argument has the name of the level that needs to be changed, and the 3rd argument says what needs to be configured.\n For example 'configure maze first-level playable true'.\n";
                Logger.Warning(message);

                message += ConfigureCommand.GetConfigurableArguments();
                throw new NotEnoughArgumentsConsoleException(message);
            }

            string levelName = arguments[0];

            switch (arguments[1])
            {
            case "playable":
                arguments.RemoveAt(1);
                arguments.RemoveAt(0);
                ToggleLevelPlayability(levelName, arguments);
                break;

            default:
                string message = $"{arguments[1]} Is an unknown argument to configure.";
                message += ConfigureCommand.GetConfigurableArguments();
                throw new UnknownArgumentConsoleException(message);
            }
        }
        catch (System.Exception)
        {
            throw;
        }
    }