Example #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="saveLoadManager">
        /// The save/load manager.
        /// </param>
        public UndoRedoManager(ISaveLoadManager saveLoadManager)
        {
            _saveLoadManager = saveLoadManager;

            _undoableActions.CollectionChanged += OnUndoChanged;
            _redoableActions.CollectionChanged += OnRedoChanged;
        }
 /// <summary>
 /// Specifies the getting of exact command.
 /// </summary>
 /// <param name="command">Specifies the input text with which the command is chosen.</param>
 /// <param name="printer">The printer of messages for the chosen command.</param>
 /// <param name="gameSaver">The object for saving game state.</param>
 /// <returns>A command object.</returns>
 public IHangmanCommand GetCommand(string command, IPrinter printer, ISaveLoadManager gameSaver)
 {
     // The string command will come from a ConsoleInputParser/Reader and it will be validated there;
     switch (command)
     {
         case "restart":
             return new RestartCommand(printer);
         case "top":
             return new ShowScoreboardCommand();
         case "help":
             return new GetHelpCommand();
         case "exit":
             return new ExitGameCommand(printer);
         case "save":
             return new SaveCommand(gameSaver);
         case "load":
             return new LoadCommand(gameSaver, printer);
         case "finishGame":
             return new NormalGameEndCommand(printer);
         case "cheater":
             return new CheaterGameEndCommand(printer);
         default:
             return new HandleLetterCommand(command, printer);
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="HangmanGame"/> class.
 /// Provides methods for running the game, ending the game and executing commands.
 /// </summary>
 public HangmanGame()
 {
     this.printer = new ConsolePrinter();
     this.context = new GameContext(SimpleRandomWordProvider.Instance, new Scoreboard(new ConsolePrinter(), new SelectionSorter(), new TextFileScoreboardDataManager<Dictionary<string, int>>()));
     this.commandFactory = new CommandFactory();
     this.gameSaver = new SaveLoadManager(this.printer, new XmlGameStateManager<SaveLoadManager>());
     this.commandExecutioner = new HangmanCommandInvoker();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="HangmanGame"/> class.
 /// Provides methods for running the game, ending the game and executing commands.
 /// </summary>
 /// <param name="printer">The object used to show messages.</param>
 /// <param name="sorter">The object used to sort scores.</param>
 /// <param name="scoresDataManager">The object from which scores are read and written in.</param>
 /// <param name="gameStateManager">The object used to save the current game state.</param>
 /// <param name="commandFactory">The object used to deal with commands needed.</param>
 /// <param name="commandExecutioner">The object used for the execution of commands.</param>
 /// <param name="wordProvider">The object that provides the word for the current game.</param>
 public HangmanGame(
     IPrinter printer,
     ISorter sorter,
     IDataManager<Dictionary<string, int>> scoresDataManager,
     IDataManager<SaveLoadManager> gameStateManager,
     CommandFactory commandFactory,
     ICommandInvoker commandExecutioner,
     IWordProvider wordProvider)
 {
     this.printer = printer;
     this.context = new GameContext(wordProvider, new Scoreboard(printer, sorter, scoresDataManager));
     this.commandFactory = new CommandFactory();
     this.gameSaver = new SaveLoadManager(this.printer, gameStateManager);
     this.commandExecutioner = new HangmanCommandInvoker();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="LoadCommand"/> class.
 /// </summary>
 /// <param name="gameSaver">The object having the game state that is loaded.</param>
 /// <param name="printer">The object used to show messages.</param>
 public LoadCommand(ISaveLoadManager gameSaver, IPrinter printer)
 {
     this.gameSaver = gameSaver;
     this.printer = printer;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SaveCommand"/> class.
 /// </summary>
 /// <param name="gameSaver">The object that will hold the saved state.</param>
 public SaveCommand(ISaveLoadManager gameSaver)
 {
     this.gameSaver = gameSaver;
 }
Example #7
0
        /// <summary>
        /// Constructor
        /// </summary>
        public TopMenuVM(
            IAppSettings appSettings, IResetManager resetManager, ISaveLoadManager saveLoadManager,
            IUndoRedoManager undoRedoManager, IDialogService dialogService, IFileDialogService fileDialogService,
            IAutoTrackerDialogVM autoTrackerDialog, IColorSelectDialogVM colorSelectDialog,
            ISequenceBreakDialogVM sequenceBreakDialog, IAboutDialogVM aboutDialog,
            IErrorBoxDialogVM.Factory errorBoxFactory, IMessageBoxDialogVM.Factory messageBoxFactory)
        {
            _appSettings     = appSettings;
            _resetManager    = resetManager;
            _saveLoadManager = saveLoadManager;
            _undoRedoManager = undoRedoManager;

            _dialogService     = dialogService;
            _fileDialogService = fileDialogService;

            _autoTrackerDialog   = autoTrackerDialog;
            _colorSelectDialog   = colorSelectDialog;
            _sequenceBreakDialog = sequenceBreakDialog;
            _aboutDialog         = aboutDialog;

            _errorBoxFactory   = errorBoxFactory;
            _messageBoxFactory = messageBoxFactory;

            Open = ReactiveCommand.CreateFromTask(OpenImpl);
            Open.IsExecuting.ToProperty(this, x => x.IsOpening, out _isOpening);

            Save = ReactiveCommand.CreateFromTask(SaveImpl);
            Save.IsExecuting.ToProperty(this, x => x.IsSaving, out _isSaving);

            SaveAs = ReactiveCommand.CreateFromTask(SaveAsImpl);
            SaveAs.IsExecuting.ToProperty(this, x => x.IsSavingAs, out _isSavingAs);

            Reset = ReactiveCommand.CreateFromTask(ResetImpl);
            Reset.IsExecuting.ToProperty(this, x => x.IsResetting, out _isResetting);

            Close = ReactiveCommand.Create <Window>(CloseImpl);

            Undo = ReactiveCommand.CreateFromTask(UndoImpl, this.WhenAnyValue(x => x.CanUndo));
            Undo.IsExecuting.ToProperty(this, x => x.IsUndoing, out _isUndoing);

            Redo = ReactiveCommand.CreateFromTask(RedoImpl, this.WhenAnyValue(x => x.CanRedo));
            Redo.IsExecuting.ToProperty(this, x => x.IsRedoing, out _isRedoing);

            AutoTracker = ReactiveCommand.CreateFromTask(AutoTrackerImpl);
            AutoTracker.IsExecuting.ToProperty(
                this, x => x.IsOpeningAutoTracker, out _isOpeningAutoTracker);

            SequenceBreaks = ReactiveCommand.CreateFromTask(SequenceBreaksImpl);
            SequenceBreaks.IsExecuting.ToProperty(
                this, x => x.IsOpeningSequenceBreak, out _isOpeningSequenceBreak);

            ToggleDisplayAllLocations       = ReactiveCommand.Create(ToggleDisplayAllLocationsImpl);
            ToggleShowItemCountsOnMap       = ReactiveCommand.Create(ToggleShowItemCountsOnMapImpl);
            ToggleDisplayMapsCompasses      = ReactiveCommand.Create(ToggleDisplayMapsCompassesImpl);
            ToggleAlwaysDisplayDungeonItems = ReactiveCommand.Create(ToggleAlwaysDisplayDungeonItemsImpl);

            ColorSelect = ReactiveCommand.CreateFromTask(ColorSelectImpl);
            ColorSelect.IsExecuting.ToProperty(
                this, x => x.IsOpeningColorSelect, out _isOpeningColorSelect);

            ChangeLayoutOrientation          = ReactiveCommand.Create <string>(ChangeLayoutOrientationImpl);
            ChangeMapOrientation             = ReactiveCommand.Create <string>(ChangeMapOrientationImpl);
            ChangeHorizontalUIPanelPlacement = ReactiveCommand.Create <string>(ChangeHorizontalUIPanelPlacementImpl);
            ChangeVerticalUIPanelPlacement   = ReactiveCommand.Create <string>(ChangeVerticalUIPanelPlacementImpl);
            ChangeHorizontalItemsPlacement   = ReactiveCommand.Create <string>(ChangeHorizontalItemsPlacementImpl);
            ChangeVerticalItemsPlacement     = ReactiveCommand.Create <string>(ChangeVerticalItemsPlacementImpl);
            ChangeUIScale = ReactiveCommand.Create <string>(ChangeUIScaleImpl);

            About = ReactiveCommand.CreateFromTask(AboutImpl);
            About.IsExecuting.ToProperty(
                this, x => x.IsOpeningAbout, out _isOpeningAbout);

            _undoRedoManager.PropertyChanged     += OnUndoRedoManagerChanged;
            _appSettings.Tracker.PropertyChanged += OnTrackerSettingsChanged;
            _appSettings.Layout.PropertyChanged  += OnLayoutChanged;
        }
Example #8
0
 public CommonSideDoor(ISaveLoadManager saveLoadManager, IHeightmapComposer composer)
 {
     _saveLoadManager = saveLoadManager;
     _composer        = composer;
 }