Ejemplo n.º 1
0
        /// <summary>
        /// Attempt to flee from character
        /// </summary>
        /// <param name="attacker">Character that is attempting to flee</param>
        /// <param name="deffender">Oponent</param>
        /// <returns></returns>
        private static bool AttemptFlee(Characters attacker, Characters deffender)
        {
            float  chance = attacker.Power() / 2 * deffender.Power();
            Random random = new Random();

            return(random.Next(100) < chance * 100);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Attempt to flee from character
        /// </summary>
        /// <param name="attacker">Character from whom the attempt will be performed</param>
        /// <returns></returns>
        public bool AttemptFlee(Characters attacker)
        {
            double chance  = (double)Power() / (2 * attacker.Power());
            Random random  = new Random();
            bool   escaped = random.Next(100) < chance * 100;
            string message;

            if (escaped)
            {
                message = String.Format("{0} managed to escape from {1}.", Name, attacker.Name);
                Console.WriteLine(message, IsPlayer ? Color.CadetBlue : Color.OrangeRed);
            }
            else
            {
                message = String.Format("{0} did not manage to escape from {1}.", Name, attacker.Name);
                Console.WriteLine(message, IsPlayer ? Color.OrangeRed : Color.CadetBlue);
            }

            return(escaped);
        }