private static string[] FormatRenderer(ColumnFormat format, IConsoleRenderer value, int columnWidth, int tabLength, int firstLineHangingIndent)
 {
     var headingText = MakeHeading(format, columnWidth, tabLength, firstLineHangingIndent);
     int wrappedLines;
     var renderedData = value.Render(columnWidth, out wrappedLines);
     return headingText.Concat(renderedData).ToArray();
 }
 public DevConsole(Game game, IConsoleRenderer renderer) : base(game)
 {
     Renderer     = renderer ?? throw new ArgumentNullException(nameof(renderer));
     InputManager = new ConsoleInputManager(Game);
     Game.Components.Add(InputManager);
     Game.Components.Add(this);
 }
 public Engine(ICommandParser commandParser, ICommandProcessor commandProcessor, IConsoleRenderer consoleRenderer, IFileManager fileManager)
 {
     this.commandParser    = commandParser;
     this.commandProcessor = commandProcessor;
     this.consoleRenderer  = consoleRenderer;
     this.fileManager      = fileManager;
 }
Beispiel #4
0
 protected CommandBase(IConsoleRenderer renderer, PartyConfiguration config, IPartyControllerFactory controllerFactory, CommonArguments args)
 {
     Renderer   = renderer;
     Config     = GetConfig(config, args.VaM);
     Logger     = args.Log == LogLevel.Disabled ? (ILogger) new NullLogger() : new AccumulatorLogger(args.Log);
     Controller = controllerFactory.Create(Config, Logger, !args.Force);
 }
Beispiel #5
0
 protected CommandBase(IConsoleRenderer renderer, PartyConfiguration config, IPartyController controller, CommonArguments args)
 {
     Renderer   = renderer;
     Config     = GetConfig(config, args.VaM);
     Controller = controller;
     Controller.ChecksEnabled = args.Force;
 }
 public CosmeticsEngine(IDataStore dataStore, IConsoleRenderer consoleRenderer,
                        ICommandsFactory commandsFactory)
 {
     this.dataStore       = dataStore;
     this.commandsFactory = commandsFactory;
     this.consoleRenderer = consoleRenderer;
 }
        public void TestConsoleRendererInstance()
        {
            IConsoleRenderer testConsRenderer    = new ConsoleRenderer();
            IConsoleRenderer factoryConsRenderer = testConsoleGraphicFactory.GetConsoleRenderer();

            Object.Equals(testConsRenderer, factoryConsRenderer);
        }
        public AgateConsole(IConsoleRenderer renderer)
        {
            this.renderer = renderer;

            renderer.State = shell.State;

            keyboardInput.KeyPress += KeyboardInput_KeyPress;
        }
Beispiel #9
0
 public static Command CreateCommand(IConsoleRenderer renderer, PartyConfiguration config, IPartyControllerFactory controllerFactory)
 {
     return(new Command("help", "Show useful information about party")
     {
         Handler = CommandHandler.Create <HelpArguments>(args =>
                                                         new HelpCommand(renderer, config, controllerFactory, args).ExecuteAsync(args))
     });
 }
Beispiel #10
0
        /// <summary>
        /// Gets the correct instance of the class implementing <see cref="IScene"/> interface.
        /// </summary>
        /// <returns>The correct instance of the class implementing <see cref="IScene"/> interface</returns>
        /// <param name="renderer">A non null value of <see cref="IConsoleRenderer"/></param>
        public IScene GetISceneInstance(IConsoleRenderer renderer)
        {
            if (renderer == null)
            {
                throw new ArgumentNullException();
            }

            return(new ConsoleScene(renderer));
        }
Beispiel #11
0
        public Game(IConsoleRenderer renderer, IRandomWordGenerator generator, ICommandManager commandManager)
        {
            this.renderer = renderer;
            this.generator = generator;
            this.commandManager = commandManager;
            this.scoreManager = ScoreManager.Instance;

            InitializeGameSettings();
        }
Beispiel #12
0
        uint vehicleSpeed; //"iteration % vehicleSpeed == 0" and this.iteration is ++ed on each iteration

        #endregion Fields

        #region Constructors

        //but for performance reasons, we'll make it 30
        public Engine(IConsoleRenderer renderer, IUserInterface userInterface, //the game will practically run on sleepTime = 0
                      int lives = 5, uint vehicleSpeed = 15, int sleepTime = 20)
        {
            this.renderer = renderer;
            this.userInterface = userInterface;
            this.lives = lives;
            this.vehicleSpeed = vehicleSpeed;
            this.SleepTime = sleepTime;
            this.allObjects = new List<GameObject>();
        }
 /// <summary>
 /// Creates a new console menu handler
 /// </summary>
 /// <param name="inputProvider">Input provider</param>
 /// <param name="renderer">Renderer</param>
 /// <param name="menuItems">Menu items</param>
 /// <param name="menuTop">Menu rendering top row</param>
 /// <param name="menuLeft">Menu rendering left col</param>
 public ConsoleMenuHandler(IConsoleInputProvider inputProvider, IConsoleRenderer renderer, IEnumerable<IGameMode> menuItems, int menuTop, int menuLeft)
 {
     this.inputProvider = inputProvider;
     this.renderer = renderer;
     this.currentSelection = new BeginnerMode();
     this.menuItems = menuItems;
     this.menuBodyTop = menuTop + RenderersConstants.MenuTitleRowsCount;
     this.menuBodyLeft = menuLeft;
     this.selectionCharTop = menuTop + RenderersConstants.MenuTitleRowsCount;
     this.selectionCharLeft = this.menuBodyLeft;
 }
Beispiel #14
0
        public RegionCreationOptions(IConsoleRenderer renderer, DotConsoleRegion parent, Coordinates bufferSize)
        {
            this.Renderer   = renderer;
            this.Parent     = parent;
            this.BufferSize = bufferSize;

            this.Orgin             = default(Coordinates);
            this.WillScrollContent = false;
            this.ForegroundColor   = new Color(255, 255, 255);
            this.BackgroundColor   = new Color(0, 0, 100);
            this.Position          = DotConsoleRegion.ContentPosition.Top;
            this.IsVisible         = true;
        }
Beispiel #15
0
        public static Command CreateCommand(IConsoleRenderer renderer, PartyConfiguration config, IPartyControllerFactory controllerFactory)
        {
            var command = new Command("show", "Show information about a package");

            AddCommonOptions(command);
            command.AddArgument(new Argument <string>("package", null));

            command.Handler = CommandHandler.Create <ShowArguments>(async args =>
            {
                await new ShowCommand(renderer, config, controllerFactory, args).ExecuteAsync(args);
            });
            return(command);
        }
Beispiel #16
0
        public static Command CreateCommand(IConsoleRenderer renderer, PartyConfiguration config, IPartyControllerFactory controllerFactory)
        {
            var command = new Command("search", "Search for packages in the registry");

            AddCommonOptions(command);
            command.AddArgument(new Argument <string>("query", null));

            command.Handler = CommandHandler.Create <SearchArguments>(async args =>
            {
                await new SearchCommand(renderer, config, controllerFactory, args).ExecuteAsync(args);
            });
            return(command);
        }
Beispiel #17
0
        public static Command CreateCommand(IConsoleRenderer renderer, PartyConfiguration config, IPartyController controller)
        {
            var command = new Command("show", "Show information about a package");

            AddCommonOptions(command);
            command.AddArgument(new Argument <string>("package", null));
            command.AddOption(new Option("--warnings", "Show warnings such as broken scenes or missing scripts"));

            command.Handler = CommandHandler.Create <ShowArguments>(async args =>
            {
                await new ShowCommand(renderer, config, controller, args).ExecuteAsync(args);
            });
            return(command);
        }
Beispiel #18
0
        public static Command CreateCommand(IConsoleRenderer renderer, PartyConfiguration config, IPartyController controller)
        {
            var command = new Command("search", "Search for packages in the registry");

            AddCommonOptions(command);
            command.AddArgument(new Argument <string>("query", null));
            command.AddOption(new Option("--no-usage", "Do not show usage information from scenes (runs faster)"));
            command.AddOption(new Option("--warnings", "Show warnings such as broken scenes or missing scripts"));

            command.Handler = CommandHandler.Create <SearchArguments>(async args =>
            {
                await new SearchCommand(renderer, config, controller, args).ExecuteAsync(args);
            });
            return(command);
        }
Beispiel #19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CakeBuildLog" /> class.
        /// </summary>
        /// <param name="console">The console.</param>
        /// <param name="verbosity">The verbosity.</param>
        public CakeBuildLog(IConsole console, Verbosity verbosity = Verbosity.Normal)
        {
            _console = console;
            _lock    = new object();

            if (_console.SupportAnsiEscapeCodes)
            {
                // Use ANSI console renderer.
                _renderer = new AnsiConsoleRenderer(_console);
            }
            else
            {
                // Use the default renderer.
                _renderer = new ConsoleRenderer(_console);
            }

            Verbosity = verbosity;
        }
Beispiel #20
0
        public static Command CreateCommand(IConsoleRenderer renderer, PartyConfiguration config, IPartyControllerFactory controllerFactory)
        {
            var command = new Command("get", "Downloads a package (script, morph or scene) into the saves folder");

            AddCommonOptions(command);
            command.AddArgument(new Argument <string>("packages", null)
            {
                Description = "The package, in the format scripts/name or scripts/[email protected]", Arity = ArgumentArity.ZeroOrMore
            });
            command.AddOption(new Option("--noop", "Do not install, just check what it will do"));
            command.AddOption(new Option("--all", "Install the latest version of everything").WithAlias("-a"));

            command.Handler = CommandHandler.Create <GetArguments>(async args =>
            {
                await new GetCommand(renderer, config, controllerFactory, args).ExecuteAsync(args);
            });
            return(command);
        }
Beispiel #21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GameEngine"/> class
        /// </summary>
        /// <param name="width">Integer value for the width</param>
        /// <param name="height">Integer value for the height</param>
        /// <param name="factory">A non null instance of <see cref="IFactory"/></param>
        public GameEngine(int width, int height, IFactory factory)
        {
            if (width < 1)
            {
                throw new ArgumentException("The value of the width must be more than 0");
            }

            if (height < 1)
            {
                throw new ArgumentException("The value of the height must be more than 0");
            }

            if (factory == null)
            {
                throw new ArgumentNullException("The factory must not be null");
            }

            this.windowWidth  = width;
            this.windowHeight = height;
            this.factory      = factory;
            this.input        = this.factory.GetIUserInputInstance();
            this.labyrinth    = this.factory.GetILabyrinthPlayFieldInstance(factory, this.factory.GetIMoveHandlerInstance());

            this.gameConsole  = this.factory.GetIGameConsoleInstance(this.factory.GetILanguageStringsInstance());
            this.resultsTable = this.factory.GetIResultsTableInstance();

            this.resultsTable.Table.Changed += (sender, e) =>
            {
                this.factory.GetFileSerializationManagerInstance().Serialize(sender);
            };
            var fileAppender = this.factory.GetFileIAppenderInstance("Log.txt");

            this.simpleLoggerFileAppender = this.factory.GetSimpleILoggerInstance(fileAppender);

            this.consoleGraphicFactory = this.factory.GetIConsoleGraphicFactoryInstance();
            this.renderer = this.consoleGraphicFactory.GetConsoleRenderer();
            this.scene    = this.factory.GetISceneInstance(this.renderer);

            this.labyrinthGraphic   = this.consoleGraphicFactory.GetLabyrinthConsoleGraphic(this.labyrinth, this.consoleGraphicFactory.GetCoordinates(2, 1), this.renderer);
            this.gameConsoleGraphic = this.consoleGraphicFactory.GetGameConsoleGraphic(this.gameConsole, this.consoleGraphicFactory.GetCoordinates(2, this.labyrinth.LabyrinthSize + 2), this.renderer);
            this.tableGraphic       = this.consoleGraphicFactory.GetResultsTableConsoleGraphic(this.resultsTable, this.consoleGraphicFactory.GetCoordinates(2, 1), this.renderer);

            this.gameLogic = factory.GetIGameLogicInstance(this.labyrinth, this.gameConsole, this.resultsTable, this.input, this.factory);
        }
        public static Command CreateCommand(IConsoleRenderer renderer, PartyConfiguration config, IPartyControllerFactory controllerFactory)
        {
            var command = new Command("status", "Shows the state of the current scripts and scenes");

            AddCommonOptions(command);
            command.AddArgument(new Argument <string>("filter")
            {
                Arity = ArgumentArity.ZeroOrOne
            });
            command.AddOption(new Option("--breakdown", "Show the list of scenes and files for each script").WithAlias("-b"));
            command.AddOption(new Option("--errors", "Show warnings such as broken scenes or missing scripts").WithAlias("-e"));
            command.AddOption(new Option("--unregistered", "Show all scripts that were not registered").WithAlias("-u"));

            command.Handler = CommandHandler.Create <StatusArguments>(async args =>
            {
                await new StatusCommand(renderer, config, controllerFactory, args).ExecuteAsync(args);
            });
            return(command);
        }
Beispiel #23
0
        public static Command CreateCommand(IConsoleRenderer renderer, PartyConfiguration config, IPartyController controller)
        {
            var command = new Command("upgrade", "Updates scenes to reference scripts from the Party folder. You can specify a package, scene or script to upgrade. If you don't specify anything, all scenes and scripts will be upgraded.");

            AddCommonOptions(command);
            // TODO: Specify specific scenes and/or specific scripts and/or specific packages to upgrade
            command.AddArgument(new Argument <string>("filter"));
            command.AddOption(new Option("--all", "Upgrade everything"));
            command.AddOption(new Option("--get", "Downloads registered scripts that were not already downloaded"));
            command.AddOption(new Option("--fix", "Updates scenes referencing scripts that are not yet in the party folder"));
            command.AddOption(new Option("--clean", "Deletes the source script after scenes have been updated"));
            command.AddOption(new Option("--warnings", "Show warnings such as broken scenes or missing scripts"));
            command.AddOption(new Option("--noop", "Prints what the script will do, but won't actually do anything"));
            command.AddOption(new Option("--verbose", "Prints every change that will be done on every scene"));

            command.Handler = CommandHandler.Create <UpgradeArguments>(async args =>
            {
                await new UpgradeCommand(renderer, config, controller, args).ExecuteAsync(args);
            });
            return(command);
        }
Beispiel #24
0
        public static Command CreateCommand(IConsoleRenderer renderer, PartyConfiguration config, IPartyController controller)
        {
            var command = new Command("get", "Downloads a package (script, morph or scene) into the saves folder");

            AddCommonOptions(command);
            command.AddArgument(new Argument <string>("package", null)
            {
                Arity = ArgumentArity.ExactlyOne
            });
            command.AddOption(new Option("--version", "Choose a specific version to install")
            {
                Argument = new Argument <string>()
            });
            command.AddOption(new Option("--noop", "Do not install, just check what it will do"));

            command.Handler = CommandHandler.Create <GetArguments>(async args =>
            {
                await new GetCommand(renderer, config, controller, args).ExecuteAsync(args);
            });
            return(command);
        }
Beispiel #25
0
        public static Command CreateCommand(IConsoleRenderer renderer, PartyConfiguration config, IPartyControllerFactory controllerFactory)
        {
            var command = new Command("upgrade", "Updates scenes to reference scripts from the Party folder. You can specify a package, scene or script to upgrade. If you don't specify anything, all scenes and scripts will be upgraded.");

            AddCommonOptions(command);
            command.AddArgument(new Argument <string>("filter")
            {
                Arity = ArgumentArity.ZeroOrOne
            });
            command.AddOption(new Option("--all", "Upgrade everything").WithAlias("-a"));
            command.AddOption(new Option("--major", "Allows upgrading even with major versions").WithAlias("-m"));
            command.AddOption(new Option("--errors", "Show warnings such as broken scenes or missing scripts").WithAlias("-e"));
            command.AddOption(new Option("--noop", "Prints what the script will do, but won't actually do anything"));
            command.AddOption(new Option("--verbose", "Prints every change that will be done on every scene").WithAlias("-v"));

            command.Handler = CommandHandler.Create <UpgradeArguments>(async args =>
            {
                await new UpgradeCommand(renderer, config, controllerFactory, args).ExecuteAsync(args);
            });
            return(command);
        }
Beispiel #26
0
        public static Command CreateCommand(IConsoleRenderer renderer, PartyConfiguration config, IPartyControllerFactory controllerFactory)
        {
            var command = new Command("clean", "Updates scenes to reference scripts from their expected folder. You can specify a specific script or scene to clean.");

            AddCommonOptions(command);
            command.AddArgument(new Argument <string>("filter")
            {
                Arity = ArgumentArity.ZeroOrOne, Description = "Optional package name or file to clean"
            });
            command.AddOption(new Option("--all", "Upgrade everything").WithAlias("-a"));
            command.AddOption(new Option("--errors", "Show warnings such as broken scenes or missing scripts").WithAlias("-e"));
            command.AddOption(new Option("--noop", "Prints what the script will do, but won't actually do anything"));
            command.AddOption(new Option("--delete-unused", "Deletes unused scripts").WithAlias("-d"));
            command.AddOption(new Option("--verbose", "Prints every change that will be done on every scene").WithAlias("-v"));

            command.Handler = CommandHandler.Create <CleanArguments>(async args =>
            {
                await new CleanCommand(renderer, config, controllerFactory, args).ExecuteAsync(args);
            });
            return(command);
        }
        public static Command CreateCommand(IConsoleRenderer renderer, PartyConfiguration config, IPartyControllerFactory controllerFactory)
        {
            var command = new Command("publish", "Prepares files for publishing (using a folder, a list of files or a list of urls)");

            AddCommonOptions(command);
            command.AddArgument(new Argument <string>("input", null)
            {
                Arity = ArgumentArity.OneOrMore
            });
            command.AddOption(new Option("--package-name", "The name of your package")
            {
                Argument = new Argument <string>()
            }.WithAlias("-pn"));
            command.AddOption(new Option("--package-version", "The version of your package")
            {
                Argument = new Argument <string>()
            }.WithAlias("-v"));
            command.AddOption(new Option("--package-author", "The author name of your package")
            {
                Argument = new Argument <string>()
            }.WithAlias("-pa"));
            command.AddOption(new Option("--package-version-download-url", "The url to download this version")
            {
                Argument = new Argument <string>()
            }.WithAlias("-pu"));
            command.AddOption(new Option("--registry", "Path the the index.json file of your locally cloned registry")
            {
                Argument = new Argument <FileInfo>().ExistingOnly()
            }.WithAlias("-r"));
            command.AddOption(new Option("--quiet", "Just print the hash and metadata, no questions asked").WithAlias("-q"));
            command.AddOption(new Option("--format", "Just format the registry, e.g. after manually editing it").WithAlias("-fmt"));

            command.Handler = CommandHandler.Create <PublishArguments>(async args =>
            {
                await new PublishCommand(renderer, config, controllerFactory, args).ExecuteAsync(args);
            });
            return(command);
        }
Beispiel #28
0
        public static Command CreateCommand(IConsoleRenderer renderer, PartyConfiguration config, IPartyController controller)
        {
            var command = new Command("publish", "Prepares files for publishing (using a folder, a list of files or a list of urls)");

            AddCommonOptions(command);
            command.AddArgument(new Argument <string>("input", null)
            {
                Arity = ArgumentArity.OneOrMore
            });
            command.AddOption(new Option("--package-name", "The name of your package")
            {
                Argument = new Argument <string>()
            });
            command.AddOption(new Option("--package-version", "The version of your package")
            {
                Argument = new Argument <string>()
            });
            command.AddOption(new Option("--package-author", "The author name of your package")
            {
                Argument = new Argument <string>()
            });
            command.AddOption(new Option("--registry", "Path the the index.json file of your locally cloned registry")
            {
                Argument = new Argument <FileInfo>().ExistingOnly()
            });
            command.AddOption(new Option("--saves", "Specify a custom saves folder, e.g. when the script is not in the Virt-A-Mate folder")
            {
                Argument = new Argument <DirectoryInfo>().ExistingOnly()
            });
            command.AddOption(new Option("--quiet", "Just print the hash and metadata, no questions asked"));

            command.Handler = CommandHandler.Create <PublishArguments>(async args =>
            {
                await new PublishCommand(renderer, config, controller, args).ExecuteAsync(args);
            });
            return(command);
        }
Beispiel #29
0
 public static ColoredConsoleRx Create(IConsoleRenderer renderer)
 {
     return(new ColoredConsoleRx(renderer));
 }
Beispiel #30
0
 public ShowCommand(IConsoleRenderer renderer, PartyConfiguration config, IPartyControllerFactory controllerFactory, CommonArguments args)
     : base(renderer, config, controllerFactory, args)
 {
 }
        /// <summary>
        /// Start Game logic
        /// </summary>
        public void Start()
        {
            // Initialize the two basic objects needed for user interactions
            this.InputProvider = this.inputProvider ?? new ConsoleInputProvider();
            this.OutputRenderer = this.outputRenderer ?? new ConsoleRenderer();

            // Render initial UI
            this.OutputRenderer.RenderWelcomeScreen(string.Join(string.Empty, RenderersConstants.GameTitle));
            this.OutputRenderer.RenderNewPlayerCreationRequest();

            // Create the active player
            var player = new Player(this.InputProvider.ReceiveInputLine());

            // Render console menu handler and execute logic for requesting board settings
            // TODO: Refactor menu handler logic
            int[] cursorPosition = this.OutputRenderer.GetCursor();
            var menuItems = new List<IGameMode>()
            {
                new BeginnerMode(),
                new IntermediateMode(),
                new ExpertMode()
            };

            var menuHandler = new ConsoleMenuHandler(this.inputProvider, this.outputRenderer, menuItems, cursorPosition[0] + 1, cursorPosition[1]);

            menuHandler.ShowSelections();

            BoardSettings boardSettings = menuHandler.RequestUserSelection();
            this.OutputRenderer.ClearScreen();
            this.OutputRenderer.SetCursor(visible: true);
            //// End of menu handler logic

            var board = new Board(boardSettings, new List<IBoardObserver>());
            var scoreboard = new Scoreboard();
            var contentFactory = new ContentFactory();
            var initializationStrategy = new StandardGameInitializationStrategy(contentFactory);
            var boardOperator = new CommandOperator(board, scoreboard);
            var engine = new StandardOnePlayerMinesweeperEngine(board, this.inputProvider, this.outputRenderer, boardOperator, scoreboard, player);

            engine.Initialize(initializationStrategy);
            board.Subscribe(engine);
            engine.Run();
        }
Beispiel #32
0
 public GetCommand(IConsoleRenderer renderer, PartyConfiguration config, IPartyController controller, CommonArguments args)
     : base(renderer, config, controller, args)
 {
 }
 public CommandManager(ICommandParser parser, IConsoleRenderer renderer)
 {
     this.parser = parser;
     this.renderer = renderer;
     scoreManager = ScoreManager.Instance;
 }
Beispiel #34
0
 public ColoredConsoleRx(IConsoleRenderer renderer)
 {
     _renderer = renderer;
 }
Beispiel #35
0
 public Program(IConsoleRenderer renderer, PartyConfiguration config, IPartyController controller)
 {
     _renderer   = renderer;
     _config     = config;
     _controller = controller;
 }
 public RenderCommand(IConsoleRenderer data)
 {
     _data = data;
 }
 /// <summary>
 /// Construct from an object derived from <see cref="IConsoleRenderer"/>.
 /// </summary>
 public FormattingIntermediate(IConsoleRenderer renderableValue)
 {
     RenderableValue = renderableValue;
 }
Beispiel #38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ConsoleScene" /> class.
 /// </summary>
 /// <param name="renderer">Renderer for the scene.</param>
 public ConsoleScene(IConsoleRenderer renderer)
     : base()
 {
     this.renderer = renderer;
 }