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); } }
public int Attack(Dice dice) { dice.Sides = DamageMaximum + 1; return dice.Roll(); }