예제 #1
0
파일: Beast.cs 프로젝트: perl-easj/OOProg
        /// <summary>
        /// Returns the amount of points a Beast deals in damage.
        /// This damage could then be received by another character
        /// </summary>
        public int DealDamage()
        {
            int    damage  = _generator.Next(_minDamage, _maxDamage);
            string message = $"Beast ({_name}) dealt {damage} damage!";

            _log.Save(message);
            return(damage);
        }
예제 #2
0
        /// <summary>
        /// Returns the amount of points a Hero deals in damage.
        /// This damage could then be received by another character
        /// </summary>
        public int DealDamage()
        {
            int    damage  = _generator.Next(_minDamage, _maxDamage);
            string message = "Hero dealt " + damage + " damage!";

            _log.Save(message);
            return(damage);
        }
예제 #3
0
        /// <summary>
        /// Returns the amount of points a Beast deals in damage.
        /// This damage could then be received by another character
        /// </summary>
        public int DealDamage()
        {
            int    damage  = _generator.Next(10, 25);
            string message = $"Beast dealt {damage} damage!";

            _log.Save(message);
            return(damage);
        }
예제 #4
0
 /// <summary>
 /// Log data about the character to the battle log,
 /// in case the character is still alive.
 /// </summary>
 public void LogSurvivor()
 {
     if (!Dead)
     {
         BattleLog.Save(Name + " survived with " + _hitPoints + " hit points left");
     }
 }
        public override void ReceiveDamage(int points)
        {
            int percentRoll = NumberGenerator.Next(0, 100);

            if (percentRoll < 50)
            {
                // Reduced damage
                int reducedPoints = points * 60 / 100; // Reduce by 40 %
                _hitPoints = _hitPoints - reducedPoints;
                string message = Name + " receives " + reducedPoints + " damage (REDUCED), and is down to " + _hitPoints + " hit points";
                BattleLog.Save(message);
            }
            else
            {
                // Normal damage
                _hitPoints = _hitPoints - points;
                string message = Name + " receives " + points + " damage, and is down to " + _hitPoints + " hit points";
                BattleLog.Save(message);
            }

            if (Dead)
            {
                BattleLog.Save(Name + " died!");
            }
        }
예제 #6
0
        /// <summary>
        /// Returns the amount of points a Character deals in damage.
        /// This damage could then be received by another character.
        /// Note that there is a chance that the damage is modified.
        /// </summary>
        public int DealDamage()
        {
            int    damage  = RandomNumberGenerator.RandomNumber(_minDamage, _maxDamage);
            string message = $"{Name} dealt {damage} in damage";

            BattleLog.Save(message);
            return(damage);
        }
예제 #7
0
        /// <summary>
        /// Returns the amount of points a Character deals in damage.
        /// This damage could then be received by another character
        /// </summary>
        public virtual int DealDamage()
        {
            int    damage  = NumberGenerator.Next(_minDamage, _maxDamage);
            string message = Name + " dealt " + damage + " damage!";

            BattleLog.Save(message);
            return(damage);
        }
예제 #8
0
        /// <summary>
        /// Returns the amount of points a Character deals in damage.
        /// This damage could then be received by another character.
        /// Note that there is a chance that the damage is modified.
        /// </summary>
        public int DealDamage()
        {
            int damage         = NumberGenerator.Next(_minDamage, _maxDamage);
            int modifiedDamage = DealDamageModify(damage);

            string damageDescription = (damage < modifiedDamage) ? "(INCREASED)" : "";
            string message           = $"{Name} dealt {modifiedDamage} damage {damageDescription}";

            BattleLog.Save(message);
            return(modifiedDamage);
        }
예제 #9
0
        /// <summary>
        /// The Character receives the amount of damage specified in the parameter.
        /// The number of hit points will decrease accordingly
        /// </summary>
        public virtual void ReceiveDamage(int points)
        {
            _hitPoints = _hitPoints - points;
            string message = Name + " receives " + points + " damage, and is down to " + _hitPoints + " hit points";

            BattleLog.Save(message);

            if (Dead)
            {
                BattleLog.Save(Name + " died!");
            }
        }
예제 #10
0
        /// <summary>
        /// The Character receives the amount of damage specified in the parameter.
        /// The number of hit points will decrease accordingly.
        /// Note that there is a chance that the damage is modified.
        /// </summary>
        public void ReceiveDamage(int damage)
        {
            int modifiedDamage = ReceiveDamageModify(damage);

            _hitPoints = _hitPoints - modifiedDamage;

            string damageDescription = (damage > modifiedDamage) ? "(DECREASED)" : "";
            string message           = $"{Name} receives {modifiedDamage} damage {damageDescription}, and is down to {_hitPoints} HP";

            BattleLog.Save(message);
            if (Dead)
            {
                BattleLog.Save(Name + " died!");
            }
        }
예제 #11
0
        public static void DoBattle(CharacterGroup groupA, CharacterGroup groupB)
        {
            while (!groupA.Dead && !groupB.Dead)
            {
                groupB.ReceiveDamage(groupA.DealDamage());

                if (!groupB.Dead)
                {
                    groupA.ReceiveDamage(groupB.DealDamage());
                }
            }

            BattleLog.Save("--------------- BATTLE IS OVER ------------");
            BattleLog.Save((groupA.Dead ? groupB.GroupName : groupA.GroupName) + " won! Status: ");
            groupA.LogSurvivor();
            groupB.LogSurvivor();

            BattleLog.PrintLog();
        }
예제 #12
0
        public override int DealDamage()
        {
            int percentRoll = NumberGenerator.Next(0, 100);
            int damage      = NumberGenerator.Next(_minDamage, _maxDamage);

            if (percentRoll < 40)
            {
                // Increased damage
                damage = damage * 2;
                string message = Name + " dealt " + damage + " damage! (INCREASED)";
                BattleLog.Save(message);
            }
            else
            {
                // Normal damage
                string message = Name + " dealt " + damage + " damage!";
                BattleLog.Save(message);
            }

            return(damage);
        }