Example #1
0
        public Match(params string[] roles)
        {
            Random = new Random();
            Id     = Guid.NewGuid();

            var roleSetup = new RoleSetup(roles);

            Setup = new Setup(roleSetup);

            AllPlayers  = Setup.Roles.Static(this);
            Controllers = AllPlayers.Select(player => player.Controller).ToList();
            Graveyard   = new Graveyard(this);
            Phase       = new PhaseManager(this);
            Executor    = new AbilityExecutor(this);
        }
        public static List <RoleSetup> GetRoleSetup(SPUser user)
        {
            List <RoleSetup> roleSetups = new List <RoleSetup>();

            List <int> groups = user.Groups.Cast <SPGroup>().Select(g => g.ID).ToList();

            groups.Add(user.ID);

            ArchiveCacheCRUD crud = new ArchiveCacheCRUD(user.ParentWeb.Site);

            foreach (int griupOrUserId in groups)
            {
                StatusValuePair <List <RoleSetupDb> > result = crud.GetRoleSetup(griupOrUserId);
                if (!result.HasValue || result.ErrorCode != ErrorCode.NoError)
                {
                    continue;
                }

                IEnumerable <RoleSetup> setups = result.Value.Select(v =>
                {
                    RoleSetup rs = new RoleSetup();

                    if (!string.IsNullOrEmpty(v.Lists))
                    {
                        rs.Lists = v.Lists.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries).ToList();
                    }
                    rs.ListRight     = v.ListsRights;
                    rs.Services      = new SPFieldLookupValueCollection(v.Service);
                    rs.ServicesRight = v.ServiceRights;
                    rs.Legals        = new SPFieldLookupValueCollection(v.Legals);
                    rs.LegalsRight   = v.LegalsRights;
                    return(rs);
                });

                roleSetups.AddRange(setups);
            }

            return(roleSetups);
        }
Example #3
0
 public Setup(RoleSetup roles = null, bool trial = true, bool anonymousVoting = false)
 {
     Trial           = trial;
     AnonymousVoting = anonymousVoting;
     Roles           = roles ?? new RoleSetup();
 }