Exemple #1
0
        private void CreateNewCharacter()
        {
            UpdateGameState(GameState.CharCreation);
            _outputHandler.HandleOutput("Create a new character! Which class would you like to play? \rType down one of the following classes: ");

            foreach (Common.Models.ICharacterClass characterClass in _characterClassDataAccess.GetAllCharacterClasses())
            {
                _outputHandler.HandleOutput("\r" + characterClass.ClassName);

                foreach (Common.Models.IAbility ability in _abilityDataAccess.GetCharacterClass_Abilities(characterClass.ClassName))
                {
                    _outputHandler.HandleOutput("Starts with: " + ability.AbilityName + ", " + ability.AbilityDescription);
                }
            }
        }
 public void WriteOutput(string output)
 {
     _outputHandler.HandleOutput(output);
 }
Exemple #3
0
        public void HandleInput(string input)
        {
            _input = input;

            if (string.IsNullOrWhiteSpace(_input))
            {
                return;
            }

            _outputHandler.HandleOutput(_input);

            // CHECKS BELOW THIS COMMENT
            GameState currentState = _httpContextAccessor.HttpContext.Session.GetObject <GameSession>("GameSession").CurrentGameState;

            if (currentState == GameState.CharCreation)
            {
                // pirvate void HandleCharacterCreationInput
                if (CheckInputCaseInsensitive(_characterClassDataAccess.GetAllCharacterClasses().Select(c => c.ClassName).ToList()))
                {
                    CreateNewCharacter();
                }
                else
                {
                    _outputHandler.HandleOutput("Please insert a valid class!");
                }
            }
            else if (currentState == GameState.Exploration)
            {
                if (CheckInputCaseInsensitive("All Abilities"))
                {
                    DisplayAllAbilities();
                }
                else if (CheckInputCaseInsensitive("My Abilities"))
                {
                    DisplayAllCharacter_Abilities();
                }
                else if (CheckInputCaseInsensitive("Sit"))
                {
                    // Stuff like this goes into states where you can freely act.
                    _outputHandler.HandleOutput("You sit down.");
                }
                else if (CheckInputCaseInsensitive("Training Dummy"))
                {
                    // Stuff like this goes in other states from where combat can start.
                    SpawnDummy();
                }
            } // combat state stuff
            else if (currentState == GameState.Combat)
            {
                ReInstantiateCombat();
                if (CheckInputCaseInsensitive(_abilityDataAccess.GetAllCharacter_Abilities(_httpContextAccessor.HttpContext.Session.GetObject <GameSession>("GameSession").Character.CharacterId).Select(a => a.AbilityName).ToList()))
                {
                    IAbility   ability   = _abilityDataAccess.GetAbilityByName(_input);
                    ICharacter character = _httpContextAccessor.HttpContext.Session.GetObject <GameSession>("GameSession").Character;

                    string attackOutput = character.Attack(ability);
                    _outputHandler.HandleOutput(attackOutput);
                }
                else if (CheckInputCaseInsensitive("Forfeit") || CheckInputCaseInsensitive("Run"))
                {
                    _combatState.EndBattleDefeat();
                    UpdateGameState(GameState.Exploration);
                }
            }
            if (_outputHandler.GetOutput() == "" || _outputHandler.GetOutput() == null)
            {
                _outputHandler.HandleOutput("Nothing happened.");
            }
        }