Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.92 KB | None | 0 0
  1. private void bOpenFile_Click(object sender, EventArgs e)
  2. {
  3. if (openFileDialog1.ShowDialog() == DialogResult.OK)
  4. {
  5. string fileName = openFileDialog1.FileName;
  6.  
  7. FileStream file = new FileStream(fileName, FileMode.Open, FileAccess.Read);
  8. StreamReader reader = new StreamReader(fileName);
  9.  
  10. string[] fileText = File.ReadAllLines(fileName);
  11. string[] filterText = new string[fileText.Length];
  12. string[] tempText = new string[fileText.Length];
  13.  
  14. tSQL.Clear();
  15. tSQL.Text = "replace into creature_difficulty_stat(entry, difficulty, dmg_multiplier, HealthModifier) values";
  16.  
  17. for (int i = 0; i < fileText.Length; ++i)
  18. {
  19. if (fileText[i].Contains((@"""health""")))
  20. filterText[i] = fileText[i] + "\r\n";
  21.  
  22. if (fileText[i].Contains(@"""level"""))
  23. filterText[i] = fileText[i] + "\r\n";
  24.  
  25. if (fileText[i].Contains(@"""id"""))
  26. {
  27. filterText[i] = fileText[i] + "\r\n";
  28. filterText[i] += "\r\n";
  29. }
  30. }
  31.  
  32. int lenghID = 1;
  33. foreach (string s in filterText)
  34. {
  35. if (s == null)
  36. continue;
  37.  
  38. tFilter.Text += s;
  39.  
  40. for (int i = 0; i < s.Length; ++i)
  41. {
  42. if (Char.IsPunctuation(s, i))
  43. if (s[i] == ',')
  44. {
  45. tempText[lenghID] += "\r\n";
  46. break;
  47. }
  48.  
  49. if (Char.IsNumber(s, i))
  50. tempText[lenghID] += s[i];
  51. }
  52.  
  53. if (lenghID % 3 == 0)
  54. {
  55. tempText[lenghID] += "\r\n";
  56.  
  57. int h = 0;
  58. int l = 0;
  59. int id = 0;
  60.  
  61. id = int.Parse(tempText[lenghID]);
  62. l = int.Parse(tempText[lenghID - 1]);
  63. h = int.Parse(tempText[lenghID - 2]);
  64.  
  65. ToFormQuery(h, l, id);
  66. }
  67.  
  68. ++lenghID;
  69. }
  70. }
  71.  
  72. void ToFormQuery(int health, int level, int id)
  73. {
  74. tSQL.Text += "\r\n";
  75. tSQL.Text += "(" + id + ", 8, 1, " + GetModify(health, GetHeath(false, level)).ToString("f2") + ")," + " (" + id + ", 23, 1, " + GetModify(health, GetHeath(false, level)).ToString("f2") + "),";
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement