Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            NewPlayer Hero    = FactoryPlayer.Create();
            NewPlayer Monster = FactoryPlayer.Create();

            NewDice DiceBonusAttack = FactoryDice.Create(10);

            Hero.Name          = "Hero";
            Hero.Health        = 200;
            Hero.DamageMaximum = 20;
            Hero.AttackBonus   = true;

            Monster.Name          = "Monster";
            Monster.Health        = 200;
            Monster.DamageMaximum = 20;
            Monster.AttackBonus   = false;

            NewDice DiceHero    = FactoryDice.Create(Hero);
            NewDice DiceMonster = FactoryDice.Create(Monster);

            int roundCount = 0;

            string result =
                DisplayResult.PlayerStats(Hero) +
                DisplayResult.PlayerStats(Monster);

            while (Hero.Health > 0 && Monster.Health > 0)
            {
                roundCount++;

                int heroDamage    = Roll(DiceHero);
                int monsterDamage = Roll(DiceMonster);

                if (Hero.AttackBonus && Roll(DiceHero) == 5)
                {
                    Monster.Defend(heroDamage);
                    result +=
                        DisplayResult.BonusRound() +
                        DisplayResult.Battle(Hero, Monster, heroDamage, Monster.Health);
                }
                if (Monster.AttackBonus && Roll(DiceMonster) == 1)
                {
                    Hero.Defend(monsterDamage);
                    result +=
                        DisplayResult.BonusRound() +
                        DisplayResult.Battle(Monster, Hero, monsterDamage, Hero.Health);
                }
                Hero.Defend(monsterDamage);
                Monster.Defend(heroDamage);

                result +=
                    DisplayResult.RoundNumber(roundCount) +
                    DisplayResult.Battle(Hero, Monster, heroDamage, Monster.Health) +
                    DisplayResult.Battle(Monster, Hero, monsterDamage, Hero.Health);
            }

            result += DisplayResult.BattleFinished(Hero, Monster);

            resultLabel.Text = result;
        }
Beispiel #2
0
        public static string PlayerStats(NewPlayer _player)
        {
            result = string.Format($"Name: {_player.Name}<br />" +
                                   $"Healht: {_player.Health}<br />" +
                                   $"Max Damage: {_player.DamageMaximum}<br />" +
                                   $"Attack Bonus: {_player.AttackBonus}<br /><br />");

            return(result);
        }
Beispiel #3
0
        public static string Battle(NewPlayer _playerAtacker, NewPlayer _playerDefender, int _damage, int _health)
        {
            if (_health < 0)
            {
                _health = 0;
            }

            result = string.Format($"The {_playerAtacker.Name} deals {_damage} damage to the {_playerDefender.Name}." +
                                   $"&nbsp;{_playerDefender.Name} has {_health} health left.<br /><br />");

            return(result);
        }
Beispiel #4
0
 public static string BattleFinished(NewPlayer _hero, NewPlayer _monster)
 {
     if (_hero.Health > 0)
     {
         result = string.Format($"<hr />The {_hero.Name} defeats the {_monster.Name}.");
     }
     else if (_monster.Health > 0)
     {
         result = string.Format($"<hr />The {_monster.Name} defeats the {_hero.Name}.");
     }
     else
     {
         result = string.Format($"<hr />They're both dead!");
     }
     return(result);
 }
Beispiel #5
0
 public NewDice(NewPlayer _player)
 {
     this.Sides = _player.DamageMaximum;
 }
 public static NewDice Create(NewPlayer _player)
 {
     return(new NewDice(_player));
 }