示例#1
0
        static void Main(string[] args)
        {
            HumanClass Ben = new HumanClass("Ben");

            Console.WriteLine($"{Ben.Name} is losing his mind");
            Buffet firstBuffet = new Buffet();

            Console.WriteLine($"{Ben.Name} got a {firstBuffet.Serve().Name}");
            Ninja carol = new Ninja("Carol");

            Console.WriteLine($"{carol.Name} is a ninja!");
            carol.Eat(firstBuffet.Serve());
            carol.Eat(firstBuffet.Serve());
            carol.Eat(firstBuffet.Serve());
            carol.Eat(firstBuffet.Serve());
            Wizard  ben  = new Wizard("Ben", 17, 19);
            Ninja   wale = new Ninja("Wale", 17, 19, 150);
            Samurai lola = new Samurai("Lola", 17, 19, 80);

            ben.DisplayStats();
            wale.DisplayStats();
            lola.DisplayStats();
            // ben.Attack(wale);
            wale.Attack(ben);
            ben.DisplayStats();
            lola.Attack(wale);
            ben.Heal(wale);
            lola.Meditate();
            wale.Steal(ben);
        }
示例#2
0
        static void Main(string[] args)
        {
            //Console.Writeline();
            Ninja   ninja1   = new Ninja("Makenna the Ninja");
            Wizard  wizard1  = new Wizard("Oscar the Wizard");
            Samurai samurai1 = new Samurai("Carlos the Samurai");
            Ninja   ninja2   = new Ninja("Dany the Ninja");

            ninja1.stats();
            wizard1.stats();
            samurai1.stats();
            //Dany.stats();
            Console.WriteLine("****New Game Starting Now****");
            samurai1.Attack(ninja1);
            ninja1.Steal(wizard1);
            ninja1.Attack(wizard1);
            wizard1.Attack(ninja1);
            wizard1.Heal(ninja1);
            //Oscar.Attack(Carlos);
            //Oscar.Attack(Dany);
            //Makenna.Attack(Dany);
            //Carlos.Attack(Dany);
            //Oscar.Attack(Dany);
            //Makenna.Attack(Dany);
            //Oscar.Heal(Dany);
            samurai1.Meditate();
            ninja1.stats();
            wizard1.stats();
            samurai1.stats();
            //Dany.stats();



            //Console.WriteLine(Makenna.Dexterity);
        }
示例#3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Learning OOP for CSharp!");
            Human Thor = new Human("Thor, God of Thunder", 10, 100, 10, 10);
            Human Loki = new Human("Loki, God of Mischief");
            // Thor.LightningStrike(Loki);
            // Loki.ShowStats();
            // Loki.Attack(Thor);
            // Thor.ShowStats();
            Wizard doc = new Wizard("Doctor Steven Strange");

            doc.ShowStats();
            Ninja naruto = new Ninja("Naruto Shipoden");

            // naruto.ShowStats();
            // naruto.Attack(Loki);
            // Loki.ShowStats();
            // doc.Attack(Thor);
            // Thor.ShowStats();
            // doc.ShowStats();
            // doc.Heal(Thor);
            // Thor.ShowStats();
            naruto.Steal(doc);
            naruto.Attack(doc);
        }
示例#4
0
        static void Main(string[] args)
        {
            Human bill = new Human("Billy");
            Human bob  = new Human("Bobby", 8, 4, 7, 100);

            bill.Attack(bob);
            bob.DisplayStat();
            Wizard w1 = new Wizard("Will");

            w1.DisplayStat();
            Console.WriteLine("############");
            Ninja n1 = new Ninja("Aon");

            n1.DisplayStat();
            Console.WriteLine("############");
            Samurai s1 = new Samurai("Panajon");

            s1.DisplayStat();
            Console.WriteLine("############");

            Wizard w2 = new Wizard("Mike");

            n1.DisplayStat();
            n1.Attack(s1);
            s1.DisplayStat();
            s1.Meditate();
            s1.DisplayStat();
        }
示例#5
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            IWeapon  sword = new Sword();
            IWarrior Ninja = new Ninja(sword);

            Console.WriteLine(Ninja.Attack("whatever"));
        }
示例#6
0
文件: Program.cs 项目: triebelscj/wns
        static void Main(string[] args)
        {
            Human Zoe     = new Human("Zoe");
            Human Brent   = new Human("Brent");
            Human Shirley = new Human("Shirley");

            Wizard  Cj   = new Wizard("Cj");
            Ninja   Sam  = new Ninja("Sam");
            Samurai Lisa = new Samurai("Lisa");

            Cj.Attack(Zoe);
            Sam.Attack(Shirley);
            for (int i = 0; i < 6; i++)
            {
                Lisa.Attack(Brent);
            }

            Cj.FirstAid(Zoe);
            Sam.Attack(Shirley);
        }
示例#7
0
        static void Main(string[] args)
        {
            Wizard  nathanWiz     = new Wizard("Wizar");
            Ninja   nathanNinja   = new Ninja("Ninja");
            Samurai nathanSamurai = new Samurai("Samurai");

            nathanWiz.Attack(nathanNinja);
            nathanNinja.Attack(nathanSamurai);
            nathanWiz.Attack(nathanSamurai);
            nathanSamurai.Attack(nathanWiz);
            nathanSamurai.Meditate();
        }
示例#8
0
            static void Main(string[] args)
            {
                Wizard  Naruto = new Wizard("Naruto");
                Ninja   Sauske = new Ninja("Sauske");
                Samurai Sakura = new Samurai("Sakura");

                Sakura.Attack(Naruto);
                Naruto.Attack(Sauske);
                Sauske.Attack(Sakura);
                Sauske.Steal(Naruto);
                Sakura.Meditate();
                Naruto.Heal(Naruto);
            }
示例#9
0
        static void Main(string[] args)
        {
            Human Dave  = new Human("Dave");
            Human Bob   = new Human("Bob");
            Human Steve = new Human("Steve");

            Wizard  Izac   = new Wizard("Izac");
            Ninja   Collin = new Ninja("Collin");
            Samurai Zach   = new Samurai("Zach");

            Izac.Attack(Dave);
            Collin.Attack(Bob);
            for (int i = 0; i < 6; i++)
            {
                Zach.Attack(Steve);
            }

            Izac.FirstAid(Dave);
            Collin.Steal(Bob);
            Collin.Attack(Zach);
            Zach.Meditate();
        }
        static void Main(string[] args)
        {
            Human dummy1 = new Human("dummy1");
            Human dummy2 = new Human("dummy2");
            Human dummy3 = new Human("dummy3");

            Wizard  wizard  = new Wizard("wizard");
            Ninja   ninja   = new Ninja("ninja");
            Samurai samurai = new Samurai("samurai");

            wizard.Attack(dummy1);
            ninja.Attack(dummy2);
            for (int i = 0; i < 6; i++)
            {
                samurai.Attack(dummy3);
            }

            wizard.Heal(dummy1);
            ninja.Steal(dummy2);
            ninja.Attack(samurai);
            samurai.Meditate();
        }
示例#11
0
        static void Main(string[] args)
        {
            Human  nibbles = new Human("Mr. Nibbles");
            Wizard benny   = new Wizard("Benny Bob");

            benny.Attack(nibbles);
            Ninja adam = new Ninja("Adam");

            adam.Attack(benny);
            Samurai bob = new Samurai("Bob");

            bob.Attack(benny);
            Wizard ken = new Wizard("Ken");

            ken.Heal(benny);
        }
示例#12
0
        public void NinjaNoInject()
        {
            //Arrange
            Weapon  weapon;
            Warrior warrior;
            string  attackTarget = "target";

            //Act
            weapon  = new Sword();
            warrior = new Ninja(weapon);

            //Assert
            Assert.IsInstanceOfType(warrior, typeof(Warrior));
            Assert.IsInstanceOfType(warrior, typeof(Ninja));
            Assert.IsInstanceOfType(warrior.Weapon, typeof(Sword));
            Assert.AreEqual(warrior.Attack(attackTarget), $"{warrior.Weapon.Name} hits {attackTarget}");
        }
示例#13
0
 void Start()
 {
     devon.SayName();
     Debug.Log(devon.Stealth);
     devon.Attack(becca);
 }
    private void Update()
    {
        //	Mengubah arah hadap karakter
        player.CurrentSide();

        if (player.transform.position.x == Vector3.zero.x)
        {
            player.Idle();
        }

        if ((EventSystem.current.IsPointerOverGameObject() || Input.touchCount > 0) || Input.anyKeyDown)
        {
            //	Bergerak kekanan / kekiri
            if ((EventSystem.current.currentSelectedGameObject.name == UIManager.Instance.leftBtn.name && Input.GetMouseButton(0)) || Input.GetKey(KeyCode.LeftArrow))
            {
                player.leftSide = true;
                Controller.Instance.Move(player.GetComponent <Transform>(), UIManager.Instance.Movebtn(), player.GetSpeed());
                if (Mathf.Abs(player.transform.position.x) > 0.001f)
                {
                    player.Run();
                }
            }
            else if ((EventSystem.current.currentSelectedGameObject.name == UIManager.Instance.rightBtn.name && Input.GetMouseButton(0)) || Input.GetKey(KeyCode.RightArrow))
            {
                player.leftSide = false;
                Controller.Instance.Move(player.GetComponent <Transform>(), UIManager.Instance.Movebtn(), player.GetSpeed());
                if (Mathf.Abs(player.transform.position.x) > 0.001f)
                {
                    player.Run();
                }
            }

            //	Melompat, meluncur, menyerang, melempar kunai
            //	Melompat
            if ((Input.GetMouseButtonDown(0) && (EventSystem.current.currentSelectedGameObject.name == UIManager.Instance.jumpBtn.name)) || Input.GetKey(KeyCode.Space))
            {
                Controller.Instance.Move(player.GetComponent <Transform>(), UIManager.Instance.JumpBtn(), player.GetSpeed());
                if (Mathf.Abs(UIManager.Instance.targetPosition.y) > Vector3.zero.y)
                {
                    Controller.Instance.Jump(player.GetComponent <Transform>(), player.GetHighJump());
                    if ((EventSystem.current.currentSelectedGameObject.name == UIManager.Instance.attackBtn.name) || Input.GetKey(KeyCode.A))
                    {
                        player.JumpAttack();
                    }
                    else if ((EventSystem.current.currentSelectedGameObject.name == UIManager.Instance.throwBtn.name) || Input.GetKey(KeyCode.RightShift))
                    {
                        player.JumpThrow();
                    }
                    else
                    {
                        player.Jump();
                    }
                }
            }
            //	Meluncur
            else if ((Input.GetMouseButtonDown(0) && (EventSystem.current.currentSelectedGameObject.name == UIManager.Instance.slideBtn.name)) || Input.GetKey(KeyCode.LeftShift))
            {
                Controller.Instance.Slide(player.GetComponent <Transform>(), UIManager.Instance.Movebtn(), player.GetSlideSpeed());
                player.Slide();
            }
            //	Menyerang
            if ((Input.GetMouseButtonDown(0) && (EventSystem.current.currentSelectedGameObject.name == UIManager.Instance.attackBtn.name)) || Input.GetKey(KeyCode.A))
            {
                player.Attack();
            }
            //	Melempar kunai
            else if ((Input.GetMouseButtonDown(0) && (EventSystem.current.currentSelectedGameObject.name == UIManager.Instance.throwBtn.name)) || Input.GetKey(KeyCode.RightShift))
            {
                player.Throw();
            }
        }
        else
        {
            Controller.Instance.Move(player.GetComponent <Transform>(), Vector3.zero, 0f);
        }
    }
示例#15
0
        static void Main(string[] args)
        {
            RayGun     green    = new RayGun("green ray gun", 2);
            RayGun     red      = new RayGun("red ray gun", 4);
            SpaceArmor titanium = new SpaceArmor("titanium space armor", 50);
            SpaceArmor alien    = new SpaceArmor("alien tech space armor", 100);
            GravBoots  nike     = new GravBoots("Nike grav boots", 2);
            GravBoots  adidas   = new GravBoots("Adidas grav boots", 4);
            AlienText  romulan  = new AlienText("book of Romulan wisdom", 2);
            AlienText  vulcan   = new AlienText("book of Vulcan wisdom", 4);

            IEquipable[] treasure = new IEquipable[8] {
                green, red, titanium, alien, nike, adidas, romulan, vulcan
            };

            ConsoleYellow("********NINJAS IN SPACE********");

            Hero player = PlayerSetup();

            ConsoleYellow($"You, {player.Name}, have been chosen(randomly selected) to join a team of developer ninjas on a space quest!  To seek out new algorithms, new data structures, and go where no else wants to go! DEEP SPACE!!!\n\nHere you will encounter aliens, space monsters, and the unknown to bring back algorithms to benefit all humans. You now must choose your team.\n\nPress Enter to Start");

            ConsoleKey key = Console.ReadKey(true).Key;

            while (key != ConsoleKey.Enter)
            {
                key = Console.ReadKey(true).Key;
            }
            Console.WriteLine("Please select two crew members");

            Hero teammate1 = TeamSetup();
            Hero teammate2 = TeamSetup();

            List <Hero> party = new List <Hero>()
            {
                player, teammate1, teammate2
            };

            int planet = 0;

            while (planet < 5)
            {
                Console.WriteLine("");
                ConsoleYellow($"Welcome to Planet {planet+1}!");
                ConsoleYellow("=====================");
                List <Enemy> enemies = new List <Enemy>();

                Spider    enemy1 = new Spider("Space Spider 1");
                Zombie    enemy2 = new Zombie("Space Zombie 1");
                Xenomorph enemy3 = new Xenomorph("Xenomorph 1");
                enemies.Add(enemy1);
                enemies.Add(enemy2);
                enemies.Add(enemy3);

                Random die   = new Random();
                int    round = 0;
                while (SumHealthParty(party) > 0 && SumHealthEnemies(enemies) > 0)
                {
                    int turn = round % 6;
                    if (turn >= 0 && turn < 3)
                    {
                        if (party[turn].Health > 0)
                        {
                            Console.WriteLine("");
                            EncounterStatus(party, enemies);
                            if (party[turn] is Ninja)
                            {
                                Ninja ninjaClone = (Ninja)party[turn];
                                Console.WriteLine($"{ninjaClone.Name}'s turn. (A)ttack or (B)ackstab?");
                                string Action = Console.ReadLine();
                                Console.WriteLine($"Target? (1){enemies[0].Name} (2){enemies[1].Name} (3){enemies[2].Name}");
                                string Target = Console.ReadLine();
                                if (Action == "A")
                                {
                                    ninjaClone.Attack(enemies[int.Parse(Target) - 1]);
                                }
                                else if (Action == "B")
                                {
                                    ninjaClone.Backstab(enemies[int.Parse(Target) - 1]);
                                }
                                else if (Action == "Z")
                                {
                                    enemies[int.Parse(Target) - 1].Health = 0;
                                    Console.WriteLine("Let's get this over with");
                                    Console.WriteLine("");
                                }
                            }
                            else if (party[turn] is Samurai)
                            {
                                Samurai samuraiClone = (Samurai)party[turn];
                                Console.WriteLine($"{samuraiClone.Name}'s turn. (A)ttack or (M)editate?");
                                string Action = Console.ReadLine();
                                if (Action == "A")
                                {
                                    Console.WriteLine($"Target? (1){enemies[0].Name} (2){enemies[1].Name} (3){enemies[2].Name}");
                                    string Target = Console.ReadLine();
                                    samuraiClone.Attack(enemies[int.Parse(Target) - 1]);
                                }
                                else if (Action == "M")
                                {
                                    samuraiClone.Meditate();
                                }
                                else if (Action == "Z")
                                {
                                    Console.WriteLine($"Target? (1){enemies[0].Name} (2){enemies[1].Name} (3){enemies[2].Name}");
                                    string Target = Console.ReadLine();
                                    enemies[int.Parse(Target) - 1].Health = 0;
                                    Console.WriteLine("Let's get this over with");
                                    Console.WriteLine("");
                                }
                            }
                            else if (party[turn] is Wizard)
                            {
                                Wizard wizardClone = (Wizard)party[turn];
                                Console.WriteLine($"{wizardClone.Name}'s turn. (A)ttack or (S)hield?");
                                string Action = Console.ReadLine();
                                if (Action == "A")
                                {
                                    Console.WriteLine($"Target? (1){enemies[0].Name} (2){enemies[1].Name} (3){enemies[2].Name}");
                                    string Target = Console.ReadLine();
                                    wizardClone.Attack(enemies[int.Parse(Target) - 1]);
                                }
                                else if (Action == "S")
                                {
                                    Console.WriteLine($"Target? (1){party[0].Name} (2){party[1].Name} (3){party[2].Name}");
                                    string Target = Console.ReadLine();
                                    wizardClone.Shield(party[int.Parse(Target) - 1]);
                                }
                                else if (Action == "Z")
                                {
                                    Console.WriteLine($"Target? (1){enemies[0].Name} (2){enemies[1].Name} (3){enemies[2].Name}");
                                    string Target = Console.ReadLine();
                                    enemies[int.Parse(Target) - 1].Health = 0;
                                    Console.WriteLine("Let's get this over with");
                                    Console.WriteLine("");
                                }
                            }
                        }
                    }
                    else
                    {
                        if (enemies[turn - 3].Health > 0)
                        {
                            Console.WriteLine("");
                            EncounterStatus(party, enemies);
                            if (enemies[turn - 3] is Zombie)
                            {
                                Zombie zombieClone = (Zombie)enemies[turn - 3];
                                Console.WriteLine($"{zombieClone.Name}'s turn.");
                                Random rand     = new Random();
                                bool   attacked = false;
                                while (!attacked)
                                {
                                    int target = rand.Next(3);
                                    if (party[target].Health > 0)
                                    {
                                        zombieClone.Attack(party[target]);
                                        attacked = true;
                                    }
                                }
                                Console.WriteLine("Please press \"Enter\" to continue");
                                string Action = Console.ReadLine();
                            }
                            else if (enemies[turn - 3] is Spider)
                            {
                                Spider spiderClone = (Spider)enemies[turn - 3];
                                Console.WriteLine($"{spiderClone.Name}'s turn.");
                                Random rand     = new Random();
                                bool   attacked = false;
                                while (!attacked)
                                {
                                    int target = rand.Next(3);
                                    if (party[target].Health > 0)
                                    {
                                        spiderClone.Attack(party[target]);
                                        attacked = true;
                                    }
                                }
                                Console.WriteLine("Please press \"Enter\" to continue");
                                string Action = Console.ReadLine();
                            }
                            else if (enemies[turn - 3] is Xenomorph)
                            {
                                Xenomorph xenoClone = (Xenomorph)enemies[turn - 3];
                                Console.WriteLine($"{xenoClone.Name}'s turn.");
                                Random rand     = new Random();
                                bool   attacked = false;
                                while (!attacked)
                                {
                                    int target = rand.Next(3);
                                    if (party[target].Health > 0)
                                    {
                                        xenoClone.Attack(party[target]);
                                        attacked = true;
                                    }
                                }
                                Console.WriteLine("Please press \"Enter\" to continue");
                                string Action = Console.ReadLine();
                            }
                        }
                    }
                    if (SumHealthEnemies(enemies) <= 0)
                    {
                        Console.WriteLine("All enemies vanquished! Congratulations!");
                        int        d8            = die.Next(8);
                        IEquipable foundTreasure = treasure[d8];
                        Equipment  equipClone    = (Equipment)foundTreasure;
                        Console.WriteLine($"You found {equipClone.Name}! {equipClone.Desc} Who should equip it?");
                        string choice = "0";
                        while (choice != "1" && choice != "2" && choice != "3")
                        {
                            Console.WriteLine($"Please type the number of the hero you would like to equip:\n1. {party[0].Name}\n2. {party[1].Name}\n3. {party[2].Name}");
                            choice = Console.ReadLine();
                        }
                        switch (choice)
                        {
                        case ("1"):
                            foundTreasure.Equip(party[0]);
                            Console.WriteLine($"{party[0].Name} has equipped the {equipClone.Name}");
                            party[0].ShowStats();
                            Console.WriteLine("");
                            break;

                        case ("2"):
                            foundTreasure.Equip(party[1]);
                            Console.WriteLine($"{party[1].Name} has equipped the {equipClone.Name}");
                            party[1].ShowStats();
                            Console.WriteLine("");
                            break;

                        case ("3"):
                            foundTreasure.Equip(party[2]);
                            Console.WriteLine($"{party[2].Name} has equipped the {equipClone.Name}");
                            party[2].ShowStats();
                            Console.WriteLine("");
                            break;
                        }
                        Console.WriteLine("Onward to the next planet! Good thing you brought clones of everyone!");
                        player.Health    = player.MaxHealth;
                        teammate1.Health = teammate1.MaxHealth;
                        teammate2.Health = teammate2.MaxHealth;
                        Console.WriteLine("");
                        planet++;
                        if (planet == 5)
                        {
                            ConsoleYellow("You've certainly accomplished something! Saved the universe? Sure! Congratulations!");
                        }
                    }
                    if (SumHealthParty(party) <= 0)
                    {
                        ConsoleYellow("Your party was killed in self-defense! Game over!");
                        planet = 5;
                    }
                    round++;
                }
            }
        }
示例#16
0
        public IActionResult PlayersTurn(int attk)
        {
            int        PlayerId  = (int)HttpContext.Session.GetInt32("PlayerId");
            Player     Player1   = _context.player.SingleOrDefault(p => p.PlayerId == PlayerId);
            int?       enconId   = HttpContext.Session.GetInt32("EncounterId");
            Encounters encounter = _context.encounters.SingleOrDefault(e => e.EncountersId == enconId);
            Enemies    monster   = _context.enemies.Where(m => m.EncountersId == enconId && m.life == true).First();
            Story      newStory  = new Story();
            Story      newStory2 = new Story();

            if (Player1.Class == "mage")
            {
                Mage Player = _context.mage.SingleOrDefault(p => p.PlayerId == PlayerId);
                if (attk == 1)
                {
                    int attackVal = Player.Attack(monster);
                    attackVal.ToString();
                    newStory.storyBook = "You attacked a " + monster.name + " and did " + attackVal + " damage.";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
                else if (attk == 2)
                {
                    Player.Heal();
                    newStory.storyBook = "You used heal";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 4;
                }
                else if (attk == 3)
                {
                    int attackVal = Player.Fireball(monster);
                    newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
                else if (attk == 4)
                {
                    int attackVal = Player.FrostBolt(monster);
                    newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
            }
            if (Player1.Class == "hunter")
            {
                Hunter Player = _context.hunter.SingleOrDefault(p => p.PlayerId == PlayerId);
                if (attk == 1)
                {
                    int attackVal = Player.Attack(monster);
                    attackVal.ToString();
                    newStory.storyBook = "You attacked a " + monster.name + " and did " + attackVal + " damage.";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
                else if (attk == 2)
                {
                    Player.Mend();
                    newStory.storyBook = "You were mended fight on Hunter.";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 4;
                }
                else if (attk == 3)
                {
                    int attackVal = Player.Snipe(monster);
                    newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
                else if (attk == 4)
                {
                    int attackVal = Player.Silencing_Shot(monster);
                    newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
            }
            if (Player1.Class == "samurai")
            {
                Samurai Player = _context.samurai.SingleOrDefault(p => p.PlayerId == PlayerId);
                if (attk == 1)
                {
                    int attackVal = Player.Attack(monster);
                    attackVal.ToString();
                    newStory.storyBook = "You attacked a " + monster.name + " and did " + attackVal + " damage.";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
                else if (attk == 2)
                {
                    Player.Meditate();
                    newStory.storyBook = "You used meditate.";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 4;
                }
                else if (attk == 3)
                {
                    int attackVal = Player.Smash(monster);
                    newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
                else if (attk == 4)
                {
                    int attackVal = Player.Death_Blow(monster);
                    newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
            }
            if (Player1.Class == "ninja")
            {
                Ninja Player = _context.ninja.SingleOrDefault(p => p.PlayerId == PlayerId);
                if (attk == 1)
                {
                    int attackVal = Player.Attack(monster);
                    attackVal.ToString();
                    newStory.storyBook = "You attacked a " + monster.name + " and did " + attackVal + " damage.";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
                else if (attk == 2)
                {
                    Player.Hide();
                    newStory.storyBook = "You hide from the enemies.";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 4;
                }
                else if (attk == 3)
                {
                    int attackVal = Player.Backstab(monster);
                    newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage.";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
                else if (attk == 4)
                {
                    int attackVal = Player.Rend(monster);
                    newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage.";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
            }
            if (Player1.Class == "priest")
            {
                Priest Player = _context.priest.SingleOrDefault(p => p.PlayerId == PlayerId);
                if (attk == 1)
                {
                    int attackVal = Player.Attack(monster);
                    attackVal.ToString();
                    newStory.storyBook = "You attacked a " + monster.name + " and did " + attackVal + " damage.";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
                else if (attk == 2)
                {
                    Player.Holy_Heal();
                    newStory.storyBook = "You healed yourself";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 4;
                }
                else if (attk == 3)
                {
                    int attackVal = Player.Holy_Light(monster);
                    newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
                else if (attk == 4)
                {
                    int attackVal = Player.Smight(monster);
                    newStory.storyBook = "You attacked a " + monster.name + " for " + attackVal + " damage";
                    SetTemp(0);
                    newStory.created_at = DateTime.Now;
                    newStory.PlayerId   = PlayerId;
                    newStory.flag       = 2;
                }
            }
            _context.Add(newStory);
            _context.SaveChanges();
            if (monster.health <= 0)
            {
                monster.health      = 0;
                monster.life        = false;
                newStory2.storyBook = "You killed a " + monster.name;
                SetTemp(-10);
                newStory2.created_at = DateTime.Now;
                newStory2.PlayerId   = PlayerId;
                newStory2.flag       = 2;
                _context.Add(newStory2);
                _context.SaveChanges();
            }
            List <Enemies> enemyCount = _context.enemies.Where(m => m.EncountersId == enconId && m.life == true).ToList();

            if (enemyCount.Count() > 0)
            {
                return(RedirectToAction("EnemiesTurn"));
            }
            int level = (int)HttpContext.Session.GetInt32("Level");

            level++;
            HttpContext.Session.SetInt32("Level", level);
            return(RedirectToAction("firstEncounter"));
        }
示例#17
0
        public void NinjaNoInject()
        {
            //Arrange
            Weapon  weapon;
            Warrior warrior;
            string  target;

            //Act
            weapon  = new Sword();
            warrior = new Ninja(weapon); //Dependency Ninja gets sword
            target  = "target";

            //Assert
            Assert.IsInstanceOfType(warrior, typeof(Warrior));
            Assert.IsInstanceOfType(warrior, typeof(Ninja));
            Assert.IsInstanceOfType(warrior.Weapon, typeof(Sword));
            Assert.AreEqual($"{warrior.ToString()} uses {warrior.Weapon.Name} on {target}.", warrior.Attack(target));
        }