Ejemplo n.º 1
0
 public IActionResult SelectScenario(ScenarioVM vm)
 {
     if (!ModelState.IsValid)
     {
         return(View());
     }
     else
     {
         try
         {
             HttpContext.Session.SetString("Scenario", vm.ScenarioChoice);
             return(RedirectToAction("NameAndGender"));
         }
         catch (ArgumentException e)
         {
             if (e.Message == "Invalid Scenario chosen")
             {
                 return(View());
             }
             else
             {
                 throw e;
             }
         }
     }
 }
Ejemplo n.º 2
0
        public IActionResult StartGame()
        {
            int        slot            = (int)TempData["slot"];
            string     name            = HttpContext.Session.GetString("Name");
            string     gender          = HttpContext.Session.GetString("Gender");
            string     profChoice      = HttpContext.Session.GetString("Profession");
            Profession prof            = (new ProfessionVM()
            {
                ProfessionChoice = profChoice, Gender = gender
            }).Profession;
            Character  PlayerCharacter = new Character(name, prof);
            ScenarioVM scenarioVM      = new ScenarioVM()
            {
                ScenarioChoice = HttpContext.Session.GetString("Scenario")
            };
            Scenario scenario = scenarioVM.Scenario;

            scenario.ActiveModule = scenario.Modules[scenario.StartingModuleIndex];
            scenario.PlayerParty.Add(PlayerCharacter);
            scenario.UpdateModuleParty();

            GameData gameData = new GameData()
            {
                UserID         = 1, // TODO: implement userID
                SaveGameSlot   = slot,
                ActiveScenario = scenario
            };

            SaveGameDAO.SaveGame(gameData.UserID, slot, gameData);

            HttpContext.Session.SetString("UserID", "1"); // TODO: remove when userID implemented

            return(RedirectToAction("Index", "Game", slot));
        }