PageRenderTime 536ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Source/RuneScape/Content/Interfaces/ClanSetup.cs

#
C# | 218 lines | 177 code | 10 blank | 31 comment | 15 complexity | 7725091defdd106797568e1e37b29c41 MD5 | raw file
Possible License(s): GPL-3.0
  1. /*
  2. Jolt Environment
  3. Copyright (C) 2010 Jolt Environment Team
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. using System;
  16. using System.Collections.Generic;
  17. using System.Linq;
  18. using System.Text;
  19. using RuneScape.Communication.Messages.Outgoing;
  20. using RuneScape.Content.ClanChat;
  21. using RuneScape.Model.Characters;
  22. namespace RuneScape.Content.Interfaces
  23. {
  24. /// <summary>
  25. /// Represents the clan setup interface.
  26. /// </summary>
  27. public class ClanSetup : IInterfaceHandler
  28. {
  29. #region Fields
  30. /// <summary>
  31. /// The id of this interface.
  32. /// </summary>
  33. public const int InterfaceId = 590;
  34. #endregion Fields
  35. #region Methods
  36. /// <summary>
  37. /// Handles the clan setup buttons.
  38. /// </summary>
  39. /// <param name="character">The character to handle for.</param>
  40. /// <param name="packetId">The packet id of the button.</param>
  41. /// <param name="buttonId">The button to handle.</param>
  42. /// <param name="buttonId2">The secondary button to handle.</param>
  43. public void HandleButton(Character character, int packetId, int buttonId, int buttonId2)
  44. {
  45. switch (buttonId)
  46. {
  47. case 22:
  48. if (packetId == 233)
  49. {
  50. character.Session.SendData(new RunScriptPacketComposer(109, "s", new object[] {
  51. "Enter your clan prefix:" }).Serialize());
  52. }
  53. else if (packetId == 22)
  54. {
  55. GameEngine.Content.ClanChat.RemoveRoom(character);
  56. }
  57. break;
  58. case 23:
  59. Room r = GameEngine.Content.ClanChat.Get(character.LongName);
  60. if (r == null)
  61. {
  62. break;
  63. }
  64. switch (packetId)
  65. {
  66. case 223:
  67. r.JoinReq = Rank.Regular;
  68. character.Session.SendData(new StringPacketComposer("Anyone", 590, 23).Serialize());
  69. break;
  70. case 21:
  71. r.JoinReq = Rank.Friend;
  72. character.Session.SendData(new StringPacketComposer("Any Friends", 590, 23).Serialize());
  73. break;
  74. case 169:
  75. r.JoinReq = Rank.Recruit;
  76. character.Session.SendData(new StringPacketComposer("Recruit+", 590, 23).Serialize());
  77. break;
  78. case 214:
  79. r.JoinReq = Rank.Corporal;
  80. character.Session.SendData(new StringPacketComposer("Corporal+", 590, 23).Serialize());
  81. break;
  82. case 173:
  83. r.JoinReq = Rank.Sergeant;
  84. character.Session.SendData(new StringPacketComposer("Sergeant+", 590, 23).Serialize());
  85. break;
  86. case 232:
  87. r.JoinReq = Rank.Lieutenant;
  88. character.Session.SendData(new StringPacketComposer("Lientenant+", 590, 23).Serialize());
  89. break;
  90. case 133:
  91. r.JoinReq = Rank.Captain;
  92. character.Session.SendData(new StringPacketComposer("Captain+", 590, 23).Serialize());
  93. break;
  94. case 102:
  95. r.JoinReq = Rank.General;
  96. character.Session.SendData(new StringPacketComposer("General+", 590, 23).Serialize());
  97. break;
  98. case 226:
  99. r.JoinReq = Rank.Owner;
  100. character.Session.SendData(new StringPacketComposer("Only me", 590, 23).Serialize());
  101. break;
  102. }
  103. break;
  104. case 24:
  105. Room r2 = GameEngine.Content.ClanChat.Get(character.LongName);
  106. if (r2 == null)
  107. {
  108. break;
  109. }
  110. switch (packetId)
  111. {
  112. case 223:
  113. r2.TalkReq = Rank.Regular;
  114. character.Session.SendData(new StringPacketComposer("Anyone", 590, 24).Serialize());
  115. break;
  116. case 21:
  117. r2.TalkReq = Rank.Friend;
  118. character.Session.SendData(new StringPacketComposer("Any Friends", 590, 24).Serialize());
  119. break;
  120. case 169:
  121. r2.TalkReq = Rank.Recruit;
  122. character.Session.SendData(new StringPacketComposer("Recruit+", 590, 24).Serialize());
  123. break;
  124. case 214:
  125. r2.TalkReq = Rank.Corporal;
  126. character.Session.SendData(new StringPacketComposer("Corporal+", 590, 24).Serialize());
  127. break;
  128. case 173:
  129. r2.TalkReq = Rank.Sergeant;
  130. character.Session.SendData(new StringPacketComposer("Sergeant+", 590, 24).Serialize());
  131. break;
  132. case 232:
  133. r2.TalkReq = Rank.Lieutenant;
  134. character.Session.SendData(new StringPacketComposer("Lientenant+", 590, 24).Serialize());
  135. break;
  136. case 133:
  137. r2.TalkReq = Rank.Captain;
  138. character.Session.SendData(new StringPacketComposer("Captain+", 590, 24).Serialize());
  139. break;
  140. case 102:
  141. r2.TalkReq = Rank.General;
  142. character.Session.SendData(new StringPacketComposer("General+", 590, 24).Serialize());
  143. break;
  144. case 226:
  145. r2.TalkReq = Rank.Owner;
  146. character.Session.SendData(new StringPacketComposer("Only me", 590, 24).Serialize());
  147. break;
  148. }
  149. break;
  150. case 25:
  151. Room r3 = GameEngine.Content.ClanChat.Get(character.LongName);
  152. if (r3 == null)
  153. {
  154. break;
  155. }
  156. switch (packetId)
  157. {
  158. case 223:
  159. r3.KickReq = Rank.Regular;
  160. character.Session.SendData(new StringPacketComposer("Anyone", 590, 25).Serialize());
  161. break;
  162. case 21:
  163. r3.KickReq = Rank.Friend;
  164. character.Session.SendData(new StringPacketComposer("Any Friends", 590, 25).Serialize());
  165. break;
  166. case 169:
  167. r3.KickReq = Rank.Recruit;
  168. character.Session.SendData(new StringPacketComposer("Recruit+", 590, 25).Serialize());
  169. break;
  170. case 214:
  171. r3.KickReq = Rank.Corporal;
  172. character.Session.SendData(new StringPacketComposer("Corporal+", 590, 25).Serialize());
  173. break;
  174. case 173:
  175. r3.KickReq = Rank.Sergeant;
  176. character.Session.SendData(new StringPacketComposer("Sergeant+", 590, 25).Serialize());
  177. break;
  178. case 232:
  179. r3.KickReq = Rank.Lieutenant;
  180. character.Session.SendData(new StringPacketComposer("Lientenant+", 590, 25).Serialize());
  181. break;
  182. case 133:
  183. r3.KickReq = Rank.Captain;
  184. character.Session.SendData(new StringPacketComposer("Captain+", 590, 25).Serialize());
  185. break;
  186. case 102:
  187. r3.KickReq = Rank.General;
  188. character.Session.SendData(new StringPacketComposer("General+", 590, 25).Serialize());
  189. break;
  190. case 226:
  191. r3.KickReq = Rank.Owner;
  192. character.Session.SendData(new StringPacketComposer("Only me", 590, 25).Serialize());
  193. break;
  194. }
  195. r3.Refresh();
  196. break;
  197. default:
  198. Program.Logger.WriteDebug("Unhandled clansetup button: " + buttonId);
  199. break;
  200. }
  201. }
  202. #endregion Methods
  203. }
  204. }