public Engine(ICommandsRunner commandsRunner, IInputReader inputReader, IScreenDrawer screenDrawer, IMainPlayer player, IRoom lastRoom)
        {
            this.commandsRunner = commandsRunner ?? throw new ArgumentNullException(nameof(commandsRunner));
            this.inputReader    = inputReader ?? throw new ArgumentNullException(nameof(inputReader));
            this.screenDrawer   = screenDrawer ?? throw new ArgumentNullException(nameof(screenDrawer));

            if (player == null)
            {
                throw new ArgumentNullException(nameof(player));
            }

            if (lastRoom == null)
            {
                throw new ArgumentNullException(nameof(lastRoom));
            }

            player.OnRoomEnter += (sender, args) =>
            {
                player.Health -= 10;
                screenDrawer.ShowMessage($"Ти отиде до стая. Това ти костваше 10 живот. Имаш {player.Health} живот");

                if (args.Room.Number == lastRoom.Number)
                {
                    this.screenDrawer.ShowMessage("Край на играта.");
                    Thread.Sleep(5000);
                    Environment.Exit(0);
                }
            };

            this.SetupCommands(player, commandsRunner, screenDrawer);
        }
 private void SetupCommands(IMainPlayer mainPlayer, ICommandsRunner commandsRunner, IScreenDrawer screenDrawer)
 {
     commandsRunner.AddCommand("помощ", new HelpCommand(commandsRunner, screenDrawer));
     commandsRunner.AddCommand("махни предмет", new DropItemCommand(mainPlayer, screenDrawer));
     commandsRunner.AddCommand("отиди до", new GoThroughCommand(mainPlayer, screenDrawer));
     commandsRunner.AddCommand("вземи предмет", new PickItemCommand(mainPlayer, screenDrawer));
     commandsRunner.AddCommand("покажи всички", new ShowItemsOnGroundCommand(mainPlayer, screenDrawer));
     commandsRunner.AddCommand("къде съм", new WhereAmICommand(mainPlayer, screenDrawer));
     commandsRunner.AddCommand("къде мога да отида", new WhereCanIGoCommand(mainPlayer, screenDrawer));
 }
예제 #3
0
 public HelpCommand(ICommandsRunner commandsRunner, IScreenDrawer screenDrawer)
 {
     this.commandsRunner = commandsRunner ?? throw new ArgumentNullException(nameof(commandsRunner));
     this.screenDrawer   = screenDrawer ?? throw new ArgumentNullException(nameof(screenDrawer));
 }
예제 #4
0
 public void Initialize()
 {
     this.commandsRunner = new CommandsRunner();
     commandsRunner.AddCommand("Мини през", new GoThroughCommand());
 }