Example #1
0
        /// <summary>
        /// Returns a role based on the balance shift and remaining players to assign a role for.
        /// </summary>
        private static WerewolfRole GetRole(WerewolfTickGenerator tick)
        {
            if (tick.Shift == 0 && tick.PlayersLeft == 0)
            {
                if (HasNeutralRoles)
                {
                    return(GetNeutralRole(tick));
                }
            }

            /*if (tick.Shift.IsInRange(-2, -1) || tick.Shift.IsInRange(1, 2))
             * {
             *  return GetWeakestRole(tick);
             * }*/

            if (tick.Shift > 0)
            {
                return(GetNegativeRole(tick));
            }
            if (tick.Shift < 0)
            {
                return(GetPostiveRole(tick));
            }

            return(GetAnyRole());
        }
Example #2
0
        /// <summary>
        /// Returns a negative role that follows off of the shift balance.
        /// </summary>
        private static WerewolfRole GetNegativeRole(WerewolfTickGenerator tick)
        {
            List <WerewolfRole> roles = RoleData;
            WerewolfRole        r;

            Generate : r = roles.Where(x => x.PointValue < 0).OrderBy(x => Math.Abs(x.PointValue + tick.Shift)).GetAny();
            return(r);
        }
Example #3
0
        /// <summary>
        /// Generates a collection of roles suitable for the player count.
        /// </summary>
        public static List <WerewolfRole> GenerateRoles(int count, out WerewolfTickGenerator tick)
        {
            tick             = new WerewolfTickGenerator();
            tick.Shift       = 0; // Used to balance roles.
            tick.PlayerCount = count;
            List <WerewolfRole> roles = new List <WerewolfRole>();

            for (int i = 0; i < count; i++)
            {
                tick.PlayersLeft = count - i;
                WerewolfRole role = GetRole(tick); // Make a better system in trying to keep things fair.
                role.Name.Debug();
                roles.Add(role);
                tick.Shift += role.PointValue;
            }

            tick.Werewolves = roles.Where(x => x.Name == "Werewolf").Count();
            tick.Seers      = roles.Where(x => x.Name == "Seer").Count();
            tick.Villagers  = roles.Where(x => x.Name == "Villager").Count();
            tick.Tanners    = roles.Where(x => x.Name == "Tanner").Count();
            return(roles);
        }
Example #4
0
 /// <summary>
 /// Gets the weakest role that least affects the shift balance.
 /// </summary>
 private static WerewolfRole GetWeakestRole(WerewolfTickGenerator tick)
 {
     return(RoleData.OrderBy(x => Math.Abs(x.PointValue)).First());
 }
Example #5
0
 /// <summary>
 /// Gets a neutral role that provides no benefit to any side.
 /// </summary>
 private static WerewolfRole GetNeutralRole(WerewolfTickGenerator tick)
 {
     return(RoleData.Where(x => x.PointValue == 0).GetAny());
 }
Example #6
0
 /// <summary>
 /// Returns a positive role that follows off of the shift balance.
 /// </summary>
 private static WerewolfRole GetPostiveRole(WerewolfTickGenerator tick)
 {
     return(RoleData.Where(x => x.PointValue > 0).OrderBy(x => Math.Abs(x.PointValue - tick.Shift)).GetAny());
 }