public void initWeapons() { RPGSQLContext context = new RPGSQLContext(); RPGRepository repo = new RPGRepository(context); Weapon = repo.GetItemById(Wepid); Armor = repo.GetItemById(Armorid); }
/// <summary> /// Start the game with the given character id. The story and the events system also gets loaded here. /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Play(int id) { RPGRepository rpgrepo = new RPGRepository(rpgct); Character character = rpgrepo.GetById(id); character.InventoryList = rpgrepo.GetInventory(id); character.initWeapons(); if (character == null) { throw new Exception("id does not exist."); } eventsViewModel.EventsSystem = new EventSystem(); eventsViewModel.EventsSystem.ScenarioList = rpgrepo.GetStory(); eventsViewModel.EventsSystem.playerProgression = 1; eventsViewModel.EventsSystem.character = character; if (Session["itemdrop"] != null) { int itmid = (int)Session["itemdrop"]; Item item = rpgrepo.GetItemById(itmid); Session["itemdrop"] = item; character.InventoryList.Add(item); eventsViewModel.droppedItem = item; } Session["CharId"] = character.CharacterID; if (Session["playerProgression"] == null) { Session["playerProgression"] = 1; } Session["Button1Name"] = eventsViewModel.EventsSystem.ScenarioList[(int)Session["playerProgression"] - 1].Button1Text; Session["Button2Name"] = eventsViewModel.EventsSystem.ScenarioList[(int)Session["playerProgression"] - 1].Button2Text; GloballyAccessibleClass.Instance.EventsSystem = new EventSystem(); return(View(eventsViewModel)); }