Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Character hero = new Character();

            hero.Name          = "Huey";
            hero.Health        = 100;
            hero.DamageMaximum = 10;
            hero.AttackBonus   = false;

            Character monster = new Character();

            monster.Name          = "Donkey Kong";
            monster.Health        = 100;
            monster.DamageMaximum = 10;
            monster.AttackBonus   = true;

            Dice dice = new Dice();

            while (hero.Health > 0 & monster.Health > 0)
            {
                if (hero.AttackBonus)
                {
                    monster.Defend(hero.Attack(dice));
                }
                if (monster.AttackBonus)
                {
                    hero.Defend(monster.Attack(dice));
                }

                monster.Defend(hero.Attack(dice));
                hero.Defend(monster.Attack(dice));

                DisplayStats(hero, monster);
            }
        }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Character hero = new Character();

            hero.Name          = "Hero";
            hero.Health        = 100;
            hero.DamageMaximum = 20;
            hero.AttackBonus   = false;

            infoLabel.Text = String.Format("Greetings, O Formidable {0}! Your starting " +
                                           "health is {1}, your attack bonus is {2}, and the most damage you can " +
                                           "inflict is {3}. Your people are counting on you! Good luck. <br/>",
                                           hero.Name, hero.Health, hero.AttackBonus, hero.DamageMaximum);

            Character monster = new Character();

            monster.Name          = "Monster";
            monster.Health        = 100;
            monster.DamageMaximum = 17;
            monster.AttackBonus   = true;

            infoLabel.Text += String.Format("<br/>Greetings, O despicable {0}! " +
                                            "Your starting health is {1}, your attack bonus is {2}, and your defense " +
                                            "bonus is {3}. I'm sure you have a reason for fighting--Good luck.<br/><br/>  ", monster.Name, monster.Health.ToString(), monster.AttackBonus.ToString(), monster.DamageMaximum.ToString());

            Dice dice  = new Dice();
            int  round = 0;

            // Give bonus attack if either is true.
            int damage = (hero.AttackBonus == true) ? hero.PerformAttack(dice) : monster.PerformAttack(dice);

            if (hero.AttackBonus == true)
            {
                monster.Defend(damage);
            }
            else
            {
                hero.Defend(damage);
            }

            displayRoundHeader(round, hero, monster);

            while (hero.Health > 0 && monster.Health > 0)
            {
                round++;
                // monster attacks first
                damage = monster.PerformAttack(dice);
                hero.Defend(damage);

                // hero attacks second
                damage = hero.PerformAttack(dice);
                monster.Defend(damage);

                displayRoundHeader(round, hero, monster);
            }
            displayResult(monster, hero, round);
        }
Exemple #3
0
        private void monsterAttack(Character monster, Character hero, Dice monsterDice)
        {
            int monsterDamage = monster.Attack(monsterDice);

            hero.Defend(monster.Attack(monsterDice));
            if (monster.AttackBonus == true)
            {
                monsterDamage += monster.Attack(monsterDice);
            }
            hero.Defend(monsterDamage);
        }
Exemple #4
0
        private void heroAttack(Character hero, Character monster, Dice heroDice)
        {
            int heroDamage = hero.Attack(heroDice);

            monster.Defend(hero.Attack(heroDice));
            if (hero.AttackBonus == true)
            {
                heroDamage += hero.Attack(heroDice);
            }
            monster.Defend(heroDamage);
        }
Exemple #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Dice dice = new Dice();


            Character hero = new Character();

            hero.Name          = "Easy Company";
            hero.Health        = 110;
            hero.DamageMaximum = 60;
            hero.AttackBonus   = false;

            Character monster = new Character();

            monster.Name          = "Bad guys";
            monster.Health        = 150;
            monster.DamageMaximum = 45;
            monster.AttackBonus   = true;

            if (hero.AttackBonus)
            {
                monster.Defend(hero.Attack(dice));
            }
            if (monster.AttackBonus)
            {
                hero.Defend(monster.Attack(dice));
            }


            /*
             * int damage = hero.Attack();
             * monster.Defend(damage);
             *
             * damage = monster.Attack();
             * hero.Defend(damage);
             *
             * printStats(hero);
             * printStats(monster); */

            while (hero.Health > 0 && monster.Health > 0)
            {
                monster.Defend(hero.Attack(dice));
                hero.Defend(monster.Attack(dice));

                outcome(hero);
                outcome(monster);
            }

            displayResults(hero, monster);
        }
Exemple #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string action = "";

            Character hero = new Character();

            hero.Name        = "Eleven";
            hero.Health      = 100;
            hero.DamageMax   = 15;
            hero.AttackBonus = 10;
            hero.LabelName   = "elevenLabel";

            Character monster = new Character();

            monster.Name        = "Demogorgon";
            monster.Health      = 666;
            monster.DamageMax   = 35;
            monster.AttackBonus = 0;
            monster.LabelName   = "demogorgonLabel";

            monster.Defend(hero.Attack(), out action);
            writeAction(action);
            hero.Defend(monster.Attack(), out action);
            writeAction(action);

            updateStats(hero, monster);
        }
Exemple #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Character hero = new Character();

            Character monster = new Character();

            if (!IsPostBack)
            {
                hero.Name        = "Jason";
                hero.Health      = 10;
                hero.DamageMax   = 10;
                hero.AttackBonus = true;

                monster.Name        = "Balrog";
                monster.Health      = 10;
                monster.DamageMax   = 1;
                monster.AttackBonus = false;
            }


            while (hero.Health >= 0 && monster.Health >= 0)
            {
                int damage = hero.Attack();
                monster.Defend(damage);

                damage = monster.Attack();
                hero.Defend(damage);

                DisplayStats(hero, monster);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Character hero    = new Character();
            Character monster = new Character();

            hero.Name          = "He-Man";
            hero.Health        = 100;
            hero.DamageMaximum = 50;
            hero.AttackBonus   = true;

            monster.Name          = "Skeletor";
            monster.Health        = 100;
            monster.DamageMaximum = 50;
            monster.AttackBonus   = true;

            int heroAttack = hero.Attack();

            monster.Defend(heroAttack);

            int monsterAttack = monster.Attack();

            hero.Defend(monsterAttack);

            Stats(hero);
            Stats(monster);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Character hero = new Character();

            hero.Name          = "Batman";
            hero.Health        = 100;
            hero.DamageMaximum = 30;
            hero.AttackBonus   = false;

            Character monster = new Character();

            monster.Name          = "Joker";
            monster.Health        = 50;
            monster.DamageMaximum = 25;
            monster.AttackBonus   = true;

            int damage = hero.Attack();

            monster.Defend(damage);

            damage = monster.Attack();
            hero.Defend(damage);

            printstats(hero);
            printstats(monster);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Character Hero    = new Character();
            Character Monster = new Character();

            Hero.Name          = "Huh-Yun-Mi";
            Hero.Health        = 10000;
            Hero.DamageMaximum = 50;
            Hero.AttackBonus   = 50;

            Monster.Name          = "Grendel";
            Monster.Health        = 1000;
            Monster.DamageMaximum = 10;
            Monster.AttackBonus   = 2;

            //Initialize the result labels:
            lblInitial.Text   = "Starting Out Stats: <br/>";
            lblPostRound.Text = "After One Round Each Stats: <br/>";
            CharacterStats(Hero, true);
            CharacterStats(Monster, true);

            //FIGHT!
            //First the hero -- I don't have to save the attack values to make this work, but I might need them later
            int HeroAttack = Hero.Attack();

            Monster.Defend(HeroAttack);
            int MonsterAttack = Monster.Attack();

            Hero.Defend(MonsterAttack);
            CharacterStats(Hero, false);
            CharacterStats(Monster, false);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Character hero    = new Character();
            Character monster = new Character();

            hero.Name          = "Vulcoran";
            hero.Health        = 100;
            hero.DamageMaximum = 25;
            hero.AttackBonus   = true;

            monster.Name          = "Demigorgon";
            monster.Health        = 200;
            monster.DamageMaximum = 15;
            monster.AttackBonus   = false;

            int damage = hero.Attack();

            monster.Defend(damage);

            damage = monster.Attack();
            hero.Defend(damage);

            printStats(hero);
            printStats(monster);
        }
Exemple #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Character hero = new Character();

            hero.Name          = "Hero";
            hero.Health        = 50;
            hero.DamageMaximum = 20;
            hero.AttackBonus   = false;

            Character monster = new Character();

            monster.Name          = "Troll";
            monster.Health        = 35;
            monster.DamageMaximum = 15;
            monster.AttackBonus   = true;

            int damage = hero.Attack();

            monster.Defend(damage);

            damage = monster.Attack();
            hero.Defend(damage);

            roundResult(hero);
            roundResult(monster);
        }
Exemple #13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Character hero = new Character();

            hero.Name          = "Hercules";
            hero.Health        = 100;
            hero.DamageMaximum = 30;
            hero.AttackBonus   = 0;
            Character monster = new Character();

            monster.Name          = "Cyclops";
            monster.Health        = 100;
            monster.DamageMaximum = 20;
            monster.AttackBonus   = 0;

            int finalMonster = monster.Defend(hero.Attack());
            int finalHero    = hero.Defend(monster.Attack());



            resultLabel.Text = String.Format(" {0}: Health {2}, DamageMaximum {4}, AttackBonus {6}" +
                                             "<br/>" + "{1}: Health {3}, DamageMaximum {5}, AttackBonus {7}",
                                             hero.Name, monster.Name, finalHero, finalMonster,
                                             hero.DamageMaximum, monster.DamageMaximum,
                                             hero.AttackBonus, monster.AttackBonus);
        }
Exemple #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Character hero = new Character();

            hero.Name          = "Hero";
            hero.Health        = 35;
            hero.DamageMaximum = 20;
            hero.AttackBonus   = false;

            Character monster = new Character();

            monster.Name          = "Monster";
            monster.Health        = 21;
            monster.DamageMaximum = 25;
            monster.AttackBonus   = true;

            int damage = hero.Attack();

            monster.Defend(damage);

            damage = monster.Attack();
            hero.Defend(damage);


            printStats(hero);
            printStats(monster);
        }
Exemple #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Character hero = new Character();

            hero.Name          = "Hero";
            hero.Health        = 100;
            hero.DamageMaximum = 15;
            hero.AttackBonus   = false;

            Character monster = new Character();

            monster.Name          = "Monster";
            monster.Health        = 100;
            monster.DamageMaximum = 12;
            monster.AttackBonus   = true;

            Dice dice = new Dice();

            //Bonus Attack
            if (hero.AttackBonus == true)
            {
                monster.Defend(hero.Attack(dice));
                resultLabel.Text = "<strong>Hero has an attack bonus!</strong><br>";
            }
            if (monster.AttackBonus == true)
            {
                hero.Defend(hero.Attack(dice));
                resultLabel.Text = "<strong>Monster has an attack bonus!</strong><br>";
            }


            //While loop
            while (hero.Health > 0 && monster.Health > 0)
            {
                monster.Defend(hero.Attack(dice));
                hero.Defend(hero.Attack(dice));

                displayResults(hero);
                displayResults(monster);
            }

            displayResult(monster, hero);
        }
Exemple #16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Character hero = new Character();

            hero.Name          = "Jason";
            hero.Health        = 35;
            hero.DamageMaximum = 20;
            hero.AttackBonus   = false;

            Character monster = new Character();

            monster.Name          = "Monster";
            monster.Health        = 21;
            monster.DamageMaximum = 25;
            monster.AttackBonus   = true;

            Dice dice = new Dice();

            // Bonus
            if (hero.AttackBonus)
            {
                monster.Defend(hero.Attack(dice));
            }


            if (monster.AttackBonus)
            {
                hero.Defend(monster.Attack(dice));
            }

            while (hero.Health > 0 && monster.Health > 0)
            {
                monster.Defend(hero.Attack(dice));
                hero.Defend(monster.Attack(dice));

                printStats(hero);
                printStats(monster);
            }

            displayResult(hero, monster);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Character hero = new Character();

            hero.Name          = "Troll Hunter";
            hero.Health        = 100;
            hero.DamageMaximum = 40;
            hero.AttackBonus   = true;

            Character monster = new Character();

            monster.Name          = "Rattle Bones";
            monster.Health        = 100;
            monster.DamageMaximum = 25;
            monster.AttackBonus   = true;

            Dice dice = new Dice();

            // Bonus
            if (hero.AttackBonus)
            {
                monster.Defend(hero.Attack(dice));
            }
            if (monster.AttackBonus)
            {
                hero.Defend(monster.Attack(dice));
            }

            while (hero.Health > 0 && monster.Health > 0)
            {
                monster.Defend(hero.Attack(dice));
                hero.Defend(monster.Attack(dice));

                battleStats(hero);
                battleStats(monster);
            }

            displayResult(hero, monster);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Character hero = new Character();
            hero.Name = "Hero";
            hero.Health = 100;
            hero.DamageMaximum = 40;
            hero.AttackBonus = true;

            Character monster = new Character();
            monster.Name = "Monster";
            monster.Health = 100;
            monster.DamageMaximum = 25;
            monster.AttackBonus = false;

            monster.Defend(hero.Attack());
            hero.Defend(monster.Attack());

            DisplayStats(hero);
            DisplayStats(monster);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Character hero = new Character();

            hero.Name          = "Hero";
            hero.Health        = 100;
            hero.DamageMaximum = 40;
            hero.AttackBonus   = true;

            Character monster = new Character();

            monster.Name          = "Monster";
            monster.Health        = 100;
            monster.DamageMaximum = 25;
            monster.AttackBonus   = false;

            monster.Defend(hero.Attack());
            hero.Defend(monster.Attack());

            DisplayStats(hero);
            DisplayStats(monster);
        }
Exemple #20
0
        protected void battleButton_Click(object sender, EventArgs e)
        {
            int damage = hero.Attack();

            monster.Defend(damage);
            showBattleExchange(hero, damage, monster);

            damage = monster.Attack();
            hero.Defend(damage);
            showBattleExchange(monster, damage, hero);

            Session["Hero"]    = hero;
            Session["Monster"] = monster;

            printStats(hero, monster);

            if (winConditionCheck(hero, monster))
            {
                //Someone has won
                showWinner(hero, monster);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Character hero = new Character();

            hero.Name          = "Batman";
            hero.Health        = 100;
            hero.DamageMaximum = 75;
            hero.AttackBonus   = false;


            Character monster = new Character();

            monster.Name          = "Joker";
            monster.Health        = 100;
            monster.DamageMaximum = 25;
            monster.AttackBonus   = false;


            int damage = hero.Attack();

            monster.Defend(damage);

            damage = monster.Attack();
            hero.Defend(damage);

            /* monster.Health -= hero.Attack();
             * hero.Health -= monster.Defend(5);
             *
             * hero.Health -= monster.Attack();
             * monster.Health -= hero.Defend(10);
             */


            displayStats(hero);
            resultLabel.Text += "<br />";
            displayStats(monster);
        }
Exemple #22
0
 private string performAttack(Character attacker, Dice dice, Character defender)
 {
     int attack = attacker.Attack(dice);
     defender.Defend(attack);
     return String.Format("{0} attacks {1} and deals {2} damage!", attacker.Name, defender.Name, attack);
 }
 public void Battle(Character character,Dice playerDice)
 {
     character.Attack(playerDice);
     character.Defend(playerDice.Roll());
 }