public void RepairItem() { RPGSQLContext context = new RPGSQLContext(); RPGRepository repo = new RPGRepository(context); repo.ExecuteRepairDurability(ItemId); }
public void DamageItem(int damage) { RPGSQLContext context = new RPGSQLContext(); RPGRepository repo = new RPGRepository(context); repo.ExecuteDamageToItem(ItemId); }
public ActionResult Login(string naam, string pass) { RPGRepository rpgrepo = new RPGRepository(rpgsql); try { if (rpgrepo.TryLogin(naam, pass)) { userview.LoginMessage = "U bent ingelogd."; userview.UserID = rpgrepo.GetUserId(naam, pass); Session["UserID"] = userview.UserID; userview.Name = naam; userview.Password = pass; userview.Loggedin = true; } else { userview.LoginMessage = "Verkeerde gebruikersnaam of wachtwoord. Probeer het opnieuw."; } } catch (Exception e) { userview.LoginMessage = "Connection to database failed. Please connect to VPN."; } return(View(userview)); }
public void initWeapons() { RPGSQLContext context = new RPGSQLContext(); RPGRepository repo = new RPGRepository(context); Weapon = repo.GetItemById(Wepid); Armor = repo.GetItemById(Armorid); }
public ActionResult Register(string naam, string pass) { RPGRepository rpgrepo = new RPGRepository(rpgsql); rpgrepo.AddUserToDB(naam, pass); return(RedirectToAction("Login")); }
public ActionResult AddCharacter(string name, int classid, int raceid) { RPGSQLContext rpgsqlContext = new RPGSQLContext(); RPGRepository repo = new RPGRepository(rpgsqlContext); repo.AddCharacter((int)Session["UserID"], classid, raceid, name); _loginview.UserID = (int)Session["UserID"]; return(RedirectToAction("Character", _loginview)); }
public void GetAllRPGs() { RPGRepository RPGRepo = new RPGRepository(); //Act RPG[] rpgs = RPGRepo.FindAll(); //Assert Assert.AreEqual(0, rpgs.Count); }
public void DatabaseDataTest() { RPGSQLContext context = new RPGSQLContext(); RPGRepository repo = new RPGRepository(context); Character character = repo.GetById(1); //Character info test Assert.AreEqual("Boro", character.Name); Assert.AreEqual(9, character.Wepid); Assert.AreEqual(12, character.Armorid); Assert.AreEqual(250, character.HP); Assert.AreEqual(25, character.Mana); }
public void UserLoginTest() { RPGSQLContext context = new RPGSQLContext(); RPGRepository repo = new RPGRepository(context); User loggedUser = new User(); loggedUser.Username = "******"; loggedUser.Password = "******"; //Test correct password entry Assert.AreEqual(true, repo.TryLogin(loggedUser.Username, loggedUser.Password)); //Test incorrect password entry Assert.AreEqual(false, repo.TryLogin(loggedUser.Username, "Randompass")); }
/// <summary> /// The player comes out of the combat screen and gets an item drop. His weapon also takes durability damage. /// </summary> /// <returns></returns> public ActionResult ReturnFromCombat() { RPGRepository rpgrepo = new RPGRepository(rpgct); int ids = (int)Session["CharId"]; Session["evm"] = null; int itemid = rpgrepo.GetItemDrop((int)Session["CharId"]); Character character = rpgrepo.GetById((int)Session["CharId"]); int itemidweapon = character.Wepid; rpgrepo.ExecuteDamageToItem(itemidweapon); Session["itemdrop"] = itemid; return(RedirectToAction("Play", new { id = ids })); }
/// <summary> /// Load the page where the user can see all of the character linked to his userid. /// </summary> /// <param name="loginView"></param> /// <returns></returns> public ActionResult Character(UserLoginViewModel loginView) { //Add characters from the logged in users to a view if (loginView != null) { Session["UserID"] = loginView.UserID; } RPGRepository rpgrepo = new RPGRepository(rpgct); _charViewModel = new CharacterViewModel { Characters = rpgrepo.GetCharactersFromUser(loginView.UserID) }; _loginview = loginView; return(View(_charViewModel)); }
/// <summary> /// This method returns a created eventsviewmodel which loads its content from a database with the characterid stored in the session. /// </summary> /// <returns></returns> public EventsViewModel GetEventsViewModel() { RPGSQLContext rpgsqlContext = new RPGSQLContext(); RPGRepository repo = new RPGRepository(rpgsqlContext); Character cha = repo.GetById(Convert.ToInt32(Session["CharId"])); cha.InventoryList = repo.GetInventory(Convert.ToInt32(Session["CharId"])); cha.initWeapons(); eventsViewModel.EventsSystem = new EventSystem(); eventsViewModel.EventsSystem.character = cha; eventsViewModel.EventsSystem.ScenarioList = repo.GetStory(); eventsViewModel.EventsSystem.playerProgression = Convert.ToInt32(Session["playerProgression"]); Session["Button1Name"] = eventsViewModel.EventsSystem.ScenarioList[(int)Session["playerProgression"] - 1].Button1Text; Session["Button2Name"] = eventsViewModel.EventsSystem.ScenarioList[(int)Session["playerProgression"] - 1].Button2Text; return(eventsViewModel); }
public void Select_Character() { RPGSQLContext context = new RPGSQLContext(); RPGRepository repo = new RPGRepository(context); User user = new User(); user.Username = "******"; user.Password = "******"; //Get the userid from the logged user int userid = repo.GetUserId(user.Username, user.Password); //Get the character from the user List <Character> characters = repo.GetCharactersFromUser(userid); //Send selected character to login view RPGController rpgController = new RPGController(); rpgController.Play(characters[1].CharacterID); }
/// <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)); }
public void Account_Add() { RPGSQLContext context = new RPGSQLContext(); RPGRepository repo = new RPGRepository(context); string testlogin = "******"; string testPassword = "******"; //Add user with a test login/password repo.AddUserToDB(testlogin, testPassword); //Create a user with the created account User loggedUser = new User(); loggedUser.Username = testlogin; loggedUser.Password = testPassword; //Test correct password entry with the newly created account Assert.AreEqual(true, repo.TryLogin(loggedUser.Username, loggedUser.Password)); //Test incorrect password entry Assert.AreEqual(false, repo.TryLogin(loggedUser.Username, "Randompass")); }
public void Add_Character() { RPGSQLContext context = new RPGSQLContext(); RPGRepository repo = new RPGRepository(context); string testname = "TestUserCharacter9"; //Add a test character to userid 2, with class and race id 2 and the name TestUserCharacter repo.AddCharacter(2, 2, 2, testname); //Get the character from the database Character character = null; List <Character> characters = repo.GetCharactersFromUser(2); foreach (Character chars in characters) { if (chars.Name == testname) { character = chars; } } //Character info test Assert.AreEqual(testname, character.Name); }
/// <summary> /// This method uses the characters progressionid to show events linked to that id. It also uses this to redirect the user to combat if nessesary. /// </summary> /// <param name="command"></param> /// <returns></returns> public ActionResult RedirectToCommand(string command) { RPGRepository rpgrepo = new RPGRepository(rpgct); int prog = Convert.ToInt32(Session["playerProgression"]); if (command == "Action1") { if (prog == 1) { prog = 3; } else if (prog == 2) { //add combat redirect prog = 5; Session["playerProgression"] = prog; return(RedirectToAction("Combat")); } else if (prog == 3) { prog = 4; } else if (prog == 4) { prog = 5; } else if (prog == 5) { //Add DBO querry voor weapon repair prog = 7; RPGSQLContext rpgsqlContext = new RPGSQLContext(); RPGRepository repo = new RPGRepository(rpgsqlContext); Character cha = repo.GetById(Convert.ToInt32(Session["CharId"])); cha.InventoryList = repo.GetInventory(Convert.ToInt32(Session["CharId"])); cha.initWeapons(); cha.Weapon.RepairItem(); } else if (prog == 6) { prog = 7; } else if (prog == 7) { prog = 10; Session["playerProgression"] = prog; return(RedirectToAction("Combat")); } else if (prog == 9) { prog = 11; } else if (prog == 10) { prog = 11; } else if (prog == 11) { Session["playerProgression"] = 1; return(RedirectToAction("Logout", "Account")); } } else if (command == "Action2") { if (prog == 1) { prog = 2; } else if (prog == 4) { prog = 6; } else if (prog == 7) { prog = 9; } else if (prog == 11) { Session["playerProgression"] = 1; return(RedirectToAction("Logout", "Account")); } } Session["playerProgression"] = prog; return(View("Play", GetEventsViewModel())); }