示例#1
0
        public void Formatting()
        {
            foreach (var yaml in RoleRegistry.LoadYaml())
            {
                var children = yaml.Children;

                Assert.That(children, Contains.Key((YamlNode)"id"));
                Assert.That(children["id"].AsString().Length, Is.Positive);

                Assert.That(children, Contains.Key((YamlNode)"team"));
                var team = children["team"].AsString();
                Assert.That(team.Length, Is.Positive);
                Assert.NotNull(TeamRegistry.Default[team]);

                Assert.That(children, Contains.Key((YamlNode)"categories"));
                var categoryNames = children["categories"];
                Assert.That(categoryNames.AsStringList().Count, Is.Positive);
                foreach (var category in (YamlSequenceNode)categoryNames)
                {
                    Assert.NotNull(CategoryRegistry.Default[category.AsString()]);
                }

                Assert.That(children, Contains.Key((YamlNode)"color"));
                Assert.That(children["color"].AsColor(), Is.Not.EqualTo(Color.Empty));
            }
        }
示例#2
0
 public RoleSetup(
     RoleRegistry roles,
     AbilityRegistry abilities,
     AbilitySetupRegistry abilitySetups,
     IEnumerable <IRoleSelector> selectors)
 {
     Roles         = roles;
     Abilities     = abilities;
     AbilitySetups = abilitySetups;
     Perks         = new PerkRegistry(roles);
     Selectors     = selectors.ToList();
 }
示例#3
0
文件: Team.cs 项目: war-man/Mafia.NET
        public List <IRoleSelector> Selectors(RoleRegistry roles)
        {
            var selectors = new List <IRoleSelector>();

            foreach (var category in CategoryRegistry.Default.Entries())
            {
                var selector = new RoleSelector(roles, category);
                selectors.Add(selector);
            }

            var random = new RoleSelector(roles, this);

            selectors.Add(random);

            return(selectors);
        }
示例#4
0
        public static List <SelectorGroup> Default(RoleRegistry roles)
        {
            var groups = new List <SelectorGroup>();

            var randomSelectors = new List <RoleSelector>();
            var anyRandom       = new RoleSelector(roles);

            randomSelectors.Add(anyRandom);

            var teams = TeamRegistry.Default.Entries();

            foreach (var team in teams)
            {
                var selectors = roles.Team(team)
                                .Where(role => role.Natural)
                                .Select(role => new RoleSelector(role)).ToList();

                var group = new SelectorGroup(team.Id, team.Name, selectors, team.Color);
                groups.Add(group);

                var teamRandom = new RoleSelector(roles, team);
                randomSelectors.Add(teamRandom);
            }

            foreach (var category in CategoryRegistry.Default.Entries())
            {
                var selector = new RoleSelector(roles, category);
                randomSelectors.Add(selector);
            }

            var randomGroup = new SelectorGroup("Random", SelectorKey.Random, randomSelectors,
                                                ColorTranslator.FromHtml("#00CCFF"));

            groups.Add(randomGroup);

            return(groups);
        }
示例#5
0
 public PerkRegistry(RoleRegistry roles)
 {
     Roles = roles;
 }