Esempio n. 1
0
        public ActionResult ComputerSecond(int id)
        {
            Battle      computer      = Battle.FindComputer();
            Battle      player        = Battle.FindPlayer();
            List <Move> computerMoves = Mon.Find(computer.GetMon_Id()).GetMoves();
            Random      move          = new Random();
            Move        computerMove  = computerMoves[move.Next(computerMoves.Count)];

            player.SetLastHitpoints();
            Message.DeleteAll();
            if (player.GetHitpoints() == 0)
            {
                return(RedirectToAction("Lose"));
            }
            else
            {
                Battle.ComputerSequence2(id, computerMove);
                player = Battle.FindPlayer();
                Dictionary <string, object> model = new Dictionary <string, object>();
                List <Move> playerMoves           = Mon.Find(player.GetMon_Id()).GetMoves();
                Message     newMessage            = new Message("<a href='/Battle/Combat'>Continue</a>");
                newMessage.Save();
                List <Message> turnMessages = Message.GetAllMessages();


                model.Add("player", player);
                model.Add("computer", computer);
                model.Add("playerMoves", playerMoves);
                model.Add("turnMessages", turnMessages);
                model.Add("computerMove", computerMove);
                return(View(model));
            }
        }
Esempio n. 2
0
        public ActionResult Combat()
        {
            Dictionary <string, object> model = new Dictionary <string, object>();
            Battle         player             = Battle.FindPlayer();
            Battle         computer           = Battle.FindComputer();
            List <Move>    playerMoves        = Mon.Find(player.GetMon_Id()).GetMoves();
            List <Message> turnMessages       = Message.GetAllMessages();

            model.Add("player", player);
            model.Add("computer", computer);
            model.Add("playerMoves", playerMoves);
            model.Add("turnMessages", turnMessages);
            if (player.GetHitpoints() == 0)
            {
                return(RedirectToAction("Lose"));
            }
            else if (computer.GetHitpoints() == 0)
            {
                return(RedirectToAction("Win"));
            }
            else
            {
                return(View(model));
            }
        }
Esempio n. 3
0
        public ActionResult PlayerFirst(int id)
        {
            Message.DeleteAll();
            Battle computer = Battle.FindComputer();

            computer.SetLastHitpoints();
            Battle.PlayerSequence1(id);
            Dictionary <string, object> model = new Dictionary <string, object>();
            Battle player = Battle.FindPlayer();

            computer = Battle.FindComputer();
            List <Move> playerMoves = Mon.Find(player.GetMon_Id()).GetMoves();
            Message     newMessage  = new Message("<a href='/Battle/Combat/Computer2/" + id + "'>Continue</a>");

            newMessage.Save();
            List <Message> turnMessages = Message.GetAllMessages();

            Move usedMove = Move.Find(id);

            model.Add("player", player);
            model.Add("computer", computer);
            model.Add("playerMoves", playerMoves);
            model.Add("turnMessages", turnMessages);
            model.Add("usedMove", usedMove);

            return(View(model));
        }
Esempio n. 4
0
        public ActionResult PlayerSecond(int id)
        {
            Battle player = Battle.FindPlayer();

            if (player.GetHitpoints() == 0)
            {
                return(RedirectToAction("Lose"));
            }
            else
            {
                Message.DeleteAll();
                Battle computer = Battle.FindComputer();
                computer.SetLastHitpoints();
                Battle.PlayerSequence2(id);
                Dictionary <string, object> model = new Dictionary <string, object>();
                player   = Battle.FindPlayer();
                computer = Battle.FindComputer();
                List <Move> playerMoves = Mon.Find(player.GetMon_Id()).GetMoves();
                Message     newMessage  = new Message("<a class='continuebutton' href='/Battle/Combat/'><button class='btn btn-primary'>Continue</button></a>");
                newMessage.Save();
                List <Message> turnMessages = Message.GetAllMessages();

                Move usedMove = Move.Find(id);

                model.Add("player", player);
                model.Add("computer", computer);
                model.Add("playerMoves", playerMoves);
                model.Add("turnMessages", turnMessages);
                model.Add("usedMove", usedMove);

                return(View(model));
            }
        }
Esempio n. 5
0
        public ActionResult ComputerFirst(int id)
        {
            Battle      player        = Battle.FindPlayer();
            Battle      computer      = Battle.FindComputer();
            List <Move> computerMoves = Mon.Find(computer.GetMon_Id()).GetMoves();
            Random      move          = new Random();
            Move        computerMove  = computerMoves[move.Next(computerMoves.Count)];

            player.SetLastHitpoints();
            Message.DeleteAll();

            Battle.ComputerSequence1(id, computerMove);
            player = Battle.FindPlayer();
            Dictionary <string, object> model = new Dictionary <string, object>();
            Message newMessage = new Message("<a class='continuebutton' href='/Battle/Combat/Player2/" + id + "'><button class='btn btn-primary'>Continue</button></a>");

            newMessage.Save();
            List <Message> turnMessages = Message.GetAllMessages();


            model.Add("player", player);
            model.Add("computer", computer);
            model.Add("turnMessages", turnMessages);
            model.Add("computerMove", computerMove);
            return(View(model));
        }
Esempio n. 6
0
        public ActionResult DoBattle(int id)
        {
            Battle.DeleteAll();
            Mon    playerMon = Mon.Find(id);
            Battle newPlayer = playerMon.GetAllTrueStats();

            newPlayer.Save();
            newPlayer.SetPlayerMon();
            newPlayer.SetActiveMon();
            Battle.ComputerChoice(id);
            return(RedirectToAction("Combat"));
        }
Esempio n. 7
0
        public ActionResult View(int id)
        {
            Dictionary <string, object> model = new Dictionary <string, object>();
            Mon            selectedMon        = Mon.Find(id);
            List <MonType> types     = selectedMon.GetMonTypes();
            List <Move>    monsmoves = selectedMon.GetMoves();

            model.Add("types", types);
            model.Add("mon", selectedMon);
            model.Add("moves", monsmoves);

            return(View(model));
        }
Esempio n. 8
0
        public ActionResult Lose()
        {
            Dictionary <string, object> model = new Dictionary <string, object>();
            Battle         player             = Battle.FindPlayer();
            Battle         computer           = Battle.FindComputer();
            List <Move>    playerMoves        = Mon.Find(player.GetMon_Id()).GetMoves();
            List <Message> turnMessages       = Message.GetAllMessages();

            model.Add("player", player);
            model.Add("computer", computer);
            model.Add("playerMoves", playerMoves);
            model.Add("turnMessages", turnMessages);

            return(View(model));
        }
Esempio n. 9
0
        public ActionResult Index()
        {
            Message.DeleteAll();
            Battle.DeleteAll();
            Dictionary <string, object> model = new Dictionary <string, object>();
            Mon        mon1    = Mon.Find(1);
            Mon        mon2    = Mon.Find(2);
            Mon        mon3    = Mon.Find(3);
            List <Mon> allMons = Mon.GetAllMons();

            model.Add("monone", mon1);
            model.Add("montwo", mon2);
            model.Add("monthree", mon3);
            model.Add("allMons", allMons);

            return(View(model));
        }
Esempio n. 10
0
        public void Find_Test()
        {
            //Arrange
            Mon newMon = new Mon("Snorlax", 4, 2, 4, 3, 5, 6, 22);

            newMon.Save();

            //Act
            Mon result = Mon.Find(newMon.GetMonId());

            //Assert
            Console.WriteLine(result.GetMonName());
            Console.WriteLine(result.GetLevel());
            Console.WriteLine(result.GetHitpoints());
            Console.WriteLine(result.GetAttack());
            Console.WriteLine(result.GetDefense());
            Console.WriteLine(result.GetSpecialattack());
            Console.WriteLine(result.GetSpecialdefense());
            Console.WriteLine(result.GetSpeed());


            Assert.AreEqual(newMon, result);
        }