GuildData.cs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. public class GuildRank
  2. {
  3. public List<GuildMember> Members = new List<GuildMember>();
  4. public string Name = "";
  5. public int Index = 0;
  6. public GuildRankOptions Options = (GuildRankOptions)0;
  7. public GuildRank() { }
  8. public GuildRank(BinaryReader reader, bool offline = false)
  9. {
  10. Name = reader.ReadString();
  11. Options = (GuildRankOptions)reader.ReadByte();
  12. if (!offline)
  13. {
  14. Index = reader.ReadInt32();
  15. }
  16. int Membercount = reader.ReadInt32();
  17. for (int j = 0; j < Membercount; j++)
  18. {
  19. Members.Add(new GuildMember(reader, offline));
  20. }
  21. }
  22. public void Save(BinaryWriter writer, bool save = false)
  23. {
  24. writer.Write(Name);
  25. writer.Write((byte)Options);
  26. if (!save)
  27. {
  28. writer.Write(Index);
  29. }
  30. writer.Write(Members.Count);
  31. for (int j = 0; j < Members.Count; j++)
  32. {
  33. Members[j].Save(writer);
  34. }
  35. }
  36. }
  37. public class GuildStorageItem
  38. {
  39. public UserItem Item;
  40. public long UserId = 0;
  41. public GuildStorageItem() { }
  42. public GuildStorageItem(BinaryReader reader)
  43. {
  44. Item = new UserItem(reader);
  45. UserId = reader.ReadInt64();
  46. }
  47. public void Save(BinaryWriter writer)
  48. {
  49. Item.Save(writer);
  50. writer.Write(UserId);
  51. }
  52. }
  53. public class GuildMember
  54. {
  55. public string Name = "";
  56. public int Id;
  57. public object Player;
  58. public DateTime LastLogin;
  59. public bool hasvoted;
  60. public bool Online;
  61. public GuildMember() { }
  62. public GuildMember(BinaryReader reader, bool offline = false)
  63. {
  64. Name = reader.ReadString();
  65. Id = reader.ReadInt32();
  66. LastLogin = DateTime.FromBinary(reader.ReadInt64());
  67. hasvoted = reader.ReadBoolean();
  68. Online = reader.ReadBoolean();
  69. Online = offline ? false : Online;
  70. }
  71. public void Save(BinaryWriter writer)
  72. {
  73. writer.Write(Name);
  74. writer.Write(Id);
  75. writer.Write(LastLogin.ToBinary());
  76. writer.Write(hasvoted);
  77. writer.Write(Online);
  78. }
  79. }
  80. public class GuildBuffInfo
  81. {
  82. public int Id;
  83. public int Icon = 0;
  84. public string Name = "";
  85. public byte LevelRequirement;
  86. public byte PointsRequirement = 1;
  87. public int TimeLimit;
  88. public int ActivationCost;
  89. public Stats Stats;
  90. public GuildBuffInfo()
  91. {
  92. Stats = new Stats();
  93. }
  94. public GuildBuffInfo(BinaryReader reader)
  95. {
  96. Id = reader.ReadInt32();
  97. Icon = reader.ReadInt32();
  98. Name = reader.ReadString();
  99. LevelRequirement = reader.ReadByte();
  100. PointsRequirement = reader.ReadByte();
  101. TimeLimit = reader.ReadInt32();
  102. ActivationCost = reader.ReadInt32();
  103. Stats = new Stats(reader);
  104. }
  105. public GuildBuffInfo(InIReader reader, int i)
  106. {
  107. Id = reader.ReadInt32("Buff-" + i.ToString(), "Id", 0);
  108. Icon = reader.ReadInt32("Buff-" + i.ToString(), "Icon", 0);
  109. Name = reader.ReadString("Buff-" + i.ToString(), "Name", "");
  110. LevelRequirement = reader.ReadByte("Buff-" + i.ToString(), "LevelReq", 0);
  111. PointsRequirement = reader.ReadByte("Buff-" + i.ToString(), "PointsReq", 1);
  112. TimeLimit = reader.ReadInt32("Buff-" + i.ToString(), "TimeLimit", 0); ;
  113. ActivationCost = reader.ReadInt32("Buff-" + i.ToString(), "ActivationCost", 0);
  114. Stats = new Stats();
  115. Stats[Stat.MaxAC] = reader.ReadByte("Buff-" + i.ToString(), "BuffAc", 0);
  116. Stats[Stat.MaxMAC] = reader.ReadByte("Buff-" + i.ToString(), "BuffMAC", 0);
  117. Stats[Stat.MaxDC] = reader.ReadByte("Buff-" + i.ToString(), "BuffDc", 0);
  118. Stats[Stat.MaxMC] = reader.ReadByte("Buff-" + i.ToString(), "BuffMc", 0);
  119. Stats[Stat.MaxSC] = reader.ReadByte("Buff-" + i.ToString(), "BuffSc", 0);
  120. Stats[Stat.HP] = reader.ReadInt32("Buff-" + i.ToString(), "BuffMaxHp", 0);
  121. Stats[Stat.MP] = reader.ReadInt32("Buff-" + i.ToString(), "BuffMaxMp", 0);
  122. Stats[Stat.MineRatePercent] = reader.ReadByte("Buff-" + i.ToString(), "BuffMineRate", 0);
  123. Stats[Stat.GemRatePercent] = reader.ReadByte("Buff-" + i.ToString(), "BuffGemRate", 0);
  124. Stats[Stat.FishRatePercent] = reader.ReadByte("Buff-" + i.ToString(), "BuffFishRate", 0);
  125. Stats[Stat.ExpRatePercent] = reader.ReadByte("Buff-" + i.ToString(), "BuffExpRate", 0);
  126. Stats[Stat.CraftRatePercent] = reader.ReadByte("Buff-" + i.ToString(), "BuffCraftRate", 0);
  127. Stats[Stat.SkillGainMultiplier] = reader.ReadByte("Buff-" + i.ToString(), "BuffSkillRate", 0);
  128. Stats[Stat.HealthRecovery] = reader.ReadByte("Buff-" + i.ToString(), "BuffHpRegen", 0);
  129. Stats[Stat.SpellRecovery] = reader.ReadByte("Buff-" + i.ToString(), "BuffMpRegen", 0);
  130. Stats[Stat.AttackBonus] = reader.ReadByte("Buff-" + i.ToString(), "BuffAttack", 0);
  131. Stats[Stat.ItemDropRatePercent] = reader.ReadByte("Buff-" + i.ToString(), "BuffDropRate", 0);
  132. Stats[Stat.GoldDropRatePercent] = reader.ReadByte("Buff-" + i.ToString(), "BuffGoldRate", 0);
  133. }
  134. public void Save(InIReader reader, int i)
  135. {
  136. reader.Write("Buff-" + i.ToString(), "Id", Id);
  137. reader.Write("Buff-" + i.ToString(), "Icon", Icon);
  138. reader.Write("Buff-" + i.ToString(), "Name", Name);
  139. reader.Write("Buff-" + i.ToString(), "LevelReq", LevelRequirement);
  140. reader.Write("Buff-" + i.ToString(), "PointsReq", PointsRequirement);
  141. reader.Write("Buff-" + i.ToString(), "TimeLimit", TimeLimit);
  142. reader.Write("Buff-" + i.ToString(), "ActivationCost", ActivationCost);
  143. reader.Write("Buff-" + i.ToString(), "BuffAc", Stats[Stat.MaxAC]);
  144. reader.Write("Buff-" + i.ToString(), "BuffMAC", Stats[Stat.MaxMAC]);
  145. reader.Write("Buff-" + i.ToString(), "BuffDc", Stats[Stat.MaxDC]);
  146. reader.Write("Buff-" + i.ToString(), "BuffMc", Stats[Stat.MaxMC]);
  147. reader.Write("Buff-" + i.ToString(), "BuffSc", Stats[Stat.MaxSC]);
  148. reader.Write("Buff-" + i.ToString(), "BuffMaxHp", Stats[Stat.HP]);
  149. reader.Write("Buff-" + i.ToString(), "BuffMaxMp", Stats[Stat.MP]);
  150. reader.Write("Buff-" + i.ToString(), "BuffMineRate", Stats[Stat.MineRatePercent]);
  151. reader.Write("Buff-" + i.ToString(), "BuffGemRate", Stats[Stat.GemRatePercent]);
  152. reader.Write("Buff-" + i.ToString(), "BuffFishRate", Stats[Stat.FishRatePercent]);
  153. reader.Write("Buff-" + i.ToString(), "BuffExpRate", Stats[Stat.ExpRatePercent]); ;
  154. reader.Write("Buff-" + i.ToString(), "BuffCraftRate", Stats[Stat.CraftRatePercent]);
  155. reader.Write("Buff-" + i.ToString(), "BuffSkillRate", Stats[Stat.SkillGainMultiplier]);
  156. reader.Write("Buff-" + i.ToString(), "BuffHpRegen", Stats[Stat.HealthRecovery]);
  157. reader.Write("Buff-" + i.ToString(), "BuffMpRegen", Stats[Stat.SpellRecovery]);
  158. reader.Write("Buff-" + i.ToString(), "BuffAttack", Stats[Stat.AttackBonus]);
  159. reader.Write("Buff-" + i.ToString(), "BuffDropRate", Stats[Stat.ItemDropRatePercent]);
  160. reader.Write("Buff-" + i.ToString(), "BuffGoldRate", Stats[Stat.GoldDropRatePercent]);
  161. }
  162. public void Save(BinaryWriter writer)
  163. {
  164. writer.Write(Id);
  165. writer.Write(Icon);
  166. writer.Write(Name);
  167. writer.Write(LevelRequirement);
  168. writer.Write(PointsRequirement);
  169. writer.Write(TimeLimit);
  170. writer.Write(ActivationCost);
  171. Stats.Save(writer);
  172. }
  173. public override string ToString()
  174. {
  175. return string.Format("{0}: {1}", Id, Name);
  176. }
  177. public string ShowStats()
  178. {
  179. string text = string.Empty;
  180. foreach (var val in Stats.Values)
  181. {
  182. var c = val.Value < 0 ? "Decreases" : "Increases";
  183. var txt = $"{c} {val.Key} by: {val.Value}{(val.Key.ToString().Contains("Percent") ? "%" : "")}.\n";
  184. text += txt;
  185. }
  186. return text;
  187. }
  188. }
  189. public class GuildBuff
  190. {
  191. public int Id;
  192. public GuildBuffInfo Info;
  193. public bool Active = false;
  194. public int ActiveTimeRemaining;
  195. public bool UsingGuildSkillIcon
  196. {
  197. get { return Info != null && Info.Icon < 1000; }
  198. }
  199. public GuildBuff() { }
  200. public GuildBuff(BinaryReader reader)
  201. {
  202. Id = reader.ReadInt32();
  203. Active = reader.ReadBoolean();
  204. ActiveTimeRemaining = reader.ReadInt32();
  205. }
  206. public void Save(BinaryWriter writer)
  207. {
  208. writer.Write(Id);
  209. writer.Write(Active);
  210. writer.Write(ActiveTimeRemaining);
  211. }
  212. }
  213. //outdated but cant delete it or old db's wont load
  214. public class GuildBuffOld
  215. {
  216. public GuildBuffOld() { }
  217. public GuildBuffOld(BinaryReader reader)
  218. {
  219. reader.ReadByte();
  220. reader.ReadInt64();
  221. }
  222. }