private void displayStats(Character hero, Character monster) { resultLabel.Text += String.Format("{0}: {1} HP {2}: {3} HP<br/>" + "Max Damage: {4} Max Damage: {5}<br/>" + "Attack Bonus: {6} Attack Bonus: {7}<br/><br/>", hero.Name, hero.Health, monster.Name, monster.Health, hero.DamageMaximum, monster.DamageMaximum, hero.AttackBonus.ToString(), monster.AttackBonus.ToString()); }
protected void Page_Load(object sender, EventArgs e) { Character hero = new Character(); hero.Name = "Daniel"; hero.Health = 100; hero.DamageMaximum = 10; hero.AttackBonus = true; Character monster = new Character(); monster.Name = "Terrible Monster"; monster.Health = 100; monster.DamageMaximum = 5; monster.AttackBonus = true; Dice playerDice = new Dice(); if (hero.AttackBonus == true) { Battle(monster, playerDice); } if (monster.AttackBonus == true) { Battle(hero, playerDice); } while ((hero.Health > 0) && (monster.Health > 0) ) { Battle(hero, playerDice); Battle(monster, playerDice); DisplayResults(monster); DisplayResults(hero); } }
private void displayResults(Character opponent1, Character opponent2) { string winner, loser; if (opponent1.Health <= 0 && opponent2.Health <= 0) { resultLabel.Text += string.Format("{0} and {1} both die!", opponent1.Name, opponent2.Name); } if (opponent1.Health <= 0) { winner = opponent2.Name; loser = opponent1.Name; } else { winner = opponent1.Name; loser = opponent2.Name; } resultLabel.Text += string.Format("{0} defeated {1}!<br/>", winner, loser); }
protected void Page_Load(object sender, EventArgs e) { Character hero = new Character(); hero.Name = "Daniel"; hero.Health = 100; hero.DamageMaximum = 10; hero.AttackBonus = 10; hero.Attack(); //resultLabel.Text = Character monster = new Character(); monster.Name = "Creep"; monster.Health = 100; monster.DamageMaximum = 10; monster.AttackBonus = 10; monster.Attack(); }
protected void Page_Load(object sender, EventArgs e) { Character hero = new Character(); Dice dice = new Dice(); hero.Name = "Hercules"; hero.Health = 100; hero.DamageMaximum = 10; hero.AttackBonus = true; //heroDice.Sides = hero.DamageMaximum; Character monster = new Character(); monster.Name = "Hydra"; monster.Health = 75; monster.DamageMaximum = 15; monster.AttackBonus = false; //monsterDice.Sides = monster.DamageMaximum; string battle = ""; if (hero.AttackBonus && !monster.AttackBonus) { battle += "Bonus Hero Attack! " + performAttack(hero, dice, monster) + "<br/><hr>"; } else if (monster.AttackBonus && !hero.AttackBonus) { battle += "Surprise attack! " + performAttack(monster, dice, hero) + "<br/><hr>"; } while (hero.Health > 0 && monster.Health > 0) { battle += performAttack(monster, dice, hero) + "<br/>"; battle += performAttack(hero, dice, monster) + "<br/>"; battle += "<hr>"; } resultLabel.Text += battle; displayStats(hero, monster); displayResults(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); }
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); }
private void DisplayStats(Character character) { resultLabel.Text += String.Format("Name: {0}, Health: {1}, Damage Maximum: {2}, Attack Bonus: {3}</br>", character.Name, character.Health, character.DamageMaximum, character.AttackBonus); }
public void Battle(Character character,Dice playerDice) { character.Attack(playerDice); character.Defend(playerDice.Roll()); }
private void DisplayResults(Character character) { resultLabel.Text += string.Format("Character Name: {0} Character Health: {1} <br /> ",character.Name, character.Health); }