Ejemplo n.º 1
0
Archivo: Rule.cs Proyecto: rzmoz/To1337
 public override int GetHashCode()
 {
     unchecked
     {
         return(((Translationz != null ? Translationz.GetHashCode() : 0) * 397) ^ (Trigger != null ? Trigger.GetHashCode() : 0));
     }
 }
Ejemplo n.º 2
0
Archivo: Rule.cs Proyecto: rzmoz/To1337
        /// <summary>
        /// Gets the translation.
        /// </summary>
        /// <param name="l337ness">The l337ness.</param>
        /// <returns></returns>
        private Translation GetTranslation(L337ness l337ness)
        {
            //if no translations are found, no translation is made
            if (Translationz.Any() == false)
            {
                return(new Translation());
            }

            //find translations where 1337nes is within boundaries
            var resolvedTranslationz = Translationz.Where(t => t.L337ness <= l337ness).ToList();

            //if no translations where 1337nes is within boundaries is found, no translation is made
            if (resolvedTranslationz.Any() == false)
            {
                return(new Translation());
            }

            //calculate randomize sum
            var weigthSum = resolvedTranslationz.Sum(t => t.Weight);

            return(RandomizeTranslationByWeight(resolvedTranslationz, 0, weigthSum, _rand.Next(weigthSum)));
        }