/// <summary>
        /// Pass the action to the appropriate interactor.
        /// </summary>
        public void ProcessInput(ConsoleKeyInfo keyInfo, Character character)
        {
            switch (keyInfo.Key)
            {
            case ConsoleKey.F when keyInfo.Modifiers == ConsoleModifiers.Shift:
                inventoryInteractor.PutOff(character, InventoryType.IncreaseForceItem);
                listener?.MakeAction(character as AbstractPlayer, ActionType.TakeOffForce);
                break;

            case ConsoleKey.H when keyInfo.Modifiers == ConsoleModifiers.Shift:
                inventoryInteractor.PutOff(character, InventoryType.IncreaseHealthItem);
                listener?.MakeAction(character as AbstractPlayer, ActionType.TakeOffHealth);
                return;

            case ConsoleKey.E when keyInfo.Modifiers == ConsoleModifiers.Shift:
                inventoryInteractor.PutOff(character, InventoryType.IncreaseExperienceItem);
                listener?.MakeAction(character as AbstractPlayer, ActionType.TakeOffExperience);
                break;

            case ConsoleKey.A when keyInfo.Modifiers == ConsoleModifiers.Shift:
                inventoryInteractor.PutOff(character, InventoryType.IncreaseAllItem);
                listener?.MakeAction(character as AbstractPlayer, ActionType.TakeOffAll);
                break;

            case ConsoleKey.F:
                inventoryInteractor.PutOn(character, InventoryType.IncreaseForceItem);
                listener?.MakeAction(character as AbstractPlayer, ActionType.ApplyForce);
                break;

            case ConsoleKey.H:
                inventoryInteractor.PutOn(character, InventoryType.IncreaseHealthItem);
                listener?.MakeAction(character as AbstractPlayer, ActionType.ApplyHealth);
                break;

            case ConsoleKey.E:
                inventoryInteractor.PutOn(character, InventoryType.IncreaseExperienceItem);
                listener?.MakeAction(character as AbstractPlayer, ActionType.ApplyExperience);
                break;

            case ConsoleKey.A:
                inventoryInteractor.PutOn(character, InventoryType.IncreaseAllItem);
                listener?.MakeAction(character as AbstractPlayer, ActionType.ApplyAll);
                break;
            }
        }
Esempio n. 2
0
        public void InventoryInteractorPutOnTest()
        {
            var playView            = new VoidView();
            var inventoryInteractor = new InventoryInteractor(level, playView);

            Assert.AreEqual(3, level.CurrentPlayer.GetInventory().Count);
            Assert.AreEqual(1, level.CurrentPlayer.GetAppliedInventory().Count);
            Assert.IsInstanceOf(typeof(IncreaseForceItem), level.CurrentPlayer.GetInventory()[2]);

            var beforeStatistics = level.CurrentPlayer.GetStatistics().Clone() as CharacterStatistics;

            inventoryInteractor.PutOn(level.CurrentPlayer, level.CurrentPlayer.GetInventory()[2].GetStringType());

            Assert.AreEqual(2, level.CurrentPlayer.GetInventory().Count);
            Assert.AreEqual(2, level.CurrentPlayer.GetAppliedInventory().Count);

            var afterStatistics = level.CurrentPlayer.GetStatistics();

            Assert.AreEqual(beforeStatistics.Health, afterStatistics.Health);
            Assert.AreEqual(beforeStatistics.Experience, afterStatistics.Experience);
            Assert.AreEqual(beforeStatistics.Force + 3, afterStatistics.Force);
        }