protected void Page_Load(object sender, EventArgs e)
        {
            Dice dice = new Dice();
            Character hero = new Character();
            hero.Name = "Hero";
            hero.Health = 100;
            hero.DamageMaximum = 30;
            hero.AttackBonus = true;

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

            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));

                DisplayStats(hero);
                DisplayStats(monster);

                DisplayResult(hero, monster);
            }
        }
예제 #2
0
        protected void battleButton_Click(object sender, EventArgs e)
        {
            resetBattlefield();
            Character hero = new Character
            {
                //set properties
                Name          = "Drizzt",
                Health        = 90,
                DamageMaximum = 15,
                AttackBonus   = 2,
                SecondAttack  = true //in this example, Drizzt has two swords so he gets two damage rolls
            };

            Character monster = new Character
            {
                //set properties
                Name          = "Orc King",
                Health        = 100,
                DamageMaximum = 20,
                AttackBonus   = 4, //could be used to set a damage base for a character. If damage is randomized with a lower limit of 0 this could cause problems though.
                SecondAttack  = false
            };

            Dice dice = new Dice();

            //SecondAttack Logic



            while (hero.Health > 0 && monster.Health > 0)
            {
                int heroAttack    = hero.Attack(dice); //creates a damagetotal from the attack.
                int monsterAttack = monster.Attack(dice);

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

                hero.Defend(monsterAttack);
                monster.Defend(heroAttack); //passes the damagetotal to be subtracted from the health total.

                roundStats(heroAttack, monsterAttack, hero, monster);
            }
            displayResults(hero, monster);
            //int heroAttack = hero.Attack(dice); //creates a damagetotal from the attack.
            //monster.Defend(heroAttack); //passes the damagetotal to be subtracted from the health total.

            //int monsterAttack = monster.Attack(dice);
            //hero.Defend(monsterAttack);

            //printResults(heroAttack, monsterAttack, hero.Name, monster.Name, hero.Health, monster.Health);
        }
예제 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Character hero = new Character();

            hero.Name          = "Batman";
            hero.Health        = 50;
            hero.DamageMaximum = 25;
            hero.AttackBonus   = true;


            Character monster = new Character();

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

            Dice dice = new Dice();

            if (hero.AttackBonus)
            {
                int damage = hero.Attack(dice);
                monster.Defend(damage);
                resultLabel.Text += "Bonus Attack:<br />";
                displayStats(hero);
                displayStats(monster);
                resultLabel.Text += "<br />";
            }

            if (monster.AttackBonus)
            {
                int damage = monster.Attack(dice);
                hero.Defend(damage);
                resultLabel.Text += "Bonus Attack:<br />";
                displayStats(hero);
                displayStats(monster);
                resultLabel.Text += "<br />";
            }


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

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

                resultLabel.Text += "New Round<br />";
                displayStats(hero);
                displayStats(monster);
                resultLabel.Text += "<br />";
            }

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

            hero.Name          = "Jedi";
            hero.Health        = 40;
            hero.DamageMaximum = 10;
            hero.AttackBonus   = true;

            Character monster = new Character();

            monster.Name          = "Rancor";
            monster.Health        = 20;
            monster.DamageMaximum = 20;
            monster.AttackBonus   = false;

            Dice die = new Dice();

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

            while (hero.Health > 0 && monster.Health > 0)
            {
                monster.Defend(hero.Attack(die));
                hero.Defend(monster.Attack(die));
                statsOut(hero);
                statsOut(monster);
            }

            displayResult(hero, monster);

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

            //damage = monster.Attack(dice);
            //hero.Defend(damage);
            ///int monsterDamage = monster.Attack();

            //statsLabel.Text = String.Format("{0} - {1} - {2} - {3}", hero.Name, hero.Health, hero.DamageMaximum, hero.AttackBonus);
            //monsterStatsLabel.Text = String.Format("{0} - {1} - {2} - {3}", monster.Name, monster.Health, monster.DamageMaximum, monster.AttackBonus);
            //statsOut(hero);
            //statsOut(monster);
        }
예제 #5
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);
        }
        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;


            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);

            /*int damage = hero.Attack(dice);
             * monster.Defend(damage);
             *
             * damage = monster.Attack(dice);
             * hero.Defend(damage);*/
        }
예제 #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Character hero = new Character();

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

            Character monster = new Character();

            monster.Name          = "Cheetah";
            monster.Health        = 75;
            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);
            }
            int damage = hero.Attack(dice);

            monster.Defend(damage);

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

            displayResults(hero, monster);
        }
예제 #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Character hero = new Character();

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

            Character monster = new Character();

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

            Dice dice = new Dice();

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

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

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

                roundResult(hero);
                roundResult(monster);
            }

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

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

            Character monster = new Character();

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

            Dice number = new Dice();



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

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

                printStats(hero);
                printStats(monster);
            }

            displayResult(hero, monster);
        }
예제 #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Character hero     = new Character();
            Character monster  = new Character();
            Dice      diceRoll = new Dice();

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

            monster.Name          = "Demigorgon the Monster";
            monster.Health        = 40;
            monster.DamageMaximum = 25;
            monster.AttackBonus   = true;

            // Bonus round at the beginning if either opponent gets a free extra round
            if (hero.AttackBonus)
            {
                monster.Defend(hero.Attack(diceRoll));
            }
            if (monster.AttackBonus)
            {
                hero.Defend(monster.Attack(diceRoll));
            }

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

                printStats(hero);
                printStats(monster);
                resultLabel.Text += "<br/>";
            }

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

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

            Character monster = new Character();

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

            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));

                DisplayStats(hero);
                DisplayStats(monster);

                DisplayResult(hero, monster);
            }
        }
예제 #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Random random  = new Random();
            Dice   redDice = new Dice();

            Character hero = new Character();

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

            Character monster = new Character();

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


            while (hero.Health > 0 && monster.Health > 0)
            {
                int monsterAttack = monster.Attack(redDice);
                hero.Defend(monsterAttack);
                if (monster.AttackBonus)
                {
                    hero.Health -= hero.DamageMaximum;
                }

                int heroAttack = hero.Attack(redDice);
                monster.Defend(heroAttack);
                if (hero.AttackBonus)
                {
                    monster.Health -= monster.DamageMaximum;
                }
                if (hero.Health == 0 || monster.Health == 0)
                {
                    break;
                }
            }

            Stats(hero);
            Stats(monster);
            displayResult(hero, monster);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Dice AttackDie = new Dice();
            Dice DefendDie = new Dice();

            AttackDie.Sides = 20;
            DefendDie.Sides = 10;

            Character Hero    = new Character();
            Character Monster = new Character();

            Hero.Name          = "Billy Joe McCallister";
            Hero.Health        = 45;
            Hero.DamageMaximum = 10;
            Hero.AttackBonus   = false;

            Monster.Name          = "Grendel";
            Monster.Health        = 36;
            Monster.DamageMaximum = 10;
            Monster.AttackBonus   = false;


            //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;
            int MonsterAttack;


            while (Hero.Health >= 0 && Monster.Health >= 0)
            {
                MonsterAttack = Monster.Attack(AttackDie);
                Hero.Defend(MonsterAttack, Monster.AttackBonus, DefendDie);
                HeroAttack = Hero.Attack(AttackDie);
                Monster.Defend(HeroAttack, Hero.AttackBonus, DefendDie);
            }
            displayResult(Hero, Monster);
        }
예제 #14
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        = 150;
            monster.DamageMaximum = 20;
            monster.AttackBonus   = true;

            Dice d20 = new Dice();

            d20.Sides = 20;

            Random random     = new Random();
            int    bonusCheck = random.Next();

            if (hero.AttackBonus)
            {
                resultLabel.Text += String.Format("<p>{0} was sneaky and attacked before {1} was ready!<p>", hero.Name, monster.Name);
                monster.Defend(hero.Attack(d20.Roll()));
            }

            if (monster.AttackBonus)
            {
                resultLabel.Text += String.Format("<p>{0} was sneaky and attacked before {1} was ready!<p>", monster.Name, hero.Name);
                hero.Defend(monster.Attack(d20.Roll()));
            }

            resultLabel.Text += "Let the battle begin!<br />";

            int round = 0;

            while (hero.Health > 0 && monster.Health > 0)
            {
                round++;
                printStats(hero);
                printStats(monster);

                resultLabel.Text += "<p>Round " + round.ToString() + ": <p>";

                int damage = hero.Attack(d20.Roll());
                monster.Defend(damage);
                resultLabel.Text += String.Format("<p>{0} attacks, dealing {1} points of damage to {2}<p>",
                                                  hero.Name, damage, monster.Name);

                damage = monster.Attack(d20.Roll());
                hero.Defend(damage);
                resultLabel.Text += String.Format("<p>{0} attacks, dealing {1} points of damage to {2}<p>",
                                                  monster.Name, damage, hero.Name);
            }

            displayResult(hero, monster);

            /*if (hero.Health <= 0 && monster.Health <= 0)
             *  {
             *      resultLabel.Text += String.Format("<p>After a long and protracted battle, {0} slew {1} but then, alas, {0} "
             + " succumbed to her own injuries.<p>", hero.Name, monster.Name);
             +      resultLabel.Text += "<P> Final Stats: <p>";
             +
             +      printStats(hero);
             +      printStats(monster);
             +  }
             +  else if (hero.Health <= 0)
             +  {
             +      resultLabel.Text += String.Format("<p>Pushed beyond the limits of her endurance, {0} stares into the abyss of {1} and goes utterly mad.", hero.Name, monster.Name);
             +      resultLabel.Text += "<P> Final Stats: <p>";
             +
             +      printStats(hero);
             +      printStats(monster);
             +  }
             +  else
             +  {
             +      resultLabel.Text += String.Format("<p>{0} stands triumphant, having defeated {1} unequivacably.", hero.Name, monster.Name);
             +      resultLabel.Text += "<P> Final Stats: <p>";
             +
             +      printStats(hero);
             +      printStats(monster);
             +  } */
        }