public static void UpdatePlayerStatistics(Mobile pm) { AuthorStatistics ast; bool newUser = false; if (ForumCore.PlayerStatistics.ContainsKey(pm.Serial.Value)) { ast = ForumCore.GetAuthorStatistics(pm.Serial.Value); } else { ast = new AuthorStatistics(pm.Serial.Value, pm.Name, DateTime.Now, 0); newUser = true; } ast.PostCount++; if (newUser) { if (!PlayerStatistics.ContainsKey(ast.Serial)) { PlayerStatistics.Add(ast.Serial, ast); } } }
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); }
public override void OnDoubleClick(Mobile from) { base.OnDoubleClick(from); AuthorStatistics ast = ForumCore.GetAuthorStatistics(from.Serial.Value); if (ast.Banned) { from.SendMessage("You have been banned from this forum!"); return; } ForumCore.Threads.Sort(new DateSort()); from.CloseGump(typeof(ForumGump)); from.SendGump(new ForumGump(from, 0)); }
public static void ViewForums_OnCommand(CommandEventArgs e) { Mobile pm = ( Mobile )e.Mobile; AuthorStatistics ast = ForumCore.GetAuthorStatistics(pm.Serial.Value); if (ast.Banned) { pm.SendMessage("You've been banned from the forum!"); return; } m_Threads.Sort(new DateSort()); pm.CloseGump(typeof(ForumGump)); pm.SendGump(new ForumGump(pm, 0)); }
public override void OnResponse(Server.Network.NetState sender, RelayInfo info) { Mobile pm = ( Mobile )sender.Mobile; if (pm == null) { return; } switch (info.ButtonID) { case 2: { TextRelay text = info.GetTextEntry(1); if (text == null || text.Text == "") { pm.CloseGump(typeof(AccountSearch)); pm.SendGump(new AccountSearch()); return; } ArrayList authors = new ArrayList(); if (ForumCore.AuthorExists(out authors, text.Text)) { pm.CloseGump(typeof(AccountListingGump)); pm.SendGump(new AccountListingGump(authors, 0)); } else { pm.SendMessage("Either that player does not exist, or no posts have been made by that player."); } break; } } }
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); }
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)); } }
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; } } }