Beispiel #1
0
        /// <summary>
        /// Renders HTML for the info card popups
        /// </summary>
        /// <param name="viewer">entity initiating the command</param>
        /// <returns>the output HTML</returns>
        public virtual string RenderToInfo(IEntity viewer)
        {
            if (viewer == null)
            {
                return(string.Empty);
            }

            ITemplate     dt   = Template <ITemplate>();
            StringBuilder sb   = new StringBuilder();
            StaffRank     rank = viewer.ImplementsType <IPlayer>() ? viewer.Template <IPlayerTemplate>().GamePermissionsRank : StaffRank.Player;

            sb.Append("<div class='helpItem'>");

            sb.AppendFormat("<h3>{0}</h3>", GetDescribableName(viewer));
            sb.Append("<hr />");
            if (Qualities != null && Qualities.Count > 0)
            {
                sb.Append("<h4>Qualities</h4>");
                sb.AppendFormat("<div>{0}</div>", string.Join(",", Qualities.Select(q => string.Format("({0}:{1})", q.Name, q.Value))));
            }

            sb.Append("</div>");

            return(sb.ToString());
        }
Beispiel #2
0
        public ActionResult Items(string SearchTerm = "")
        {
            try
            {
                IEnumerable <IInanimateTemplate> validEntries = TemplateCache.GetAll <IInanimateTemplate>(true);
                ApplicationUser user     = null;
                string          searcher = SearchTerm.Trim().ToLower();

                if (User.Identity.IsAuthenticated)
                {
                    user = UserManager.FindById(User.Identity.GetUserId());
                    StaffRank userRank = user.GetStaffRank(User);
                }

                ItemsViewModel vModel = new ItemsViewModel(validEntries.Where(item => item.Name.ToLower().Contains(searcher)))
                {
                    AuthedUser = user,
                    SearchTerm = SearchTerm,
                };

                return(View(vModel));
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
            }

            return(View());
        }
Beispiel #3
0
        public string ChangeAccountRole(string accountName, short role)
        {
            RoleManager <IdentityRole> roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(new ApplicationDbContext()));
            List <IdentityRole>        validRoles  = roleManager.Roles.ToList();

            ApplicationUser user     = UserManager.FindById(User.Identity.GetUserId());
            Account         account  = user.GameAccount;
            StaffRank       userRole = user.GetStaffRank(User);

            if (userRole != StaffRank.Admin)
            {
                if (string.IsNullOrWhiteSpace(accountName) || account.GlobalIdentityHandle.Equals(accountName) || role >= (short)user.GetStaffRank(User))
                {
                    return("failure");
                }
            }

            ApplicationUser userToModify = UserManager.FindByName(accountName);

            if (userToModify == null)
            {
                return("failure");
            }

            List <string> rolesToRemove = userToModify.Roles.Select(rol => validRoles.First(vR => vR.Id.Equals(rol.RoleId)).Name).ToList();

            foreach (string currentRole in rolesToRemove)
            {
                UserManager.RemoveFromRole(userToModify.Id, currentRole);
            }

            UserManager.AddToRole(userToModify.Id, ((StaffRank)role).ToString());

            return("success");
        }
Beispiel #4
0
        /// <summary>
        /// Remove this object from the db permenantly
        /// </summary>
        /// <returns>success status</returns>
        public virtual bool Remove(IAccount remover, StaffRank rank)
        {
            DataAccess.FileSystem.TemplateData accessor = new DataAccess.FileSystem.TemplateData();

            try
            {
                //Not allowed to remove stuff you didn't make unless you're an admin, TODO: Make this more nuanced for guilds
                if (rank <= CreatorRank && !remover.Equals(Creator))
                {
                    return(false);
                }

                //Remove from cache first
                TemplateCache.Remove(new TemplateCacheKey(this));

                //Remove it from the file system.
                accessor.ArchiveEntity(this);
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
                return(false);
            }

            return(true);
        }
Beispiel #5
0
        /// <summary>
        /// Update the field data for this object to the db
        /// </summary>
        /// <returns>success status</returns>
        public override bool Save(IAccount editor, StaffRank rank)
        {
            bool result = base.Save(editor, rank);

            EnsureDictionary();
            return(result);
        }
Beispiel #6
0
        public ActionResult Index()
        {
            ApplicationUser user   = null;
            HomeViewModel   vModel = new HomeViewModel();

            try
            {
                IEnumerable <IJournalEntry> validEntries;
                if (User.Identity.IsAuthenticated)
                {
                    user = UserManager.FindById(User.Identity.GetUserId());
                    StaffRank userRank = user.GetStaffRank(User);
                    validEntries = TemplateCache.GetAll <IJournalEntry>().Where(blog => blog.IsPublished() && (blog.Public || blog.MinimumReadLevel <= userRank));
                }
                else
                {
                    validEntries = TemplateCache.GetAll <IJournalEntry>().Where(blog => blog.IsPublished() && blog.Public);
                }

                vModel.AuthedUser       = user;
                vModel.LatestNews       = validEntries.Where(blog => !blog.HasTag("Patch Notes")).OrderByDescending(blog => blog.PublishDate).Take(3);
                vModel.LatestPatchNotes = validEntries.OrderByDescending(blog => blog.PublishDate).FirstOrDefault(blog => blog.HasTag("Patch Notes"));
            }
            catch
            {
                vModel.AuthedUser       = user;
                vModel.LatestNews       = Enumerable.Empty <IJournalEntry>();
                vModel.LatestPatchNotes = null;
            }

            return(View(vModel));
        }
Beispiel #7
0
 internal void ApproveMe(IAccount approver, StaffRank rank, ApprovalState state = ApprovalState.Approved)
 {
     State        = state;
     ApprovedBy   = approver;
     ApprovedOn   = DateTime.Now;
     ApproverRank = rank;
 }
Beispiel #8
0
        /// <summary>
        /// Remove this object from the db permenantly
        /// </summary>
        /// <returns>success status</returns>
        public override bool Remove(IAccount remover, StaffRank rank)
        {
            bool removalState = base.Remove(remover, rank);

            if (removalState)
            {
                IEnumerable <IDictata> synonyms = WordForms.SelectMany(dict =>
                                                                       ConfigDataCache.GetAll <ILexeme>().Where(lex => lex.SuitableForUse && lex.GetForm(dict.WordType) != null &&
                                                                                                                lex.GetForm(dict.WordType).Synonyms.Any(syn => syn.Equals(dict))).Select(lex => lex.GetForm(dict.WordType)));
                IEnumerable <IDictata> antonyms = WordForms.SelectMany(dict =>
                                                                       ConfigDataCache.GetAll <ILexeme>().Where(lex => lex.SuitableForUse && lex.GetForm(dict.WordType) != null &&
                                                                                                                lex.GetForm(dict.WordType).Antonyms.Any(syn => syn.Equals(dict))).Select(lex => lex.GetForm(dict.WordType)));

                foreach (IDictata word in synonyms)
                {
                    HashSet <IDictata> syns = new HashSet <IDictata>(word.Synonyms);
                    syns.RemoveWhere(syn => syn.Equals(this));
                    word.Synonyms = syns;
                }

                foreach (IDictata word in antonyms)
                {
                    HashSet <IDictata> ants = new HashSet <IDictata>(word.Antonyms);
                    ants.RemoveWhere(syn => syn.Equals(this));
                    word.Antonyms = ants;
                }
            }

            return(removalState);
        }
Beispiel #9
0
        /// <summary>
        /// Delete this account
        /// </summary>
        /// <param name="remover">The person removing this account</param>
        /// <param name="removerRank">The remover's staff ranking</param>
        /// <returns>success</returns>
        public bool Delete(IAccount remover, StaffRank removerRank)
        {
            //No one but Admin can delete player accounts
            if (removerRank < StaffRank.Admin)
            {
                return(false);
            }

            Dictionary <string, object> parms = new Dictionary <string, object>();

            string sql = "delete from [Accounts] where GlobalIdentityHandle = @handle";

            parms.Add("handle", GlobalIdentityHandle);

            try
            {
                SqlWrapper.RunNonQuery(sql, CommandType.Text, parms);
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex, LogChannels.SystemWarnings);
                return(false);
            }

            return(true);
        }
Beispiel #10
0
        /// <summary>
        /// Update the field data for this object to the db
        /// </summary>
        /// <returns>success status</returns>
        public virtual bool Save(IAccount editor, StaffRank rank)
        {
            DataAccess.FileSystem.ConfigData accessor = new DataAccess.FileSystem.ConfigData();

            try
            {
                //Not allowed to edit stuff you didn't make unless you're an admin, TODO: Make this more nuanced for guilds
                if (ApprovalType != ContentApprovalType.None && rank < StaffRank.Admin && !editor.Equals(Creator))
                {
                    return(false);
                }

                //Disapprove of things first
                State      = ApprovalState.Pending;
                ApprovedBy = null;
                ApprovedOn = DateTime.MinValue;

                //Figure out automated approvals, always throw reviewonly in there
                if (rank < StaffRank.Admin && ApprovalType != ContentApprovalType.ReviewOnly)
                {
                    switch (ApprovalType)
                    {
                    case ContentApprovalType.None:
                        ApproveMe(editor, rank);
                        break;

                    case ContentApprovalType.Leader:
                        if (rank == StaffRank.Builder)
                        {
                            ApproveMe(editor, rank);
                        }

                        break;
                    }
                }
                else
                {
                    //Staff Admin always get approved
                    ApproveMe(editor, rank);
                }

                if (Creator == null)
                {
                    Creator     = editor;
                    CreatorRank = rank;
                }

                PersistToCache();
                accessor.WriteEntity(this);
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
                return(false);
            }

            return(true);
        }
Beispiel #11
0
 public static void SetRank(string Username, StaffRank Rank)
 {
     if (CurrentDB.UserRanks.ContainsKey(Username))
     {
         CurrentDB.UserRanks.Remove(Username);
     }
     CurrentDB.UserRanks.Add(Username, Rank);
     SaveDb();
 }
Beispiel #12
0
        public override IKeyedData Create(IAccount creator, StaffRank rank)
        {
            //approval will be handled inside the base call
            IKeyedData obj = base.Create(creator, rank);

            ParentLocation.RemapInterior();

            return(obj);
        }
Beispiel #13
0
        /// <summary>
        /// Update the field data for this object to the db
        /// </summary>
        /// <returns>success status</returns>
        public override bool Save(IAccount editor, StaffRank rank)
        {
            bool removalState = base.Remove(editor, rank);

            if (removalState)
            {
                return(base.Save(editor, rank));
            }

            return(false);
        }
Beispiel #14
0
        public ActionResult Index(string[] includedTags, string monthYearPair = "")
        {
            System.Collections.Generic.IEnumerable <IJournalEntry> validEntries    = Enumerable.Empty <IJournalEntry>();
            System.Collections.Generic.IEnumerable <IJournalEntry> filteredEntries = Enumerable.Empty <IJournalEntry>();
            ApplicationUser user = null;

            if (User.Identity.IsAuthenticated)
            {
                user = UserManager.FindById(User.Identity.GetUserId());
                StaffRank userRank = user.GetStaffRank(User);
                validEntries = TemplateCache.GetAll <IJournalEntry>().Where(blog => blog.IsPublished() && (blog.Public || blog.MinimumReadLevel <= userRank));
            }
            else
            {
                validEntries = TemplateCache.GetAll <IJournalEntry>().Where(blog => blog.IsPublished() && blog.Public);
            }

            System.Collections.Generic.IEnumerable <string> allTags = validEntries.SelectMany(blog => blog.Tags).Distinct();
            if (includedTags != null && includedTags.Count() > 0)
            {
                validEntries = validEntries.Where(blog => blog.Tags.Any(tag => includedTags.Contains(tag)));
            }

            if (!string.IsNullOrWhiteSpace(monthYearPair))
            {
                string[] pair  = monthYearPair.Split("|||", StringSplitOptions.RemoveEmptyEntries);
                string   month = pair[0];
                int      year  = -1;

                if (!string.IsNullOrWhiteSpace(month) && int.TryParse(pair[1], out year))
                {
                    filteredEntries = validEntries.Where(blog =>
                                                         month.Equals(blog.PublishDate.ToString("MMMM", CultureInfo.InvariantCulture), StringComparison.InvariantCultureIgnoreCase) &&
                                                         blog.PublishDate.Year.Equals(year));
                }
            }

            if (filteredEntries.Count() == 0)
            {
                filteredEntries = validEntries;
            }

            BlogViewModel vModel = new BlogViewModel(filteredEntries.OrderByDescending(obj => obj.PublishDate))
            {
                AuthedUser     = user,
                MonthYearPairs = validEntries.Select(blog => new Tuple <string, int>(blog.PublishDate.ToString("MMMM", CultureInfo.InvariantCulture), blog.PublishDate.Year)).Distinct(),
                IncludeTags    = includedTags?.Where(tag => tag != "false").ToArray() ?? (new string[0]),
                AllTags        = allTags.ToArray()
            };

            return(View(vModel));
        }
Beispiel #15
0
        /// <summary>
        /// Remove this object from the db permenantly
        /// </summary>
        /// <returns>success status</returns>
        public override bool Remove(IAccount remover, StaffRank rank)
        {
            bool removalState = base.Remove(remover, rank);

            if (removalState)
            {
                IEnumerable <IDictata> synonyms = ConfigDataCache.GetAll <IDictata>().Where(dict => dict.Synonyms.Any(syn => syn.Equals(this)));
                IEnumerable <IDictata> antonyms = ConfigDataCache.GetAll <IDictata>().Where(dict => dict.Antonyms.Any(ant => ant.Equals(this)));

                foreach (IDictata word in synonyms)
                {
                    HashSet <IDictata> syns = new HashSet <IDictata>(word.Synonyms);
                    syns.RemoveWhere(syn => syn.Equals(this));
                    word.Synonyms = syns;
                }

                foreach (IDictata word in antonyms)
                {
                    HashSet <IDictata> ants = new HashSet <IDictata>(word.Antonyms);
                    ants.RemoveWhere(syn => syn.Equals(this));
                    word.Antonyms = ants;
                }

                IEnumerable <IDictataPhrase> synonymPhrases = ConfigDataCache.GetAll <IDictataPhrase>().Where(dict => dict.Synonyms.Any(syn => syn.Equals(this)));
                IEnumerable <IDictataPhrase> antonymPhrases = ConfigDataCache.GetAll <IDictataPhrase>().Where(dict => dict.Antonyms.Any(ant => ant.Equals(this)));

                foreach (IDictataPhrase phrase in synonymPhrases)
                {
                    HashSet <IDictata> syns = new HashSet <IDictata>(phrase.Synonyms);
                    syns.RemoveWhere(syn => syn.Equals(this));
                    phrase.Synonyms = syns;
                    phrase.Save(remover, rank);
                }

                foreach (IDictataPhrase phrase in antonymPhrases)
                {
                    HashSet <IDictata> ants = new HashSet <IDictata>(phrase.Antonyms);
                    ants.RemoveWhere(syn => syn.Equals(this));
                    phrase.Antonyms = ants;
                    phrase.Save(remover, rank);
                }

                IEnumerable <IDictataPhrase> containedPhrases = ConfigDataCache.GetAll <IDictataPhrase>().Where(dict => dict.Words.Any(syn => syn.Equals(this)));

                foreach (IDictataPhrase phrase in containedPhrases)
                {
                    phrase.Remove(remover, rank);
                }
            }

            return(removalState);
        }
Beispiel #16
0
        /// <summary>
        /// Add it to the cache and save it to the file system
        /// </summary>
        /// <returns>the object with Id and other db fields set</returns>
        public virtual IKeyedData Create(IAccount creator, StaffRank rank)
        {
            DataAccess.FileSystem.TemplateData accessor = new DataAccess.FileSystem.TemplateData();

            try
            {
                if (Created != DateTime.MinValue)
                {
                    Save(creator, rank);
                }
                else
                {
                    //reset this guy's Id to the next one in the list
                    GetNextId();
                    Created     = DateTime.Now;
                    Creator     = creator;
                    CreatorRank = rank;

                    //Figure out automated approvals, always throw reviewonly in there
                    if (rank < StaffRank.Admin && ApprovalType != ContentApprovalType.ReviewOnly)
                    {
                        switch (ApprovalType)
                        {
                        case ContentApprovalType.None:
                            ApproveMe(creator, rank);
                            break;

                        case ContentApprovalType.Leader:
                            if (rank == StaffRank.Builder)
                            {
                                ApproveMe(creator, rank);
                            }

                            break;
                        }
                    }

                    PersistToCache();
                    accessor.WriteEntity(this);
                }
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
                return(null);
            }

            return(this);
        }
Beispiel #17
0
        /// <summary>
        /// Change the approval status of this thing
        /// </summary>
        /// <returns>success</returns>
        public bool ChangeApprovalStatus(IAccount approver, StaffRank rank, ApprovalState newState)
        {
            //Can't approve/deny your own stuff
            if (rank < StaffRank.Admin && Creator.Equals(approver))
            {
                return(false);
            }

            DataAccess.FileSystem.ConfigData accessor = new DataAccess.FileSystem.ConfigData();
            ApproveMe(approver, rank, newState);

            PersistToCache();
            accessor.WriteEntity(this);

            return(true);
        }
Beispiel #18
0
        public ActionResult Help(string SearchTerm = "", bool IncludeInGame = true)
        {
            List <IHelp>    validEntries = TemplateCache.GetAll <IHelp>(true).ToList();
            ApplicationUser user         = null;
            string          searcher     = SearchTerm.Trim().ToLower();

            if (User.Identity.IsAuthenticated)
            {
                user = UserManager.FindById(User.Identity.GetUserId());
                StaffRank userRank = user.GetStaffRank(User);
            }

            if (IncludeInGame)
            {
                //All the entities with helps
                IEnumerable <ILookupData> entityHelps = TemplateCache.GetAll <ILookupData>(true).Where(data => !data.ImplementsType <IHelp>());
                validEntries.AddRange(entityHelps.Select(helpful => new Data.Administrative.Help()
                {
                    Name = helpful.Name, HelpText = helpful.HelpText
                }));

                //All the commands
                Assembly           commandsAssembly = Assembly.GetAssembly(typeof(CommandParameterAttribute));
                IEnumerable <Type> validTargetTypes = commandsAssembly.GetTypes().Where(t => !t.IsAbstract && t.ImplementsType <IHelpful>());

                foreach (Type command in validTargetTypes)
                {
                    IHelpful       instance = (IHelpful)Activator.CreateInstance(command);
                    MarkdownString body     = instance.HelpText;
                    string         subject  = command.Name;

                    validEntries.Add(new Data.Administrative.Help()
                    {
                        Name = subject, HelpText = body
                    });
                }
            }

            HelpViewModel vModel = new HelpViewModel(validEntries.Where(help => help.HelpText.ToLower().Contains(searcher) || help.Name.ToLower().Contains(searcher)))
            {
                AuthedUser    = user,
                SearchTerm    = SearchTerm,
                IncludeInGame = IncludeInGame
            };

            return(View(vModel));
        }
Beispiel #19
0
        public override IKeyedData Create(IAccount creator, StaffRank rank)
        {
            //approval will be handled inside the base call
            IKeyedData obj = base.Create(creator, rank);

            if (Origin?.GetType() == typeof(RoomTemplate))
            {
                ((IRoomTemplate)Origin).ParentLocation.RemapInterior();
            }

            if (Destination?.GetType() == typeof(RoomTemplate))
            {
                ((IRoomTemplate)Destination).ParentLocation.RemapInterior();
            }

            return(obj);
        }
Beispiel #20
0
        /// <summary>
        /// Get the staffrank of this account
        /// </summary>
        /// <returns>the staffrank</returns>
        public StaffRank GetStaffRank(IPrincipal identity)
        {
            StaffRank rank = StaffRank.Player;

            if (identity.IsInRole("Admin"))
            {
                rank = StaffRank.Admin;
            }
            else if (identity.IsInRole("Builder"))
            {
                rank = StaffRank.Builder;
            }
            else if (identity.IsInRole("Guest"))
            {
                rank = StaffRank.Guest;
            }

            return(rank);
        }
Beispiel #21
0
        public ActionResult FightingArts(string SearchTerm = "")
        {
            List <IFightingArt> validEntries = TemplateCache.GetAll <IFightingArt>(true).ToList();
            ApplicationUser     user         = null;
            string searcher = SearchTerm.Trim().ToLower();

            if (User.Identity.IsAuthenticated)
            {
                user = UserManager.FindById(User.Identity.GetUserId());
                StaffRank userRank = user.GetStaffRank(User);
            }

            FightingArtsViewModel vModel = new FightingArtsViewModel(validEntries.Where(help => help.Name.ToLower().Contains(searcher)))
            {
                AuthedUser = user,
                SearchTerm = SearchTerm
            };

            return(View(vModel));
        }
Beispiel #22
0
        /// <summary>
        /// Remove this object from the db permenantly
        /// </summary>
        /// <returns>success status</returns>
        public override bool Remove(IAccount remover, StaffRank rank)
        {
            DataAccess.FileSystem.PlayerData accessor = new DataAccess.FileSystem.PlayerData();

            try
            {
                //Remove from cache first
                PlayerDataCache.Remove(new PlayerDataCacheKey(this));

                //Remove it from the file system.
                accessor.ArchiveCharacter(this);
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
                return(false);
            }

            return(true);
        }
Beispiel #23
0
        /// <summary>
        /// Add it to the cache and save it to the file system
        /// </summary>
        /// <returns>the object with Id and other db fields set</returns>
        public override IKeyedData Create(IAccount creator, StaffRank rank)
        {
            DataAccess.FileSystem.PlayerData accessor = new DataAccess.FileSystem.PlayerData();

            try
            {
                //reset this guy's Id to the next one in the list
                GetNextId();
                Created     = DateTime.Now;
                Creator     = creator;
                CreatorRank = rank;

                //Default godsight to all false on creation unless you're making a new administrator
                if (rank == StaffRank.Admin)
                {
                    SuperSenses = new HashSet <MessagingType>()
                    {
                        MessagingType.Audible,
                        MessagingType.Olefactory,
                        MessagingType.Psychic,
                        MessagingType.Tactile,
                        MessagingType.Taste,
                        MessagingType.Visible
                    };
                }

                //No approval stuff necessary here
                ApproveMe(creator, rank);

                PersistToCache();
                accessor.WriteCharacter(this);
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
                return(null);
            }

            return(this);
        }
Beispiel #24
0
        /// <summary>
        /// Update the field data for this object to the db
        /// </summary>
        /// <returns>success status</returns>
        public override bool Save(IAccount editor, StaffRank rank)
        {
            DataAccess.FileSystem.PlayerData accessor = new DataAccess.FileSystem.PlayerData();

            try
            {
                //No approval stuff necessary here
                ApproveMe(editor, rank);

                LastRevised = DateTime.Now;

                PersistToCache();
                accessor.WriteCharacter(this);
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
                return(false);
            }

            return(true);
        }
Beispiel #25
0
 /// <summary>
 /// Add it to the cache and save it to the file system
 /// </summary>
 /// <returns>the object with Id and other db fields set</returns>
 public override IKeyedData Create(IAccount creator, StaffRank rank)
 {
     EnsureDictionary();
     return(base.Create(creator, rank));
 }
Beispiel #26
0
 /// <summary>
 /// Create a new permission attribute
 /// </summary>
 /// <param name="minimumRankAllowed">Minimum staff rank a player must be before they can "see" and use this command</param>
 /// <param name="requiresTargetOwnership">Does the target require the zone be owned/allied to the Actor</param>
 public CommandPermissionAttribute(StaffRank minimumRankAllowed, bool requiresTargetOwnership = false)
 {
     MinimumRank = minimumRankAllowed;
 }
 /// <summary>
 /// Create a new permission attribute
 /// </summary>
 /// <param name="minimumRankAllowed">Minimum staff rank a player must be before they can "see" and use this command</param>
 public CommandPermissionAttribute(StaffRank minimumRankAllowed)
 {
     MinimumRank = minimumRankAllowed;
 }
        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );
            int version = reader.ReadInt();

            switch ( version )
            {
                case 36:
                {
                    m_PeacedUntil = reader.ReadDateTime();

                    goto case 35;
                }
                case 35:
                {
                    m_AnkhNextUse = reader.ReadDateTime();

                    goto case 34;
                }
                case 34:
                {
                    m_AutoStabled = reader.ReadStrongMobileList();

                    m_CustomFlags = (CustomPlayerFlag)reader.ReadEncodedInt();

                    if ( GetCustomFlag( CustomPlayerFlag.VisibilityList ) )
                    {
                        int length = reader.ReadInt();
                        for( int i = 0; i < length; i++ )
                            VisibilityList.Add( reader.ReadMobile() );
                    }

                    if ( GetCustomFlag( CustomPlayerFlag.StaffLevel ) )
                        AccessLevelToggler.m_Mobiles.Add( this, new AccessLevelMod( (AccessLevel)reader.ReadInt() ) );

                    if ( GetCustomFlag( CustomPlayerFlag.StaffRank ) )
                        m_StaffRank = (StaffRank)reader.ReadInt();

                    if ( GetCustomFlag( CustomPlayerFlag.DisplayStaffRank ) )
                        m_StaffTitle = reader.ReadString();

                    goto case 33;
                }
                case 33: // Added by Blady for Sphynx
                {
                    m_FortuneType = reader.ReadEncodedInt();
                    if ( m_FortuneType > 0 )
                    {
                        m_FortunePower = reader.ReadEncodedInt();
                        FortuneExpire = reader.ReadDateTime();
                        if ( FortuneExpire > DateTime.Now )
                        {
                            ApplyFortune( m_FortuneType, m_FortunePower );
                            FortuneGump.Told.Add( this );
                        }
                        else
                            m_FortuneType = m_FortunePower = 0;
                    }

                    goto case 32;
                }
                case 32: //PowerHour added by Blady
                {
                    m_PowerHourStart = reader.ReadDeltaTime();
                    goto case 31;
                }
                //*** Edit by Sunny ***\\
                case 31:
                case 30:
                {
                    m_OSIHouseLoading = reader.ReadBool();
                    goto case 29;
                }
                //*** End edit ***\\

                case 29:
                {
                    int recipeCount = reader.ReadInt();

                    if ( recipeCount > 0 )
                    {
                        m_AcquiredRecipes = new Dictionary<int, bool>();

                        for (int i = 0; i < recipeCount; i++)
                        {
                            int r = reader.ReadInt();
                            if (reader.ReadBool())	//Don't add in recipies which we haven't gotten or have been removed
                                m_AcquiredRecipes.Add(r, true);
                        }
                    }
                    goto case 28;
                }
                case 28:
                {
                    m_LastHonorLoss = reader.ReadDeltaTime();
                    goto case 27;
                }
                case 27:
                {
                    m_ChampionTitles = new ChampionTitleInfo(reader);
                    goto case 26;
                }
                case 26:
                {
                    m_LastValorLoss = reader.ReadDateTime();
                    goto case 25;
                }
                case 25:
                {
                    m_ToTItemsTurnedIn = reader.ReadEncodedInt();
                    m_ToTTotalMonsterFame = reader.ReadInt();
                    goto case 24;
                }
                case 24:
                {
                    m_AllianceMessageHue = reader.ReadEncodedInt();
                    m_GuildMessageHue = reader.ReadEncodedInt();

                    goto case 23;
                }
                case 23:
                {
                    int rank = reader.ReadEncodedInt();
                    int maxRank = Guilds.RankDefinition.Ranks.Length - 1;
                    if (rank > maxRank)
                        rank = maxRank;

                    m_GuildRank = Guilds.RankDefinition.Ranks[rank];
                    m_LastOnline = reader.ReadDateTime();
                    goto case 22;
                }
                case 22:
                {
                    if (version < 31)
                        reader.ReadInt();
                    goto case 21;
                }
                // *** Added for Hunting Contracts ***
                case 21:
                {
                    m_NextHuntContract = reader.ReadDateTime();
                    goto case 20;
                }
                // *** ***
                // *** Added for Honor ***
                case 20:
                {
                    if (version < 29)
                    {
                        double m_HonorGain = reader.ReadDouble();
                        DateTime m_LastHonorLoss = reader.ReadDateTime();
                        DateTime m_LastEmbrace = reader.ReadDateTime();
                    }
                    goto case 19;
                }
                // *** ***
                // *** Added for Valor ***
                case 19:
                {
                    if (version < 29)
                    {
                        double m_ValorGain = reader.ReadDouble();
                        DateTime m_LastValorLoss = reader.ReadDeltaTime();
                    }
                    goto case 18;
                }
                // *** ***
                case 18:
                {
                    m_SolenFriendship = (SolenFriendship) reader.ReadEncodedInt();

                    goto case 17;
                }
                case 17: // changed how DoneQuests is serialized
                case 16:
                {
                    m_Quest = QuestSerializer.DeserializeQuest( reader );

                    if ( m_Quest != null )
                        m_Quest.From = this;

                    int count = reader.ReadEncodedInt();

                    if ( count > 0 )
                    {
                        m_DoneQuests = new List<QuestRestartInfo>();

                        for ( int i = 0; i < count; ++i )
                        {
                            Type questType = QuestSerializer.ReadType( QuestSystem.QuestTypes, reader );
                            DateTime restartTime;

                            if ( version < 17 )
                                restartTime = DateTime.MaxValue;
                            else
                                restartTime = reader.ReadDateTime();

                            m_DoneQuests.Add( new QuestRestartInfo( questType, restartTime ) );
                        }
                    }

                    m_Profession = reader.ReadEncodedInt();
                    goto case 15;
                }
                case 15:
                {
                    m_LastCompassionLoss = reader.ReadDeltaTime();
                    goto case 14;
                }
                case 14:
                {
                    m_CompassionGains = reader.ReadEncodedInt();

                    if ( m_CompassionGains > 0 )
                        m_NextCompassionDay = reader.ReadDeltaTime();

                    goto case 13;
                }
                case 13: // just removed m_PaidInsurance list
                case 12:
                {
                    m_BOBFilter = new Engines.BulkOrders.BOBFilter( reader );
                    goto case 11;
                }
                case 11:
                {
                    if ( version < 13 )
                    {
                        List<Item> paid = reader.ReadStrongItemList();

                        for ( int i = 0; i < paid.Count; ++i )
                            paid[i].PaidInsurance = true;
                    }

                    goto case 10;
                }
                case 10:
                {
                    if ( reader.ReadBool() )
                    {
                        m_HairModID = reader.ReadInt();
                        m_HairModHue = reader.ReadInt();
                        m_BeardModID = reader.ReadInt();
                        m_BeardModHue = reader.ReadInt();

                        // We cannot call SetHairMods( -1, -1 ) here because the items have not yet loaded
            //						Timer.DelayCall( TimeSpan.Zero, new TimerCallback( RevertHair ) );
                    }

                    goto case 9;
                }
                case 9:
                {
                    SavagePaintExpiration = reader.ReadTimeSpan();

                    if ( SavagePaintExpiration > TimeSpan.Zero )
                    {
                        BodyMod = ( Female ? 184 : 183 );
                        HueMod = 0;
                    }

                    goto case 8;
                }
                case 8:
                {
                    m_NpcGuild = (NpcGuild)reader.ReadInt();
                    m_NpcGuildJoinTime = reader.ReadDateTime();
                    m_NpcGuildGameTime = reader.ReadTimeSpan();
                    goto case 7;
                }
                case 7:
                {
                    m_PermaFlags = reader.ReadStrongMobileList();
                    goto case 6;
                }
                case 6:
                {
                    NextTailorBulkOrder = reader.ReadTimeSpan();
                    goto case 5;
                }
                case 5:
                {
                    NextSmithBulkOrder = reader.ReadTimeSpan();
                    goto case 4;
                }
                case 4:
                {
                    m_LastJusticeLoss = reader.ReadDeltaTime();
                    m_JusticeProtectors = reader.ReadStrongMobileList();
                    goto case 3;
                }
                case 3:
                {
                    m_LastSacrificeGain = reader.ReadDeltaTime();
                    m_LastSacrificeLoss = reader.ReadDeltaTime();
                    m_AvailableResurrects = reader.ReadInt();
                    goto case 2;
                }
                case 2:
                {
                    m_Flags = (PlayerFlag)reader.ReadInt();
                    goto case 1;
                }
                case 1:
                {
                    m_LongTermElapse = reader.ReadTimeSpan();
                    m_ShortTermElapse = reader.ReadTimeSpan();
                    m_GameTime = reader.ReadTimeSpan();
                    goto case 0;
                }
                case 0:
                {
                    if( version < 34 )
                        m_AutoStabled = new List<Mobile>();
                    break;
                }
            }

            // Professions weren't verified on 1.0 RC0
            if ( !CharacterCreation.VerifyProfession( m_Profession ) )
                m_Profession = 0;

            if ( m_PermaFlags == null )
                m_PermaFlags = new List<Mobile>();

            if ( m_JusticeProtectors == null )
                m_JusticeProtectors = new List<Mobile>();

            if ( m_BOBFilter == null )
                m_BOBFilter = new Engines.BulkOrders.BOBFilter();

            if( m_GuildRank == null )
                m_GuildRank = Guilds.RankDefinition.Member;	//Default to member if going from older verstion to new version (only time it should be null)

            if( m_LastOnline == DateTime.MinValue && Account != null )
                m_LastOnline = ((Account)Account).LastLogin;

            if( m_ChampionTitles == null )
                m_ChampionTitles = new ChampionTitleInfo();
            if ( AccessLevel > AccessLevel.Player )
                m_IgnoreMobiles = true;

            List<Mobile> list = this.Stabled;

            for ( int i = 0; i < list.Count; ++i )
            {
                BaseCreature bc = list[i] as BaseCreature;

                if ( bc != null )
                    bc.IsStabled = true;
            }

            CheckAtrophies( this );

            if( Hidden )	//Hiding is the only buff where it has an effect that's serialized.
                AddBuff( new BuffInfo( BuffIcon.HidingAndOrStealth, 1075655 ) );
        }
Beispiel #29
0
        public ActionResult AddCharacter(string newName, string newSurName, string newGender, long raceId, StaffRank chosenRole = StaffRank.Player)
        {
            string message = string.Empty;
            var userId = User.Identity.GetUserId();
            var model = new ManageCharactersViewModel
            {
                authedUser = UserManager.FindById(userId)
            };

            var newChar = new Character();
            newChar.Name = newName;
            newChar.SurName = newSurName;
            newChar.Gender = newGender;
            var race = ReferenceWrapper.GetOne<Race>(raceId);

            if (race != null)
                newChar.RaceData = race;

            if (User.IsInRole("Admin"))
                newChar.GamePermissionsRank = chosenRole;
            else
                newChar.GamePermissionsRank = StaffRank.Player;

            message = model.authedUser.GameAccount.AddCharacter(newChar);

            return RedirectToAction("ManageCharacters", new { Message = message });
        }
Beispiel #30
0
        public ActionResult AddCharacter(string newName, string newSurName, string newGender, long raceId, StaffRank chosenRole = StaffRank.Player)
        {
            string message = string.Empty;
            var    userId  = User.Identity.GetUserId();
            var    model   = new ManageCharactersViewModel
            {
                authedUser = UserManager.FindById(userId)
            };

            var newChar = new Character();

            newChar.Name    = newName;
            newChar.SurName = newSurName;
            newChar.Gender  = newGender;
            var race = ReferenceWrapper.GetOne <Race>(raceId);

            if (race != null)
            {
                newChar.RaceData = race;
            }

            if (User.IsInRole("Admin"))
            {
                newChar.GamePermissionsRank = chosenRole;
            }
            else
            {
                newChar.GamePermissionsRank = StaffRank.Player;
            }

            message = model.authedUser.GameAccount.AddCharacter(newChar);

            return(RedirectToAction("ManageCharacters", new { Message = message }));
        }
Beispiel #31
0
 /// <summary>
 /// Update the field data for this object to the db
 /// </summary>
 /// <returns>success status</returns>
 public override bool Save(IAccount editor, StaffRank rank)
 {
     EnsureDictionary();
     return(base.Save(editor, rank));
 }
Beispiel #32
0
 /// <summary>
 /// Create a new permission attribute
 /// </summary>
 /// <param name="minimumRankAllowed">Minimum staff rank a player must be before they can "see" and use this command</param>
 public CommandPermissionAttribute(StaffRank minimumRankAllowed)
 {
     MinimumRank = minimumRankAllowed;
 }
Beispiel #33
0
		public override void Deserialize(GenericReader reader)
		{
			base.Deserialize(reader);

			int version = reader.ReadInt();

			//46+ (This should ALWAYS come just after the version!)
			if (version >= 46)
			{
				DeserializeSnapshot(reader);
			}

			if (LostStabledPetRecorder.Enabled)
			{
				LostStabledPetRecorder.PlayerMobiles.Add(this);
			}

			switch (version)
			{
                case 51:
                    {
                        HalloweenPaintExpirationOrange = reader.ReadTimeSpan();

                        if (HalloweenPaintExpirationOrange > TimeSpan.Zero)
                        {
                            BodyMod = (Female ? 184 : 183);
                            HueMod = 1358;
                        }

                        HalloweenPaintExpirationPurple = reader.ReadTimeSpan();

                        if (HalloweenPaintExpirationPurple > TimeSpan.Zero)
                        {
                            BodyMod = (Female ? 184 : 183);
                            HueMod = 1378;
                        }
                    }
                    goto case 50;
                case 50:
                    {
                        ZombiePaintExperationBooger = reader.ReadTimeSpan();

                        if (ZombiePaintExperationBooger > TimeSpan.Zero)
                        {
                            BodyMod = (Female ? 184 : 183);
                            HueMod = 61;
                        }

                        ZombiePaintExperationVesper = reader.ReadTimeSpan();

                        if (ZombiePaintExperationVesper > TimeSpan.Zero)
                        {
                            BodyMod = (Female ? 184 : 183);
                            HueMod = 1159;
                        }
                    }
                    goto case 49;
                case 49:
                    {
                        BattlePaintExpirationShadow = reader.ReadTimeSpan();

                        if (BattlePaintExpirationShadow > TimeSpan.Zero)
                        {
                            BodyMod = (Female ? 184 : 183);
                            HueMod = 1175;
                        }

                        BattlePaintExpirationRed = reader.ReadTimeSpan();

                        if (BattlePaintExpirationRed > TimeSpan.Zero)
                        {
                            BodyMod = (Female ? 184 : 183);
                            HueMod = 1157;
                        }
                    }
                    goto case 48;
                case 48:
			    {
			        NewbieQuestCompleted = reader.ReadBool();
			    }
                    goto case 47;
				case 47:
					{
						if (reader.ReadBool())
						{
							BodyValue = Race.Body(this);
						}
					}
					goto case 46;
				case 46:
				case 45:
					{
						EventMsgFlag = reader.ReadBool();
						EventPoints = reader.ReadInt();
					}
					goto case 44;
				case 44:
					{
						int titleCount = reader.ReadInt();

						if (titleCount > 0)
						{
							_ValorTitles = new List<string>();

							for (int i = 0; i < titleCount; i++)
							{
								string title = reader.ReadString();
								_ValorTitles.Add(title);
							}
						}
					}
					goto case 43;
				case 43:
					{
						Lastkilled = reader.ReadDateTime();
						goto case 42;
					}
				case 42:
					_ValorRating = reader.ReadInt();
					goto case 41;
				case 41:
					ValorQuests = reader.ReadInt();
					goto case 40;
				case 40:
					ValorTitle = reader.ReadString();
					goto case 39;
				case 39:
					ValorRank = reader.ReadInt();
					goto case 38;
				case 38:
					MurderersKilled = reader.ReadInt();
					goto case 37;
				case 37:
					ValorPoints = reader.ReadInt();
					goto case 36;
				case 36:
					LongTermLastDecayGameTime = reader.ReadTimeSpan();
					goto case 35;
				case 35:
					Companion = reader.ReadBool();
					goto case 34;
				case 34:
					{
						// don't check stat loss decay here, just on login
						GameParticipant = reader.ReadBool();
					}
					goto case 33;
				case 33:
					{
						// don't check stat loss decay here, just on login
						StatEnd = reader.ReadDateTime();
					}
					goto case 32;
				case 32:
					reader.ReadInt(); //m_InStat = reader.ReadInt(); 
					// TODO: Remove
					goto case 31;
				case 31:
					KMUsed = reader.ReadInt();
					goto case 30;
				case 30:
					MurderBounty = reader.ReadInt();
					goto case 29;
				case 29:
					{
						int skillgaincount = reader.ReadEncodedInt();

						for (int i = 0; i < skillgaincount; i++)
						{
							SkillGainMods.Add(new SkillGainMod(this, reader));
						}

						goto case 28;
					}
				case 28:
					PeacedUntil = reader.ReadDateTime();
					goto case 27;
				case 27:
					AnkhNextUse = reader.ReadDateTime();
					goto case 26;
				case 26:
					{
						AutoStabled = reader.ReadStrongMobileList();

						CustomFlags = (CustomPlayerFlag)reader.ReadEncodedInt();

						if (GetCustomFlag(CustomPlayerFlag.VisibilityList))
						{
							int length = reader.ReadInt();

							for (int i = 0; i < length; i++)
							{
								VisibilityList.Add(reader.ReadMobile());
							}
						}

						if (GetCustomFlag(CustomPlayerFlag.StaffLevel))
						{
							AccessLevelToggler.m_Mobiles.Add(this, new AccessLevelMod((AccessLevel)reader.ReadInt()));
						}

						if (GetCustomFlag(CustomPlayerFlag.StaffRank))
						{
							m_StaffRank = (StaffRank)reader.ReadInt();
						}

						if (GetCustomFlag(CustomPlayerFlag.DisplayStaffRank))
						{
							m_StaffTitle = reader.ReadString();
						}
					}
					goto case 25;
				case 25:
					{
						int recipeCount = reader.ReadInt();

						if (recipeCount > 0)
						{
							m_AcquiredRecipes = new Dictionary<int, bool>();

							for (int i = 0; i < recipeCount; i++)
							{
								int r = reader.ReadInt();

								//Don't add in recipies which we haven't gotten or have been removed
								if (reader.ReadBool())
								{
									m_AcquiredRecipes.Add(r, true);
								}
							}
						}
					}
					goto case 24;
				case 24:
					reader.ReadDeltaTime(); //m_LastHonorLoss = reader.ReadDeltaTime();
					// TODO: Remove
					goto case 23;
				case 23:
					ChampionTitles = new ChampionTitleInfo(reader);
					goto case 22;
				case 22:
					reader.ReadDateTime(); //m_LastValorLoss = reader.ReadDateTime();
					// TODO: Remove
					goto case 21;
				case 21:
					{
						ToTItemsTurnedIn = reader.ReadEncodedInt();
						ToTTotalMonsterFame = reader.ReadInt();
					}
					goto case 20;
				case 20:
					{
						AllianceMessageHue = reader.ReadEncodedInt();
						GuildMessageHue = reader.ReadEncodedInt();
					}
					goto case 19;
				case 19:
					{
						int rank = reader.ReadEncodedInt();
						int maxRank = RankDefinition.Ranks.Length - 1;

						if (rank > maxRank)
						{
							rank = maxRank;
						}

						m_GuildRank = RankDefinition.Ranks[rank];
						LastOnline = reader.ReadDateTime();
					}
					goto case 18;
				case 18:
					SolenFriendship = (SolenFriendship)reader.ReadEncodedInt();
					goto case 17;
				case 17: // changed how DoneQuests is serialized
				case 16:
					{
						Quest = QuestSerializer.DeserializeQuest(reader);

						if (Quest != null)
						{
							Quest.From = this;
						}

						int count = reader.ReadEncodedInt();

						DoneQuests = new List<QuestRestartInfo>(count);

						if (count > 0)
						{
							for (int i = 0; i < count; ++i)
							{
								Type questType = QuestSerializer.ReadType(QuestSystem.QuestTypes, reader);
								DateTime restartTime = version < 17 ? DateTime.MaxValue : reader.ReadDateTime();

								DoneQuests.Add(new QuestRestartInfo(questType, restartTime));
							}
						}

						Profession = reader.ReadEncodedInt();
					}
					goto case 15;
				case 15:
					reader.ReadDeltaTime(); //m_LastCompassionLoss = reader.ReadDeltaTime();
					// TODO: Remove
					goto case 14;
				case 14:
					{
						// TODO: Remove
						if (reader.ReadEncodedInt() > 0)
						{
							reader.ReadDeltaTime(); //m_NextCompassionDay = reader.ReadDeltaTime();
						}
					}
					goto case 13;
				case 13: // removed PaidInsurance list
				case 12:
					BOBFilter = new BOBFilter(reader);
					goto case 11;
				case 11:
					{
						if (version < 13)
						{
							List<Item> paid = reader.ReadStrongItemList();

							foreach (Item i in paid)
							{
								i.PaidInsurance = true;
							}
						}
					}
					goto case 10;
				case 10:
					{
						if (reader.ReadBool())
						{
							m_HairModID = reader.ReadInt();
							m_HairModHue = reader.ReadInt();
							m_BeardModID = reader.ReadInt();
							m_BeardModHue = reader.ReadInt();
						}
					}
					goto case 9;
				case 9:
					{
						SavagePaintExpiration = reader.ReadTimeSpan();

						if (SavagePaintExpiration > TimeSpan.Zero)
						{
							BodyMod = (Female ? 184 : 183);
							HueMod = 0;
						}
					}
					goto case 8;
				case 8:
					{
						NpcGuild = (NpcGuild)reader.ReadInt();
						NpcGuildJoinTime = reader.ReadDateTime();
						NpcGuildGameTime = reader.ReadTimeSpan();
					}
					goto case 7;
				case 7:
					m_PermaFlags = reader.ReadStrongMobileList();
					goto case 6;
				case 6:
					NextTailorBulkOrder = reader.ReadTimeSpan();
					goto case 5;
				case 5:
					NextSmithBulkOrder = reader.ReadTimeSpan();
					goto case 4;
				case 4:
				case 3:
				case 2:
					Flags = (PlayerFlag)reader.ReadInt();
					goto case 1;
				case 1:
					{
						m_ShortTermElapse = reader.ReadDateTime();
						m_GameTime = reader.ReadTimeSpan();
					}
					goto case 0;
				case 0:
					break;
			}

			if (RecentlyReported == null)
			{
				RecentlyReported = new List<Mobile>();
			}

			// Professions weren't verified on 1.0 RC0
			if (!CharacterCreation.VerifyProfession(Profession, Expansion))
			{
				Profession = 0;
			}

			if (m_PermaFlags == null)
			{
				m_PermaFlags = new List<Mobile>();
			}

			if (BOBFilter == null)
			{
				BOBFilter = new BOBFilter();
			}

			if (m_GuildRank == null)
			{
				//Default to member if going from older version to new version (only time it should be null)
				m_GuildRank = RankDefinition.Member;
			}

			if (LastOnline == DateTime.MinValue && Account != null)
			{
				LastOnline = ((Account)Account).LastLogin;
			}

			if (ChampionTitles == null)
			{
				ChampionTitles = new ChampionTitleInfo();
			}

			if (AccessLevel > AccessLevel.Player)
			{
				IgnoreMobiles = true;
			}

			List<Mobile> list = Stabled;

			foreach (BaseCreature bc in list.OfType<BaseCreature>())
			{
				bc.IsStabled = true; //Charge date set in BaseCreature
			}

			CheckAtrophies(this);

			if (Hidden) //Hiding is the only buff where it has an effect that's serialized.
			{
				AddBuff(new BuffInfo(BuffIcon.HidingAndOrStealth, 1075655));
			}
		}
Beispiel #34
0
		public static string GetStaffTitle(StaffRank rank)
		{
			return m_StaffTitles[(int)rank];
		}
Beispiel #35
0
 /// <summary>
 /// Can the given rank approve this or not
 /// </summary>
 /// <param name="rank">Approver's rank</param>
 /// <returns>If it can</returns>
 public bool CanIBeApprovedBy(StaffRank rank, IAccount approver)
 {
     return(rank >= CreatorRank || Creator.Equals(approver));
 }