Advertisement
Guest User

DataHolder

a guest
May 25th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.76 KB | None | 0 0
  1. // ☺ Created by Eslam Reda
  2. // ☺ Copyright © 2010 - 2016 TQ Digital
  3. // ☺ Emulator - Project
  4.  
  5. using System;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Collections.Generic;
  9. using MYSQLCONNECTION = MySql.Data.MySqlClient.MySqlConnection;
  10.  
  11. namespace COServer.Database
  12. {
  13. public unsafe static class DataHolder
  14. {
  15. public static string ConnectionString;
  16. private static string MySqlUsername, MySqlPassword, MySqlDatabase, MySqlHost;
  17. public static void CreateConnection1(string user, string password, string database, string host)
  18. {
  19. MySqlUsername = user;
  20. MySqlHost = host;
  21. MySqlPassword = password;
  22. MySqlDatabase = database;
  23. ConnectionString = "Server=" + MySqlHost + ";Database='" + MySqlDatabase + "';Username='" + MySqlUsername + "';Password='" + MySqlPassword + "';Pooling=true; Max Pool Size = 900000; Min Pool Size = 5";
  24. }
  25. public static void CreateConnection(string user, string password, string database, string host)
  26. {
  27. var list = System.Configuration.ConfigurationManager.ConnectionStrings;
  28. ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings[list.Count - 1].ConnectionString;
  29. }
  30. public static MYSQLCONNECTION MySqlConnection
  31. {
  32. get
  33. {
  34. MYSQLCONNECTION conn = new MYSQLCONNECTION();
  35. conn.ConnectionString = ConnectionString;
  36. return conn;
  37. }
  38. }
  39. public static bool IsTrojan(byte Job) { return Job >= 10 && Job <= 15; }
  40. public static bool IsWarrior(byte Job) { return Job >= 20 && Job <= 25; }
  41. public static bool IsArcher(byte Job) { return Job >= 40 && Job <= 45; }
  42. public static bool IsNinja(byte Job) { return Job >= 50 && Job <= 55; }
  43. public static bool IsMonk(byte Job) { return Job >= 60 && Job <= 65; }
  44. public static bool IsPirate(byte Job) { return Job >= 70 && Job <= 75; }
  45. public static bool IsWather(byte Job) { return Job >= 100 && Job <= 135; }
  46. public static bool IsFire(byte Job) { return Job >= 142 && Job <= 145; }
  47. public static bool IsWater(byte Job) { return Job >= 132 && Job <= 135; }
  48. public static bool IsTaoist(byte Job) { return Job >= 100 && Job <= 145; }
  49. public static bool IsLee(byte Job) { return Job >= 80 && Job <= 85; }
  50. public static bool Iswind(byte Job) { return Job >= 160 && Job <= 165; }
  51. static SafeDictionary<byte, string> ArcherStats = new SafeDictionary<byte, string>(130);
  52. static SafeDictionary<byte, string> NinjaStats = new SafeDictionary<byte, string>(130);
  53. static SafeDictionary<byte, string> WarriorStats = new SafeDictionary<byte, string>(130);
  54. static SafeDictionary<byte, string> TrojanStats = new SafeDictionary<byte, string>(130);
  55. static SafeDictionary<byte, string> TaoistStats = new SafeDictionary<byte, string>(130);
  56. static SafeDictionary<byte, string> MonkStats = new SafeDictionary<byte, string>(130);
  57. static SafeDictionary<byte, string> PirateStats = new SafeDictionary<byte, string>(130);
  58. static SafeDictionary<byte, string> BruceLeeStats = new SafeDictionary<byte, string>(130);
  59. static SafeDictionary<byte, string> WindwalkerStats = new SafeDictionary<byte, string>(130);//Windwalker Stats.ini File
  60. public static void ReadStats()
  61. {
  62. string Path = Constants.DataHolderPath + "Stats.ini";
  63. IniFile IniFile = new IniFile(Path);
  64. for (byte lvl = 1; lvl < 122; lvl++)
  65. {
  66. string job = "Archer[" + lvl + "]";
  67. string Data = IniFile.ReadString("Stats", job);
  68. try
  69. {
  70. ArcherStats.Add(lvl, Data);
  71. job = "Ninja[" + lvl + "]";
  72. Data = IniFile.ReadString("Stats", job);
  73. NinjaStats.Add(lvl, Data);
  74. job = "Warrior[" + lvl + "]";
  75. Data = IniFile.ReadString("Stats", job);
  76. WarriorStats.Add(lvl, Data);
  77. job = "Trojan[" + lvl + "]";
  78. Data = IniFile.ReadString("Stats", job);
  79. TrojanStats.Add(lvl, Data);
  80. job = "Taoist[" + lvl + "]";
  81. Data = IniFile.ReadString("Stats", job);
  82. TaoistStats.Add(lvl, Data);
  83. job = "Monk[" + lvl + "]";
  84. Data = IniFile.ReadString("Stats", job);
  85. MonkStats.Add(lvl, Data);
  86. job = "BruceLee[" + lvl + "]";
  87. Data = IniFile.ReadString("Stats", job);
  88. BruceLeeStats.Add(lvl, Data);
  89. job = "Pirate[" + lvl + "]";
  90. Data = IniFile.ReadString("Stats", job);
  91. PirateStats.Add(lvl, Data);
  92. job = "Windwalker[" + lvl + "]";//Point Stats Class Windwalker
  93. Data = IniFile.ReadString("Stats", job);
  94. WindwalkerStats.Add(lvl, Data);
  95. }
  96. catch
  97. {
  98. Console.WriteLine(Data);
  99. }
  100. }
  101. }
  102. public static ushort[] FindReviveSpot(ushort mapID)
  103. {
  104. IniFile IniFile = new IniFile(Constants.RevivePoints);
  105. string value = IniFile.ReadString(mapID.ToString(), "Value");
  106. if (value == String.Empty)
  107. return new ushort[] { 1002, 300, 278 };
  108.  
  109. if (value.Contains("L"))
  110. value = IniFile.ReadString(value.Remove(0, 7), "Value");
  111.  
  112. string[] split = value.Split(' ');
  113. List<ushort> values = new List<ushort>();
  114. try
  115. {
  116. values.Add(ushort.Parse(split[0]));
  117. values.Add(ushort.Parse(split[1]));
  118. values.Add(ushort.Parse(split[2]));
  119. }
  120. catch
  121. {
  122. Console.WriteLine("Revive spot with error: " + value);
  123. return new ushort[] { 1002, 300, 278 };
  124. }
  125. return values.ToArray();
  126. }
  127. public static void GetStats(byte inClass, byte inLevel, Client.GameState client)
  128. {
  129. string Class = "";
  130. inClass = (byte)((inClass / 10) * 10);
  131. switch (inClass)
  132. {
  133. case 10: Class = "Trojan"; break;
  134. case 20: Class = "Warrior"; break;
  135. case 40: Class = "Archer"; break;
  136. case 50: Class = "Ninja"; break;
  137. case 60: Class = "Monk"; break;
  138. case 70: Class = "Pirate"; break;
  139. case 80: Class = "BruceLee"; break;
  140. case 160: Class = "Windwalker"; break;// Class Windwalker [160 Mini - 165 Mix]
  141. default: Class = "Taoist"; break;
  142. }
  143. inLevel = Math.Max((byte)10, inLevel);
  144. inLevel = Math.Min((byte)120, inLevel);
  145. string[] Data = null;
  146. if (Class == "Trojan")
  147. Data = TrojanStats[inLevel].Split(',');
  148. else if (Class == "Warrior")
  149. Data = WarriorStats[inLevel].Split(',');
  150. else if (Class == "Archer")
  151. Data = ArcherStats[inLevel].Split(',');
  152. else if (Class == "Ninja")
  153. Data = NinjaStats[inLevel].Split(',');
  154. else if (Class == "Taoist")
  155. Data = TaoistStats[inLevel].Split(',');
  156. else if (Class == "Monk")
  157. Data = MonkStats[inLevel].Split(',');
  158. else if (Class == "Pirate")
  159. Data = PirateStats[inLevel].Split(',');
  160. else if (Class == "BruceLee")
  161. Data = BruceLeeStats[inLevel].Split(',');
  162. else if (Class == "Windwalker")
  163. Data = WindwalkerStats[inLevel].Split(','); // Level Windwalker Class
  164.  
  165. client.Player.Strength = Convert.ToUInt16(Data[0]);
  166. client.Player.Vitality = Convert.ToUInt16(Data[1]);
  167. client.Player.Agility = Convert.ToUInt16(Data[2]);
  168. client.Player.Spirit = Convert.ToUInt16(Data[3]);
  169. }
  170. public static ulong LevelExperience(byte Level)
  171. {
  172. return levelExperience[Math.Min(Math.Max(Level - 1, 0), 135)];
  173. }
  174. public static uint ProficiencyLevelExperience(byte Level)
  175. {
  176. return proficiencyLevelExperience[Math.Min(Level, (byte)20)];
  177. }
  178. public static uint StonePlusPoints(byte plus)
  179. {
  180. return StonePoints[Math.Min((int)plus, 8)];
  181. }
  182. public static uint ComposePlusPoints(byte plus)
  183. {
  184. return ComposePoints[Math.Min(plus, (byte)12)];
  185. }
  186. public static byte SteedSpeed(byte plus)
  187. {
  188. return _SteedSpeed[Math.Min(plus, (byte)12)];
  189. }
  190. public static ushort TalismanPlusPoints(byte plus)
  191. {
  192. return TalismanExtra[Math.Min(plus, (byte)9)];
  193. }
  194. public static ushort PurifyStabilizationPoints(byte plevel)
  195. {
  196. return purifyStabilizationPoints[Math.Min(plevel - 1, (byte)5)];
  197. }
  198. public static ushort RefineryStabilizationPoints(byte elevel)
  199. {
  200. return refineryStabilizationPoints[Math.Min(elevel - 1, (byte)4)];
  201. }
  202. static ushort[] purifyStabilizationPoints = new ushort[6] { 10, 30, 60, 100, 150, 200 };
  203. static ushort[] refineryStabilizationPoints = new ushort[5] { 10, 30, 70, 150, 270 };
  204. public static ushort[] Disguises = new ushort[] { 111, 224, 117, 152, 113, 833, 116, 245, 223, 112, 222, 114, 221, 115, 220 };
  205. static ushort[] StonePoints = new ushort[9] { 1, 10, 40, 120, 360, 1080, 3240, 9720, 29160 };
  206. static ushort[] ComposePoints = new ushort[13] { 20, 20, 80, 240, 720, 2160, 6480, 19440, 58320, 2700, 5500, 9000, 0 };
  207. static byte[] _SteedSpeed = new byte[] { 0, 5, 10, 15, 20, 30, 40, 50, 65, 85, 90, 95, 100 };
  208. static ushort[] TalismanExtra = new ushort[10] { 0, 6, 30, 70, 240, 740, 2240, 6670, 20000, 60000 };
  209. static uint[] proficiencyLevelExperience = new uint[21] { 0, 1200, 68000, 250000, 640000, 1600000, 4000000, 10000000, 22000000, 40000000, 90000000, 95000000, 142500000, 213750000, 320625000, 480937500, 721406250, 1082109375, 1623164063, 2100000000, 0 };
  210. static ulong[] levelExperience = new ulong[139] { 120, 180, 240, 360, 600, 960, 1200, 2400, 3600, 8400, 12000, 14400, 18000, 21600, 22646, 32203, 37433, 47556, 56609, 68772, 70515, 75936, 97733, 114836, 120853, 123981, 126720, 145878, 173436, 197646, 202451, 212160, 244190, 285823, 305986, 312864, 324480, 366168, 433959, 460590, 506738, 569994, 728527, 850829, 916479, 935118, 940800, 1076593, 1272780, 1357994, 1384861, 1478400, 1632438, 1903104, 2066042, 2104924, 1921085, 2417202, 2853462, 3054574, 3111217, 3225600, 3810962, 4437896, 4880605, 4970962, 5107200, 5652518, 6579162, 6877991, 7100700, 7157657, 9106860, 10596398, 11220549, 11409192, 11424000, 12882952, 15172807, 15896990, 16163799, 16800000, 19230280, 22365208, 23819312, 24219528, 24864000, 27200077, 32033165, 33723801, 34291317, 34944000, 39463523, 45878567, 48924236, 49729220, 51072000, 55808379, 64870058, 68391931, 69537026, 76422968, 96950789, 112676755, 120090482, 121798280, 127680000, 137446887, 193715970, 408832150, 454674685, 461125885, 469189885, 477253885, 480479485, 485317885, 493381885, 580580046, 717424987, 282274058, 338728870, 406474644, 487769572, 585323487, 702388184, 842865821, 1011438985, 1073741823, 1073741823, 8589134588, 25767403764, 77302211292, 231906633876, 347859950814, 447859950814, 547859950814, 1174030000000, 1761040000000, 2641550000000 };
  211. }
  212. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement