Esempio n. 1
0
        public void RepairItem()
        {
            RPGSQLContext context = new RPGSQLContext();
            RPGRepository repo    = new RPGRepository(context);

            repo.ExecuteRepairDurability(ItemId);
        }
Esempio n. 2
0
        public void DamageItem(int damage)
        {
            RPGSQLContext context = new RPGSQLContext();
            RPGRepository repo    = new RPGRepository(context);

            repo.ExecuteDamageToItem(ItemId);
        }
Esempio n. 3
0
        public void initWeapons()
        {
            RPGSQLContext context = new RPGSQLContext();
            RPGRepository repo    = new RPGRepository(context);

            Weapon = repo.GetItemById(Wepid);
            Armor  = repo.GetItemById(Armorid);
        }
Esempio n. 4
0
        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));
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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"));
        }
Esempio n. 7
0
        /// <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);
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
        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"));
        }
Esempio n. 10
0
        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);
        }
Esempio n. 11
0
        /// <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()));
        }