public string LoadData() { HttpContext.Session.SetObject("GameSession", _gameSession); _gameLoader.Load(); return(_outputHandler.GetOutput()); }
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."); } }