Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace ChallangeHeroMonsterClassesPart1
- {
- public partial class Default : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- Dice dice1 = new Dice();
- Dice dice2 = new Dice();
- Characters hero = new Characters();
- Characters monster = new Characters();
- hero.Name = "Hero";
- hero.Health = 20;
- hero.AttackBonus = false;
- hero.DamageMaximum = 20;
- monster.Name = "Monster";
- monster.Health = 20;
- monster.AttackBonus = true;
- monster.DamageMaximum = 20;
- monster.Defend(hero.Attack(dice1,hero));
- hero.Defend(monster.Attack(dice2,monster));
- int giverandom1 = dice1.Roll();
- int giverandom2 = dice2.Roll();
- showStats(hero);
- showStats(monster);
- }
- private void showStats(Characters character)
- {
- Label1.Text += string.Format("<p> Name: {0} - Health: {1} - DamageMaximum: {2} - AttackBonus: {3} </p>",
- character.Name, character.Health, character.DamageMaximum, character.AttackBonus);
- }
- }
- class Characters
- {
- //public Random random = new Random();
- public string Name { get; set; }
- public int Health { get; set; }
- public int DamageMaximum { get; set; }
- public bool AttackBonus { get; set; }
- public int myDamage { get; set; }
- public int Attack(Dice damage,Characters charc)
- {
- damage.sides = charc.DamageMaximum;
- return damage.Roll();
- }
- public void Defend(int damage)
- {
- this.Health -= damage;
- }
- }
- class Dice
- {
- public Random random { get; set; }
- public int sides { get; set; }
- public int Roll()
- {
- return random.Next(sides);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement