Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 10.77 KB | None | 0 0
  1. // ☺ Created by KimoxD
  2.  
  3.  
  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. using Core;
  11.  
  12. namespace COServer.Database
  13. {
  14.     public unsafe static class DataHolder
  15.     {
  16.         public static string ConnectionString;
  17.         private static string MySqlUsername, MySqlPassword, MySqlDatabase, MySqlHost;
  18.         public static void CreateConnection1(string user, string password, string database, string host)
  19.         {
  20.             MySqlUsername = user;
  21.             MySqlHost = host;
  22.             MySqlPassword = password;
  23.             MySqlDatabase = database;
  24.             ConnectionString = "Server=" + MySqlHost + ";Database='" + MySqlDatabase + "';Username='" + MySqlUsername + "';Password='" + MySqlPassword + "';Pooling=true; Max Pool Size = 900000; Min Pool Size = 5";
  25.         }
  26.         public static void CreateConnection(string user, string password, string database, string host)
  27.         {
  28.             var list = System.Configuration.ConfigurationManager.ConnectionStrings;
  29.             ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings[list.Count - 1].ConnectionString;
  30.         }
  31.         public static MYSQLCONNECTION MySqlConnection
  32.         {
  33.             get
  34.             {
  35.                 MYSQLCONNECTION conn = new MYSQLCONNECTION();
  36.                 conn.ConnectionString = ConnectionString;
  37.                 return conn;
  38.             }
  39.         }
  40.         public static ushort[][] RevivePoints = new ushort[31][];
  41.         static SafeDictionary<byte, string> ArcherStats = new SafeDictionary<byte, string>(130);
  42.         static SafeDictionary<byte, string> NinjaStats = new SafeDictionary<byte, string>(130);
  43.         static SafeDictionary<byte, string> WarriorStats = new SafeDictionary<byte, string>(130);
  44.         static SafeDictionary<byte, string> TrojanStats = new SafeDictionary<byte, string>(130);
  45.         static SafeDictionary<byte, string> TaoistStats = new SafeDictionary<byte, string>(130);
  46.         static SafeDictionary<byte, string> MonkStats = new SafeDictionary<byte, string>(130);
  47.         static SafeDictionary<byte, string> PirateStats = new SafeDictionary<byte, string>(130);
  48.         static SafeDictionary<byte, string> BruceLeeStats = new SafeDictionary<byte, string>(130);
  49.         static SafeDictionary<byte, string> WindwalkerStats = new SafeDictionary<byte, string>(130);
  50.         public static void ReadStats()
  51.         {
  52.             string Path = Constants.DataHolderPath + "Stats.ini";
  53.             IniFile IniFile = new IniFile(Path);
  54.             for (byte lvl = 1; lvl < 122; lvl++)
  55.             {
  56.                 string job = "Archer[" + lvl + "]";
  57.                 string Data = IniFile.ReadString("Stats", job);
  58.                 try
  59.                 {
  60.                     ArcherStats.Add(lvl, Data);
  61.                     job = "Ninja[" + lvl + "]";
  62.                     Data = IniFile.ReadString("Stats", job);
  63.                     NinjaStats.Add(lvl, Data);
  64.                     job = "Warrior[" + lvl + "]";
  65.                     Data = IniFile.ReadString("Stats", job);
  66.                     WarriorStats.Add(lvl, Data);
  67.                     job = "Trojan[" + lvl + "]";
  68.                     Data = IniFile.ReadString("Stats", job);
  69.                     TrojanStats.Add(lvl, Data);
  70.                     job = "Taoist[" + lvl + "]";
  71.                     Data = IniFile.ReadString("Stats", job);
  72.                     TaoistStats.Add(lvl, Data);
  73.                     job = "Monk[" + lvl + "]";
  74.                     Data = IniFile.ReadString("Stats", job);
  75.                     MonkStats.Add(lvl, Data);
  76.                     job = "BruceLee[" + lvl + "]";
  77.                     Data = IniFile.ReadString("Stats", job);
  78.                     BruceLeeStats.Add(lvl, Data);
  79.                     job = "Pirate[" + lvl + "]";
  80.                     Data = IniFile.ReadString("Stats", job);
  81.                     PirateStats.Add(lvl, Data);
  82.                     Data = IniFile.ReadString("Stats", job);
  83.                     WindwalkerStats.Add(lvl, Data);
  84.                 }
  85.                 catch
  86.                 {
  87.                     Console.WriteLine(Data);
  88.                 }
  89.             }
  90.         }
  91.         public static ushort[] FindReviveSpot(ushort mapID)
  92.         {
  93.             IniFile IniFile = new IniFile(Constants.RevivePoints);
  94.             string value = IniFile.ReadString(mapID.ToString(), "Value");
  95.             if (value == String.Empty)
  96.                 return new ushort[] { 1002, 300, 278 };
  97.  
  98.             if (value.Contains("L"))
  99.                 value = IniFile.ReadString(value.Remove(0, 7), "Value");
  100.  
  101.             string[] split = value.Split(' ');
  102.             List<ushort> values = new List<ushort>();
  103.             try
  104.             {
  105.                 values.Add(ushort.Parse(split[0]));
  106.                 values.Add(ushort.Parse(split[1]));
  107.                 values.Add(ushort.Parse(split[2]));
  108.             }
  109.             catch
  110.             {
  111.                 Console.WriteLine("Revive spot with error: " + value);
  112.                 return new ushort[] { 1002, 300, 278 };
  113.             }
  114.             return values.ToArray();
  115.         }
  116.         public static void GetStats(byte inClass, byte inLevel, Client.GameState client)
  117.         {
  118.             string Class = "";
  119.             inClass = (byte)((inClass / 10) * 10);
  120.             switch (inClass)
  121.             {
  122.                 case 10: Class = "Trojan"; break;
  123.                 case 20: Class = "Warrior"; break;
  124.                 case 40: Class = "Archer"; break;
  125.                 case 50: Class = "Ninja"; break;
  126.                 case 60: Class = "Monk"; break;
  127.                 case 70: Class = "Pirate"; break;
  128.                 case 80: Class = "BruceLee"; break;
  129.                 case 160: Class = "Windwalker"; break;
  130.                 default: Class = "Taoist"; break;
  131.             }
  132.             inLevel = Math.Max((byte)10, inLevel);
  133.             inLevel = Math.Min((byte)120, inLevel);
  134.             string[] Data = null;
  135.             if (Class == "Trojan")
  136.                 Data = TrojanStats[inLevel].Split(',');
  137.             else if (Class == "Warrior")
  138.                 Data = WarriorStats[inLevel].Split(',');
  139.             else if (Class == "Archer")
  140.                 Data = ArcherStats[inLevel].Split(',');
  141.             else if (Class == "Ninja")
  142.                 Data = NinjaStats[inLevel].Split(',');
  143.             else if (Class == "Taoist")
  144.                 Data = TaoistStats[inLevel].Split(',');
  145.             else if (Class == "Monk")
  146.                 Data = MonkStats[inLevel].Split(',');
  147.             else if (Class == "Pirate")
  148.                 Data = PirateStats[inLevel].Split(',');
  149.             else if (Class == "BruceLee")
  150.                 Data = BruceLeeStats[inLevel].Split(',');
  151.             else if (Class == "Windwalker")
  152.                 Data = WindwalkerStats[inLevel].Split(',');
  153.             client.Player.Strength = Convert.ToUInt16(Data[0]);
  154.             client.Player.Vitality = Convert.ToUInt16(Data[1]);
  155.             client.Player.Agility = Convert.ToUInt16(Data[2]);
  156.             client.Player.Spirit = Convert.ToUInt16(Data[3]);
  157.         }
  158.         public static ulong LevelExperience(byte Level)
  159.         {
  160.             return levelExperience[Math.Min(Math.Max(Level - 1, 0), 135)];
  161.         }
  162.         public static uint ProficiencyLevelExperience(byte Level)
  163.         {
  164.             return proficiencyLevelExperience[Math.Min(Level, (byte)20)];
  165.         }
  166.         public static uint StonePlusPoints(byte plus)
  167.         {
  168.             return StonePoints[Math.Min((int)plus, 8)];
  169.         }
  170.         public static uint ComposePlusPoints(byte plus)
  171.         {
  172.             return ComposePoints[Math.Min(plus, (byte)12)];
  173.         }
  174.         public static uint PerfectionPoints(uint plus)
  175.         {
  176.             return ComposePoints[Math.Min(plus, (byte)12)];
  177.         }
  178.         public static byte SteedSpeed(byte plus)
  179.         {
  180.             return _SteedSpeed[Math.Min(plus, (byte)12)];
  181.         }
  182.         public static ushort TalismanPlusPoints(byte plus)
  183.         {
  184.             return TalismanExtra[Math.Min(plus, (byte)9)];
  185.         }
  186.         public static ushort PurifyStabilizationPoints(byte plevel)
  187.         {
  188.             return purifyStabilizationPoints[Math.Min(plevel - 1, (byte)5)];
  189.         }
  190.         public static ushort RefineryStabilizationPoints(byte elevel)
  191.         {
  192.             return refineryStabilizationPoints[Math.Min(elevel - 1, (byte)4)];
  193.         }
  194.         static ushort[] purifyStabilizationPoints = new ushort[6] { 10, 30, 60, 100, 150, 200 };
  195.         static ushort[] refineryStabilizationPoints = new ushort[5] { 10, 30, 70, 150, 270 };
  196.         public static ushort[] Disguises = new ushort[] { 111, 224, 117, 152, 113, 833, 116, 245, 223, 112, 222, 114, 221, 115, 220 };
  197.         static ushort[] StonePoints = new ushort[9] { 1, 10, 40, 120, 360, 1080, 3240, 9720, 29160 };
  198.         static ushort[] ComposePoints = new ushort[13] { 20, 20, 80, 240, 720, 2160, 6480, 19440, 58320, 2700, 5500, 9000, 0 };
  199.         static byte[] _SteedSpeed = new byte[] { 0, 5, 10, 15, 20, 30, 40, 50, 65, 85, 90, 95, 100 };
  200.         static ushort[] TalismanExtra = new ushort[10] { 0, 6, 30, 70, 240, 740, 2240, 6670, 20000, 60000 };
  201.         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 };
  202.         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 };
  203.     }
  204. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement