Esempio n. 1
0
        public string GetThreadInfo()
        {
            string post = "";

            for (int i = 0; i < m_Posts.Count; i++)
            {
                PostEntry pe = ( PostEntry )m_Posts[i];

                if (pe != null)
                {
                    AuthorStatistics ast;
                    if (ForumCore.PlayerStatistics.ContainsKey(pe.Serial))
                    {
                        ast = ForumCore.GetAuthorStatistics(pe.Serial);
                    }
                    else
                    {
                        ast = new AuthorStatistics(pe.Serial, pe.Author.Name, DateTime.Now, 0);
                        ForumCore.PlayerStatistics.Add(ast.Serial, ast);
                    }

                    post += String.Format("{0}<br>Posts: {1}, Join Date: {2}, {3}<br>----------------------------------------------------------<br><br>{4}<br><br>----------------------------------------------------------<br>{5}<br>----------------------------------------------------------<br>", pe.Author.Name, ast.PostCount, ast.JoinDate.ToShortDateString(), ast.RankTitle, pe.Post, ast.Signature);
                }
            }
            return(post);
        }
Esempio n. 2
0
        public void WritePostList(GenericWriter writer, ArrayList list)
        {
            writer.Write(( int )list.Count);

            for (int i = 0; i < list.Count; i++)
            {
                PostEntry pe = ( PostEntry )list[i];
                pe.Serialize(writer);
            }
        }
Esempio n. 3
0
        public ArrayList ReadPostList(GenericReader reader)
        {
            int       count = reader.ReadInt();
            ArrayList list  = new ArrayList();

            for (int i = 0; i < count; i++)
            {
                PostEntry pe = new PostEntry();
                pe.Deserialize(reader);
                list.Add(pe);
            }

            return(list);
        }
Esempio n. 4
0
        public void AddPost(PostEntry post)
        {
            m_PostersSinceUpdate.Clear();
            m_ViewersSinceUpdate.Clear();

            if (!IsViewer(post.Author))
            {
                m_Viewers.Add(post.Author);
            }
            if (!IsPoster(post.Author))
            {
                m_Posters.Add(post.Author);
            }

            m_ViewersSinceUpdate.Add(post.Author);
            m_PostersSinceUpdate.Add(post.Author);

            m_Posts.Add(post);
        }
Esempio n. 5
0
 public ThreadEntry( string subject, PostEntry post, Mobile pm, DateTime creationTime, int id, ThreadType type )
 {
     m_Subject = subject;
     m_ThreadCreator = pm;
     m_CreationTime = creationTime;
     m_ThreadType = type;
     m_ThreadID = id;
     m_Locked = false;
     m_Viewers = new ArrayList();
     m_Posters = new ArrayList();
     m_ViewersSinceUpdate = new ArrayList();
     m_PostersSinceUpdate = new ArrayList();
     m_Posts = new ArrayList();
     m_Viewers.Add( pm );
     m_Posters.Add( pm );
     m_ViewersSinceUpdate.Add( pm );
     m_PostersSinceUpdate.Add( pm );
     m_Posts.Add( post );
     m_LastPostTime = DateTime.Now;
 }
Esempio n. 6
0
 public ThreadEntry(string subject, PostEntry post, Mobile pm, DateTime creationTime, int id, ThreadType type)
 {
     m_Subject            = subject;
     m_ThreadCreator      = pm;
     m_CreationTime       = creationTime;
     m_ThreadType         = type;
     m_ThreadID           = id;
     m_Locked             = false;
     m_Viewers            = new ArrayList();
     m_Posters            = new ArrayList();
     m_ViewersSinceUpdate = new ArrayList();
     m_PostersSinceUpdate = new ArrayList();
     m_Posts = new ArrayList();
     m_Viewers.Add(pm);
     m_Posters.Add(pm);
     m_ViewersSinceUpdate.Add(pm);
     m_PostersSinceUpdate.Add(pm);
     m_Posts.Add(post);
     m_LastPostTime = DateTime.Now;
 }
Esempio n. 7
0
        public string GetThreadInfo()
        {
            string post = "";

            for (int i = 0; i < m_Posts.Count; i++)
            {
                PostEntry pe = ( PostEntry )m_Posts[i];

                if (pe != null)
                {
                    AuthorStatistics ast;
                    if (ForumCore.PlayerStatistics.ContainsKey(pe.Serial))
                    {
                        ast = ForumCore.GetAuthorStatistics(pe.Serial);
                    }
                    else
                    {
                        ast = new AuthorStatistics(pe.Serial, pe.Author.Name, DateTime.Now, 0);
                        ForumCore.PlayerStatistics.Add(ast.Serial, ast);
                    }

                    if (pe.Author == null)
                    {
                        post += String.Format("<center>{0}</center><br>{1}<br><br>________________________________________________________<br>", "[ Guest ]", pe.Post);
                    }
                    else if (ast.PostCount == 0)
                    {
                        post += String.Format("<center>[ {0} ]</center><br>{1}<br><br>________________________________________________________<br>", pe.Author.Name, pe.Post);
                    }
                    else
                    {
                        post += String.Format("<center>[ {0} - {1} Posts ]</center><br>{2}<br><br>________________________________________________________<br>", pe.Author.Name, ast.PostCount, pe.Post);
                    }
                }
            }
            return(post);
        }
Esempio n. 8
0
        public void Post()
        {
            if (m_NewThread)
            {
                bool staff        = false;
                bool sticky       = false;
                bool announcement = false;

                for (int i = 0; i < m_Switches.Length; i++)
                {
                    if (m_Switches[i] == 4)
                    {
                        staff = true;
                    }
                    if (m_Switches[i] == 5)
                    {
                        sticky = true;
                    }
                    if (m_Switches[i] == 6)
                    {
                        announcement = true;
                    }
                }

                if (sticky && announcement)
                {
                    m_Player.SendMessage("Since you checked both sticky and announcement, this post was changed to sticky by default!");
                    announcement = false;
                }

                ThreadType type;

                if (sticky)
                {
                    type = ThreadType.Sticky;
                }
                else if (announcement)
                {
                    type = ThreadType.Announcement;
                }
                else
                {
                    type = ThreadType.RegularThread;
                }

                string post = GetText();

                PostEntry   pe = new PostEntry(m_Player, m_Player.Serial, post, DateTime.Now);
                ThreadEntry te = new ThreadEntry(m_Topic, pe, m_Player, DateTime.Now, ForumCore.ThreadNumber, type);

                if (staff)
                {
                    te.StaffMessage = true;
                }

                te.LastPostTime = DateTime.Now;

                ForumCore.Threads.Add(te);
                ForumCore.UpdatePlayerStatistics(m_Player);

                ForumCore.Threads.Sort(new DateSort());
                m_Player.CloseGump(typeof(ForumGump));
                m_Player.SendGump(new ForumGump(m_Player, 0));
            }
            else
            {
                string    post = GetText();
                PostEntry pe   = new PostEntry(m_Player, m_Player.Serial, post, DateTime.Now);

                m_ThreadEntry.AddPost(pe);
                m_ThreadEntry.LastPostTime = DateTime.Now;
                ForumCore.UpdatePlayerStatistics(m_Player);

                ForumCore.Threads.Sort(new DateSort());
                m_Player.CloseGump(typeof(ForumGump));
                m_Player.SendGump(new ForumGump(m_Player, 0));
            }
        }
Esempio n. 9
0
        public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
        {
            Mobile m_Player = ( Mobile )sender.Mobile;

            if (m_Player == null)
            {
                return;
            }

            switch (info.ButtonID)
            {
            case 0:
            {
                ForumCore.Threads.Sort(new DateSort());
                m_Player.CloseGump(typeof(ForumGump));
                m_Player.SendGump(new ForumGump(m_Player, 0));
                break;
            }

            case 1:
            {
                if (m_NewThread)
                {
                    TextRelay topic = info.GetTextEntry(2);
                    TextRelay post  = info.GetTextEntry(3);

                    int[] switches = info.Switches;

                    bool staff        = false;
                    bool sticky       = false;
                    bool announcement = false;

                    for (int i = 0; i < switches.Length; i++)
                    {
                        if (switches[i] == 4)
                        {
                            staff = true;
                        }
                        if (switches[i] == 5)
                        {
                            sticky = true;
                        }
                        if (switches[i] == 6)
                        {
                            announcement = true;
                        }
                    }

                    if (sticky && announcement)
                    {
                        m_Player.SendMessage("Since you checked both sticky and announcement, this post was changed to sticky by default!");
                        announcement = false;
                    }

                    if (topic.Text.Length < ForumCore.MinPostCharactersCount)
                    {
                        m_Player.SendMessage("The subject of the post must be more then {0} characters in length.", ForumCore.MinPostCharactersCount.ToString());
                        m_Player.SendGump(this);
                        break;
                    }

                    if (post.Text.Length < ForumCore.MinPostCharactersCount)
                    {
                        m_Player.SendMessage("The content of the post must be more then {0} characters in length.", ForumCore.MinPostCharactersCount.ToString());
                        m_Player.SendGump(this);
                        break;
                    }

                    if (post.Text.Length > ForumCore.MaxPostCharactersCount)
                    {
                        m_Player.SendMessage("The content of the post must be less then {0} characters in length.", ForumCore.MaxPostCharactersCount.ToString());
                        m_Player.SendGump(new PostGump(m_Player, post.Text));
                        break;
                    }

                    ThreadType type;

                    if (sticky)
                    {
                        type = ThreadType.Sticky;
                    }
                    else if (announcement)
                    {
                        type = ThreadType.Announcement;
                    }
                    else
                    {
                        type = ThreadType.RegularThread;
                    }

                    PostEntry   pe = new PostEntry(m_Player, m_Player.Serial, post.Text, DateTime.Now);
                    ThreadEntry te = new ThreadEntry(topic.Text, pe, m_Player, DateTime.Now, ForumCore.ThreadNumber, type);

                    if (staff)
                    {
                        te.StaffMessage = true;
                    }

                    te.LastPostTime = DateTime.Now;

                    ForumCore.Threads.Add(te);
                    ForumCore.UpdatePlayerStatistics(m_Player);

                    ForumCore.Threads.Sort(new DateSort());
                    m_Player.CloseGump(typeof(ForumGump));
                    m_Player.SendGump(new ForumGump(m_Player, 0));
                }
                else
                {
                    TextRelay post = info.GetTextEntry(3);
                    PostEntry pe   = new PostEntry(m_Player, m_Player.Serial, post.Text, DateTime.Now);

                    m_ThreadEntry.AddPost(pe);
                    m_ThreadEntry.LastPostTime = DateTime.Now;
                    ForumCore.UpdatePlayerStatistics(m_Player);

                    ForumCore.Threads.Sort(new DateSort());
                    m_Player.CloseGump(typeof(ForumGump));
                    m_Player.SendGump(new ForumGump(m_Player, 0));
                }

                break;
            }

            case 7:
            {
                if (m_NewThread)
                {
                    TextRelay topic = info.GetTextEntry(2);

                    if (topic.Text.Length < ForumCore.MinPostCharactersCount)
                    {
                        m_Player.SendMessage("The subject of the post must be more then {0} characters in length.", ForumCore.MinPostCharactersCount.ToString());
                        m_Player.SendGump(this);
                        break;
                    }
                    m_Topic    = topic.Text;
                    m_Switches = info.Switches;
                }

                m_Player.Prompt = new LongPostLinesPrompt(this, m_Player);
                break;
            }
            }
        }
Esempio n. 10
0
        public override void OnResponse( Server.Network.NetState sender, RelayInfo info )
        {
            Mobile m_Player = ( Mobile )sender.Mobile;

            if( m_Player == null )
                return;

            switch( info.ButtonID )
            {
                case 0:
                    {
                        ForumCore.Threads.Sort( new DateSort() );
                        m_Player.CloseGump( typeof( ForumGump ) );
                        m_Player.SendGump( new ForumGump( m_Player, 0 ) );
                        break;
                    }
                case 1:
                    {
                        if( m_NewThread )
                        {
                            TextRelay topic = info.GetTextEntry( 2 );
                            TextRelay post = info.GetTextEntry( 3 );

                            int[] switches = info.Switches;

                            bool staff = false;
                            bool sticky = false;
                            bool announcement = false;

                            for( int i = 0; i < switches.Length; i++ )
                            {
                                if( switches[i] == 4)
                                    staff = true;
                                if( switches[i] == 5 )
                                    sticky = true;
                                if( switches[i] == 6 )
                                    announcement = true;                                
                            }

                            if( sticky && announcement )
                            {
                                m_Player.SendMessage( "Since you checked both sticky and announcement, this post was changed to sticky by default!" );
                                announcement = false;                                
                            }

                            if( topic.Text.Length < ForumCore.MinPostCharactersCount )
                            {
                                m_Player.SendMessage( "The subject of the post must be more then {0} characters in length.", ForumCore.MinPostCharactersCount.ToString() );
                                m_Player.SendGump( this );
                                break;
                            }

                            if( post.Text.Length < ForumCore.MinPostCharactersCount )
                            {
                                m_Player.SendMessage( "The content of the post must be more then {0} characters in length.", ForumCore.MinPostCharactersCount.ToString() );
                                m_Player.SendGump( this );
                                break;
                            }

                            if( post.Text.Length > ForumCore.MaxPostCharactersCount )
                            {
                                m_Player.SendMessage( "The content of the post must be less then {0} characters in length.", ForumCore.MaxPostCharactersCount.ToString() );
                                m_Player.SendGump( new PostGump( m_Player, post.Text ) );
                                break;
                            }

                            ThreadType type;

                            if( sticky )
                                type = ThreadType.Sticky;
                            else if( announcement )
                                type = ThreadType.Announcement;
                            else
                                type = ThreadType.RegularThread;

                            PostEntry pe = new PostEntry( m_Player, m_Player.Serial, post.Text, DateTime.Now );
                            ThreadEntry te = new ThreadEntry( topic.Text, pe, m_Player, DateTime.Now, ForumCore.ThreadNumber, type );

                            if( staff )
                                te.StaffMessage = true;

                            te.LastPostTime = DateTime.Now;

                            ForumCore.Threads.Add( te );
                            ForumCore.UpdatePlayerStatistics( m_Player );
                                                        
                            ForumCore.Threads.Sort( new DateSort() );
                            m_Player.CloseGump( typeof( ForumGump ) );
                            m_Player.SendGump( new ForumGump( m_Player, 0 ) );
                        }
                        else
                        {
                            TextRelay post = info.GetTextEntry( 3 );
                            PostEntry pe = new PostEntry( m_Player, m_Player.Serial, post.Text, DateTime.Now );
                            
                            m_ThreadEntry.AddPost( pe );
                            m_ThreadEntry.LastPostTime = DateTime.Now;
                            ForumCore.UpdatePlayerStatistics( m_Player );
  
                            ForumCore.Threads.Sort( new DateSort() );
                            m_Player.CloseGump( typeof( ForumGump ) );
                            m_Player.SendGump( new ForumGump( m_Player, 0 ) );
                        }
                        
                        break;
                    }
                case 7:
                    {
                        if( m_NewThread )
                        {
                            TextRelay topic = info.GetTextEntry( 2 );

                            if( topic.Text.Length < ForumCore.MinPostCharactersCount )
                            {
                                m_Player.SendMessage( "The subject of the post must be more then {0} characters in length.", ForumCore.MinPostCharactersCount.ToString() );
                                m_Player.SendGump( this );
                                break;
                            }                            
                            m_Topic = topic.Text;
                            m_Switches = info.Switches;
                        }

                        m_Player.Prompt = new LongPostLinesPrompt( this, m_Player );                        
                        break;

                    }
            }
        }
Esempio n. 11
0
        public void Post()
        {
            if( m_NewThread )
            {
                bool staff = false;
                bool sticky = false;
                bool announcement = false;

                for( int i = 0; i < m_Switches.Length; i++ )
                {
                    if( m_Switches[i] == 4 )
                        staff = true;
                    if( m_Switches[i] == 5 )
                        sticky = true;
                    if( m_Switches[i] == 6 )
                        announcement = true;
                }

                if( sticky && announcement )
                {
                    m_Player.SendMessage( "Since you checked both sticky and announcement, this post was changed to sticky by default!" );
                    announcement = false;
                }

                ThreadType type;

                if( sticky )
                    type = ThreadType.Sticky;
                else if( announcement )
                    type = ThreadType.Announcement;
                else
                    type = ThreadType.RegularThread;

                string post = GetText();

                PostEntry pe = new PostEntry( m_Player, m_Player.Serial, post, DateTime.Now );
                ThreadEntry te = new ThreadEntry( m_Topic, pe, m_Player, DateTime.Now, ForumCore.ThreadNumber, type );

                if( staff )
                    te.StaffMessage = true;

                te.LastPostTime = DateTime.Now;

                ForumCore.Threads.Add( te );
                ForumCore.UpdatePlayerStatistics( m_Player );

                ForumCore.Threads.Sort( new DateSort() );
                m_Player.CloseGump( typeof( ForumGump ) );
                m_Player.SendGump( new ForumGump( m_Player, 0 ) );
            }
            else
            {
                string post = GetText();
                PostEntry pe = new PostEntry( m_Player, m_Player.Serial, post, DateTime.Now );

                m_ThreadEntry.AddPost( pe );
                m_ThreadEntry.LastPostTime = DateTime.Now;
                ForumCore.UpdatePlayerStatistics( m_Player );

                ForumCore.Threads.Sort( new DateSort() );
                m_Player.CloseGump( typeof( ForumGump ) );
                m_Player.SendGump( new ForumGump( m_Player, 0 ) );
            }
        }
Esempio n. 12
0
        public ArrayList ReadPostList( GenericReader reader )
        {
            int count = reader.ReadInt();
            ArrayList list = new ArrayList();

            for( int i = 0; i < count; i++ )
            {
                PostEntry pe = new PostEntry();
                pe.Deserialize( reader );
                list.Add( pe );
            }

            return list;
        }
Esempio n. 13
0
        public void AddPost( PostEntry post )
        {
            m_PostersSinceUpdate.Clear();
            m_ViewersSinceUpdate.Clear();

            if( !IsViewer( post.Author ) )
                m_Viewers.Add( post.Author );
            if( !IsPoster( post.Author ) )
                m_Posters.Add( post.Author );

            m_ViewersSinceUpdate.Add( post.Author );
            m_PostersSinceUpdate.Add( post.Author );

            m_Posts.Add( post );
        }