コード例 #1
0
ファイル: Program.cs プロジェクト: wilsonmw/C-Sharp
        static void Main(string[] args)
        {
            Wizard  wiz1 = new Wizard("Merlin");
            Ninja   nin1 = new Ninja("George");
            Samurai sam1 = new Samurai("Samuel");

            sam1.Attack(nin1);
            sam1.Attack(wiz1);
            nin1.Attack(sam1);
            nin1.Attack(wiz1);
            wiz1.Attack(nin1);
            wiz1.Attack(sam1);

            nin1.steal(wiz1);
            sam1.meditate();
            wiz1.heal();
            wiz1.heal();
            wiz1.fireball(sam1);
            nin1.get_away();
            sam1.death_blow(nin1);
            wiz1.fireball(sam1);
            wiz1.fireball(nin1);
            wiz1.fireball(sam1);
            wiz1.fireball(nin1);
            wiz1.fireball(sam1);
            wiz1.fireball(nin1);
            sam1.death_blow(nin1);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: fearnoevil7/CSharp
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Human Jonathon    = new Human("Jonathon");
            Human AfroSamurai = new Human("Afro");

            Jonathon.Attack(AfroSamurai);
            Console.WriteLine(Jonathon.Name);
            Console.WriteLine(AfroSamurai.Name);
            Console.WriteLine(AfroSamurai.showHealth());
            Wizard  mickyMouse = new Wizard("Micky Mouse");
            Samurai jack       = new Samurai("Samurai Jack");
            Ninja   ryzu       = new Ninja("Ryzu");

            Console.WriteLine(mickyMouse.Attack(jack));
            Console.WriteLine(ryzu.Attack(mickyMouse));
            Console.WriteLine(jack.Attack(mickyMouse));
            Console.WriteLine(ryzu.Attack(jack));
            Console.WriteLine(jack.Meditate());
            Console.WriteLine(mickyMouse.Heal(jack));
            Console.WriteLine(ryzu.Steal(jack));
            Console.WriteLine(jack.health);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: tammilee18/humanCS
        static void Main(string[] args)
        {
            Human   bob   = new Human("Bobby", 3, 3, 3, 100);
            Wizard  tam   = new Wizard("Tammi");
            Ninja   henry = new Ninja("Henry");
            Samurai kim   = new Samurai("Kim");

            tam.Attack(bob);
            tam.Heal(bob);
            henry.Attack(bob);
            henry.Steal(bob);
            kim.Attack(bob);
            kim.Meditate();
            // Ninja kevin = new Ninja("Kevin");
            // Samurai jesus = new Samurai("Jesus");
        }
コード例 #4
0
        static void Main(string[] args)
        {
            Human vlad = new Human("Vlad");
            Human dima = new Human("Dima", 20, 30, 40, 3000);

            Wizard  wiz     = new Wizard("Torlol");
            Ninja   ninja   = new Ninja("Lala");
            Samurai samurai = new Samurai("zebbie");

            samurai.Attack(vlad);
            wiz.Attack(vlad);
            ninja.Attack(vlad);
            wiz.Heal(vlad);
            ninja.Steal(wiz);
            Console.WriteLine(wiz.Strength);
        }
コード例 #5
0
        static void Main(string[] args)
        {
            Wizard  wiz  = new Wizard("Teng");
            Wizard  wiz2 = new Wizard("Kian", 5, 5, 4, 99);
            Ninja   nin1 = new Ninja("Angelo");
            Samurai sam  = new Samurai("Sam");
            Samurai sam2 = new Samurai("Alex", 10);

            System.Console.WriteLine($"Wizard's Name: {wiz.Name} Strength: {wiz.Strength} Intelligence: {wiz.Intelligence} Health: {wiz.Health}");
            System.Console.WriteLine($"Samurai's Name: {sam.Name} Strength: {sam.Strength} Intelligence: {sam.Intelligence} Health: {sam.Health}");
            wiz.Attack(sam);
            System.Console.WriteLine($"Sam's heath: {sam.Health}");
            System.Console.WriteLine($"Ninja's Name: {nin1.Name}");
            nin1.Attack(wiz);
            sam2.Attack(wiz2);
            wiz.Heal(wiz2);
        }
コード例 #6
0
        static void Main(string[] args)
        {
            Human Wizard = new Human("Wizard");
            Human Knight = new Human("Knight");

            Knight.Attack(Wizard);
            Knight.Attack(Wizard);
            Ninja myNinja = new Ninja("Jim");

            Console.WriteLine(myNinja.Dexterity);
            Wizard myWizard = new Wizard("Tim");

            Console.WriteLine(myWizard.Health);
            Console.WriteLine(myWizard.Intelligence);
            Samurai mySamurai = new Samurai("Kim");

            Console.WriteLine(mySamurai.Health);
            myWizard.Attack(myNinja);
            myNinja.Attack(myWizard);
            mySamurai.Attack(myWizard);
            myWizard.Heal(myWizard);
        }
コード例 #7
0
        static void Main(string[] args)
        {
            var     ninjaFactory = new NinjaFactory();
            Samurai brittany     = new Samurai("Brittany");
            Ninja   morgan       = ninjaFactory.CreateNinja("Morgan");
            Ninja   cat          = ninjaFactory.CreateNinja("TacoCat");
            Wizard  gandalf      = new Wizard("Gandalf");

            brittany.Attack(morgan);
            brittany.Attack(morgan);
            brittany.Attack(morgan);
            brittany.Attack(morgan);
            brittany.DeathBlow(morgan);
            cat.Attack(brittany);
            gandalf.FireBall(cat);

            Console.WriteLine(brittany);
            Console.WriteLine(morgan);
            Console.WriteLine(cat);
            Console.WriteLine(gandalf);

            ninjaFactory.HowMany();
        }
コード例 #8
0
        public void Encounter(Human[] allies, Monster[] enemies)
        {
            Random rand = new Random();

            Console.WriteLine("Random encounter! Enemies appeared!");
            int totallength = allies.Length + enemies.Length;

            object[] turns = new object[totallength];
            int      i     = 0;

            foreach (Human ally in allies)
            {
                turns[i] = ally;
                i++;
            }
            foreach (Monster enemy in enemies)
            {
                turns[i] = enemy;
                i++;
            }
            foreach (Monster enemy in enemies)
            {
                Console.WriteLine(enemy.name);
            }
            int turncount = 0;

            while (true)
            {
                Boolean allieswin  = true;
                Boolean enemieswin = true;
                foreach (Monster enemy in enemies)
                {
                    if (enemy.health > 0)
                    {
                        allieswin = false;
                    }
                }
                foreach (Human ally in allies)
                {
                    if (ally.health > 0)
                    {
                        enemieswin = false;
                    }
                }
                if (allieswin == true)
                {
                    Console.WriteLine("You win! Commence victory theme!");
                    break;
                }
                if (enemieswin == true)
                {
                    Console.WriteLine("The allied party has died. Now the sacred crystals will never be collected, and darkness will forever rule throughout the land. Game Over.");
                    break;
                }
                int myturn = turncount % totallength;
                //Console.WriteLine(myturn);
                if (turns[myturn] is Monster)
                {
                    Monster currenemy = turns[myturn] as Monster;
                    if (currenemy.health == 0)
                    {
                        turncount += 1;
                        continue;
                    }
                    Console.WriteLine("{0}'s turn!", currenemy.name);
                    int mytarget = 0;
                    while (true)
                    {
                        mytarget = rand.Next(0, allies.Length);
                        if (allies[mytarget].health > 0)
                        {
                            currenemy.Attack(allies[mytarget]);
                            break;
                        }
                    }
                    turns[myturn] = currenemy;
                }
                else if (turns[myturn] is Human)
                {
                    string  command  = "default";
                    string  target   = "default";
                    Monster mytarget = enemies[0];
                    if (turns[myturn] is Samurai)
                    {
                        Samurai turnplayer = turns[myturn] as Samurai;
                        if (turnplayer.health == 0)
                        {
                            turncount += 1;
                            continue;
                        }
                        while (true)
                        {
                            Boolean found = false;
                            Console.WriteLine("What will {0} do?", turnplayer.name);
                            command = Console.ReadLine();
                            if (command != "attack" && command != "deathblow" && command != "meditate")
                            {
                                Console.WriteLine("Invalid command.");
                                continue;
                            }
                            if (command != "meditate")
                            {
                                Console.WriteLine("Targeting what?");
                                target = Console.ReadLine();
                                foreach (Monster enemy in enemies)
                                {
                                    if (target == enemy.name)
                                    {
                                        mytarget = enemy;
                                        found    = true;
                                        break;
                                    }
                                }
                                if (found == false)
                                {
                                    Console.WriteLine("Invalid target.");
                                    continue;
                                }
                            }
                            if (command == "attack")
                            {
                                turnplayer.Attack(mytarget);
                                if (turnplayer.poisoned > 0)
                                {
                                    turnplayer.health -= 5;
                                    turnplayer.poisoned--;
                                }
                                break;
                            }
                            else if (command == "deathblow")
                            {
                                turnplayer.Death_blow(mytarget);
                                if (turnplayer.poisoned > 0)
                                {
                                    turnplayer.health -= 5;
                                    turnplayer.poisoned--;
                                }
                                break;
                            }
                            else if (command == "meditate")
                            {
                                turnplayer.Meditate();
                                if (turnplayer.poisoned > 0)
                                {
                                    turnplayer.health -= 5;
                                    turnplayer.poisoned--;
                                }
                                break;
                            }
                        }
                    }
                    else if (turns[myturn] is Wizard)
                    {
                        Wizard turnplayer = turns[myturn] as Wizard;
                        if (turnplayer.health == 0)
                        {
                            turncount += 1;
                            continue;
                        }
                        while (true)
                        {
                            Boolean found = false;
                            Console.WriteLine("What will {0} do?", turnplayer.name);
                            command = Console.ReadLine();
                            if (command != "attack" && command != "fireball" && command != "heal")
                            {
                                Console.WriteLine("Invalid command.");
                                continue;
                            }
                            if (command != "heal")
                            {
                                Console.WriteLine("Targeting what?");
                                target = Console.ReadLine();
                                foreach (Monster enemy in enemies)
                                {
                                    if (target == enemy.name)
                                    {
                                        mytarget = enemy;
                                        found    = true;
                                        break;
                                    }
                                }
                                if (found == false)
                                {
                                    Console.WriteLine("Invalid target.");
                                    continue;
                                }
                            }


                            if (command == "attack")
                            {
                                turnplayer.Attack(mytarget);
                                break;
                            }
                            else if (command == "fireball")
                            {
                                turnplayer.Fireball(mytarget);
                                break;
                            }
                            else if (command == "heal")
                            {
                                turnplayer.Heal();
                                break;
                            }
                        }
                    }
                    else if (turns[myturn] is Ninja)
                    {
                        Ninja turnplayer = turns[myturn] as Ninja;
                        if (turnplayer.health == 0)
                        {
                            turncount += 1;
                            continue;
                        }
                        while (true)
                        {
                            Boolean found = false;
                            Console.WriteLine("What will {0} do?", turnplayer.name);
                            command = Console.ReadLine();
                            if (command != "attack" && command != "steal" && command != "getaway")
                            {
                                Console.WriteLine("Invalid command.");
                                continue;
                            }
                            if (command != "getaway")
                            {
                                Console.WriteLine("Targeting what?");
                                target = Console.ReadLine();
                            }
                            foreach (Monster enemy in enemies)
                            {
                                if (target == enemy.name)
                                {
                                    mytarget = enemy;
                                    found    = true;
                                    break;
                                }
                            }
                            if (found == false)
                            {
                                Console.WriteLine("Invalid target.");
                                continue;
                            }
                            if (command == "attack")
                            {
                                turnplayer.Attack(mytarget);
                                break;
                            }
                            else if (command == "steal")
                            {
                                turnplayer.Steal(mytarget);
                                break;
                            }
                            else if (command == "getaway")
                            {
                                turnplayer.Get_away();
                                Console.WriteLine("{} couldn't get away!", turnplayer.name);
                                break;
                            }
                        }
                    }
                    else
                    {
                        Human turnplayer = turns[myturn] as Human;
                        if (turnplayer.health == 0)
                        {
                            turncount += 1;
                            continue;
                        }
                        while (true)
                        {
                            Boolean found = false;
                            Console.WriteLine("What will {0} do?", turnplayer.name);
                            command = Console.ReadLine();
                            if (command != "attack")
                            {
                                Console.WriteLine("Invalid command.");
                                continue;
                            }
                            foreach (Monster enemy in enemies)
                            {
                                if (target == enemy.name)
                                {
                                    mytarget = enemy;
                                    found    = true;
                                    break;
                                }
                            }
                            if (found == false)
                            {
                                Console.WriteLine("Invalid target.");
                                continue;
                            }
                            if (command == "attack")
                            {
                                turnplayer.Attack(mytarget);
                                break;
                            }
                        }
                    }
                }
                turncount += 1;
            }
        }