Exemple #1
0
        public void TestMatchCharacter(string text, string remainingText)
        {
            var character = new Charact('f');
            var match     = character.Match(text);

            Assert.True(match.Success());
            Assert.Equal(remainingText, match.RemainingText());
        }
Exemple #2
0
        public void TestEmptyOrNullString(string text, string remainingText)
        {
            var character = new Charact('a');
            var match     = character.Match(text);

            Assert.False(match.Success());
            Assert.Equal(remainingText, match.RemainingText());
        }
Exemple #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //used to calculate damage amount
            Dice currentDice = new Dice();

            //create 2 character classes and assign value
            Charact hero    = new Charact();
            Charact monster = new Charact();

            hero.Name    = "Galleon"; hero.Health = 99; hero.DamageMax = 10; hero.Attackbonus = true;
            monster.Name = "Garados"; monster.Health = 80; monster.DamageMax = 10; monster.Attackbonus = false;


            //If a character has attack bonus they get an extra attack in begining
            if (hero.Attackbonus)
            {
                monster.Defend(hero.Attack(currentDice));
            }

            if (monster.Attackbonus)
            {
                hero.Defend(monster.Attack(currentDice));
            }


            //Keep attacking until one of the characters dies
            do
            {
                //Calculate Damage
                hero.Defend(monster.Attack(currentDice));
                resultLabel.Text += String.Format("<p>Monster Attacks, Hero health = {0}</p>", hero.Health);
                monster.Defend(hero.Attack(currentDice));
                resultLabel.Text += String.Format("Hero Attacks, Monster health = {0}", monster.Health);
            } while (monster.Health > 0 && hero.Health > 0);


            //Display results
            heroLabel.Text    = String.Format("{0} health remaining is {1}", hero.Name, hero.Health);
            monsterLabel.Text = String.Format("{0} health remaining is {1}", monster.Name, monster.Health);
        }