-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMainWindow.axaml.cs
2865 lines (2590 loc) · 144 KB
/
MainWindow.axaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Interactivity;
using Avalonia.Styling;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Net;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using Point = System.Drawing.Point;
using Bitmap = Avalonia.Media.Imaging.Bitmap;
using Avalonia.Themes.Fluent;
using System.Threading;
using System.Net.Http;
using System.Net.Http.Headers;
using Avalonia.Threading;
using System.Security.Cryptography.X509Certificates;
namespace LOL_Client_TOOL
{
public partial class MainWindow : Window
{
public static bool debug = false;//set true to display inputs for testing lcu requests
public static bool preview = false;
public static bool alreadyRunning = false;
public static bool showFormLoginOnce = true;
public static ConfigurationData configData = new ConfigurationData();
public static Avalonia.Controls.WindowIcon icco = new WindowIcon(getBitmap("https://user-images.githubusercontent.com/21199858/166489461-f28fbae9-b620-474e-9fc6-7a58566e584b.png"));
public static bool isClientApiReady = false;
public static Avalonia.Media.Imaging.Bitmap icon = null;
public static Dictionary<string, string> lesArguments = new Dictionary<string, string>();
public static Dictionary<string, string> riotCredntials = new Dictionary<string, string>();
public static Dictionary<string, string> shardsRunes = new Dictionary<string, string>();
public static Dictionary<int, string> currentSummonerTestedIcon = new Dictionary<int, string>();
public static Dictionary<int, System.Drawing.Point> posSubMainRune = new Dictionary<int, Point>();
public static SortedDictionary<string, string> champs = new SortedDictionary<string, string>();
public static List<string> summonerIcons = new List<string>();
public static List<string> currentSummonerOwnedIcons = new List<string>();
public static List<string> conversationsMessageSent = new List<string>();
public static List<string> usernames = new List<string>();
public static List<TextBlock> TextBlocksSummonerStatus = new List<TextBlock>();
public static List<championPick> pickPriorities = new List<championPick>();
public static string LCUport = "";
public static string portRiotClient = "";
public static string autorization = "";
public static string autorizationRiotClient = "";
public static string version = "";
public static string lang = "en_US";
public static string DDragonImg = "https://ddragon.leagueoflegends.com/cdn/img/";
public static string pathRunes = "C:\\Users\\" + Environment.UserName + "\\AppData\\Local\\LOL_Client_TOOL\\runes\\";
public static string instaLockChampId = "266";
public static string position1 = "TOP";
public static string position2 = "JUNGLE";
public static string[] chare = { "/" };
public static string[] postions = new string[] { "TOP", "JUNGLE", "MID", "ADC", "SUPPORT", "FILL" };// TOP JUNGLE MIDDLE BOTTOM UTILITY FILL
public static string runeSource = "U.GG";
public static string lastRunePageBuilt = "";
public static string lastSummonerBuilt = "";
public static string leagueClientAPIStatus = "";
public static int champPickId = 0;
public static int instalockCount = 0;
public static int downloadingRunes = 0;
public static int downloadedRunes = 0;
public static int AutoQPlayAgianIntervalle = 0;
public static int autoPositionOnce = 0;
public static Thread LcuCon = new Thread(setupLCU) { };
public static JArray runesReforged = new JArray();
public static bool formSummonerIconLoadComplete = false;
public static bool processingAllIcon = false;
public static bool formSummonerRuneIsSetup = false;
public static bool instalockIsEnabled = false;
public HttpClient httpClient;
public string Token { get; set; }
public ushort RiotPort { get; set; }
public string ClientReadyCheckState
{
get { return _clientReadyCheckState; }
set
{
apiEndPointResponse.Text += DateTime.Now + " : " + value + Environment.NewLine;
if (_clientReadyCheckState != value)
{
_clientReadyCheckState = value;
}
}
}
public static string _clientReadyCheckState;
public static List<leagueRune> leagueOfLegendsRunes = new List<leagueRune>();
public static List<champion> leagueOfLegendsChampions = new List<champion>();
public class ConfigurationData
{
public bool autoAccept { get; set; }
public bool autoPick { get; set; }
public bool autoBan { get; set; }
public bool autoPlayAgain { get; set; }
public bool autoHonor { get; set; }
public bool autoRole { get; set; }
public string autoRolePosition1 { get; set; }
public string autoRolePosition2 { get; set; }
public string autoPickChampion { get; set; }
public bool autoMessage { get; set; }
public string autoMessageText { get; set; }
public bool autoReroll { get; set; }
public bool autoSkin { get; set; }
public bool autoPrePick { get; set; }
public bool autoAramBenchSwap { get; set; }
public bool autoRunes { get; set; }
public bool autoSummoners { get; set; }
public string autoRunesSource { get; set; }
public string autoSummonersSource { get; set; }
public bool LightOn { get; set; }
public List<championPick> championPickList { get; set; }
public int prePickDelay { get; set; }
public int pickDelay { get; set; }
public int banDelay { get; set; }
public string leagueOfLegendsClientExe { get; set; }
public string lang { get; set; }
public List<leagueOfLegendsAccount> leagueOfLegendsAccounts { get; set; }
}
public class leagueOfLegendsAccount
{
public string username { get; set; }
public string password { get; set; }
}
public class championsPrio
{
int id { get; set; }
int pick { get; set; }
int ban { get; set; }
int aram { get; set; }
}
public class championPick
{
public int Id { get; set; }
public int Pick { get; set; }
public int Ban { get; set; }
public int Aram { get; set; }
}
public class RunePage
{
public bool current { get; set; }
public int id { get; set; }
public bool isActive { get; set; }
public bool isDeletable { get; set; }
public bool isEditable { get; set; }
public bool isValid { get; set; }
public double lastModified { get; set; }
public string name { get; set; }
public int order { get; set; }
public int primaryStyleId { get; set; }
public int subStyleId { get; set; }
public Dictionary<int, int> selectedPerkIds { get; set; }
}
public class SummonerRunes
{
public Dictionary<int, RunePage> RunePages { get; set; }
}
public class Rune
{
public int id { get; set; }
public string key { get; set; }
public string icon { get; set; }
public string name { get; set; }
public string shortDesc { get; set; }
public string longDesc { get; set; }
}
public class leagueRune
{
public int id { get; set; }
public string key { get; set; }
public string icon { get; set; }
public string name { get; set; }
public Dictionary<int, Dictionary<int, Rune>> slots { get; set; }
}
public class champion
{
public string name { get; set; }
public string version { get; set; }
public string id { get; set; }
public string key { get; set; }
public string title { get; set; }
public string blurb { get; set; }
public info info { get; set; }
public image image { get; set; }
public List<string> tags { get; set; }
public string partype { get; set; }
public stats stats { get; set; }
}
public class info
{
public string attack { get; set; }
public string defense { get; set; }
public string magic { get; set; }
public string difficulty { get; set; }
}
public class image
{
public string full { get; set; }
public string sprite { get; set; }
public string group { get; set; }
public string x { get; set; }
public string y { get; set; }
public string w { get; set; }
public string h { get; set; }
}
public class tags
{
public string tag1 { get; set; }
public string tag2 { get; set; }
}
[Conditional("DEBUG")]
public static void isDebug()
{
debug = false;
}
public class stats
{
public string hp { get; set; }
public string hpperlevel { get; set; }
public string mp { get; set; }
public string mpperlevel { get; set; }
public string movespeed { get; set; }
public string armor { get; set; }
public string armorperlevel { get; set; }
public string spellblock { get; set; }
public string spellblockperlevel { get; set; }
public string attackrange { get; set; }
public string hpregen { get; set; }
public string hpregenperlevel { get; set; }
public string mpregen { get; set; }
public string mpregenperlevel { get; set; }
public string crit { get; set; }
public string critperlevel { get; set; }
public string attackdamage { get; set; }
public string attackdamageperlevel { get; set; }
public string attackspeedoffset { get; set; }
public string attackspeedperlevel { get; set; }
public string attackdamageperleveloffset { get; set; }
}
public class ComboBoxIdName
{
public string Name { get; set; }
}
public class RerollPoints
{
public string currentPoints { get; set; }
public string maxRolls { get; set; }
public string numberOfRolls { get; set; }
public string pointsCostToRoll { get; set; }
public string pointsToReroll { get; set; }
}
public class Summoner
{
public string accountId { get; set; }
public string displayName { get; set; }
public string internalName { get; set; }
public string nameChangeFlag { get; set; }
public string percentCompleteForNextLevel { get; set; }
public string profileIconId { get; set; }
public string puuid { get; set; }
public RerollPoints rerollPoints { get; set; }
public string summonerId { get; set; }
public string summonerLevel { get; set; }
public string unnamed { get; set; }
public string xpSinceLastLevel { get; set; }
public string xpUntilNextLevel { get; set; }
}
public static Summoner currentSummoner = new Summoner();
public static RerollPoints currentSummonerRerollPoints = new RerollPoints();
public static SummonerRunes currentSummonerRunes = new SummonerRunes();
//Form objects
public static Grid gridMain = new Grid();
public static Grid FormSummonerIcon = new Grid();
public static Grid FormSummonerRunes = new Grid();
public static Grid FormChampSelect = new Grid();
public static Window formChampions = new Window();
public static Grid gridChampions = new Grid();
public static Window formInformation = new Window();
public static Grid gridInformations = new Grid();
public static Window formDelays = new Window();
public static Grid gridDelays = new Grid();
public static Window formLogin = new Window();
public static ComboBox comboBoxRunesPages = new ComboBox();
public static ComboBox comboBoxSummonerStatus = new ComboBox();
public static ComboBox comboBoxAutoPosition1 = new ComboBox();
public static ComboBox comboBoxAutoPosition2 = new ComboBox();
public static ComboBox comboBoxAutoRunesSources = new ComboBox();
public static ComboBox comboBoxAutoSummonersSources = new ComboBox();
public static ComboBox comboBoxLightOnOff = new ComboBox();
public static ComboBox comboBoxSavedAccounts = new ComboBox();
public static ComboBox comboBoxLanguage = new ComboBox();
public static List<ComboBoxIdName> summonerStatus = new List<ComboBoxIdName>();
public static Label labelSummonerDisplayName = new Label();
public static Label labelInfo = new Label();
public static ToolTip tooltip = new ToolTip();
public static CheckBox verifyOwnedIcons = new CheckBox();
public static CheckBox checkBoxAutoAccept = new CheckBox();
public static CheckBox checkBoxAutoPick = new CheckBox();
public static CheckBox checkBoxAutoBan = new CheckBox();
public static CheckBox checkBoxAutoQPlayAgain = new CheckBox();
public static CheckBox checkBoxAutoHonor = new CheckBox();
public static CheckBox checkBoxAutoPosition = new CheckBox();
public static CheckBox checkBoxAutoMessage = new CheckBox();
public static CheckBox checkBoxAutoReroll = new CheckBox();
public static CheckBox checkBoxAutoSkin = new CheckBox();
public static CheckBox checkBoxAutoPrePick = new CheckBox();
public static CheckBox checkBoxAutoAramBenchSwap = new CheckBox();
public static CheckBox checkBoxAutoRunes = new CheckBox();
public static CheckBox checkBoxAutoSummoners = new CheckBox();
public static TextBox apiEnpoint = new TextBox();
public static TextBox apiRequestType = new TextBox();
public static TextBox apiRequestJson = new TextBox();
public static TextBox apiEndPointResponse = new TextBox();
public static TextBox textBoxId = new TextBox();
public static TextBox textBoxConversationMessage = new TextBox();
public static TextBox textBoxUsername = new TextBox();
public static TextBox textBoxPassword = new TextBox();
public static Button apiEndpointCall = new Button();
public static Button buttonRune = new Button();
public static Button buttonSetupFrom = new Button();
public static Button buttonChampions = new Button();
public static Button buttonDelays = new Button();
public static Button buttonLogin = new Button();
public static Button buttonAccount = new Button();
public static Button buttonRemoveAccount = new Button();
public static Button buttonDisconnect = new Button();
public static Avalonia.Controls.Image summonerIcon = new Avalonia.Controls.Image();
//Form object EVENTS
private static ImageCodecInfo GetEncoderInfo(String mimeType)
{
int j;
ImageCodecInfo[] encoders;
encoders = ImageCodecInfo.GetImageEncoders();
for (j = 0; j < encoders.Length; ++j)
{
if (encoders[j].MimeType == mimeType)
return encoders[j];
}
return null;
}
private void SetTimer()
{
//System.Timers.Timer aTimer = new System.Timers.Timer();
//aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
//aTimer.Interval = 1000;
//aTimer.Enabled = true;
}
public static void getVersion()
{
string data = DDragonRequest("https://ddragon.leagueoflegends.com/api/versions.json");
var LeagueVersion = JArray.Parse(data);
version = LeagueVersion.First.ToString();
}
private static string DDragonRequest(string url = "", string json = "")
{
if (!url.Contains("version"))
{
if (url.Contains("languages"))
{
url = "https://ddragon.leagueoflegends.com/cdn/" + url;
}
else
{
url = "https://ddragon.leagueoflegends.com/cdn/" + version + url;
}
}
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "GET";
if (json != "")
{
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
streamWriter.Write(json);
}
}
System.Net.ServicePointManager.ServerCertificateValidationCallback = (senderX, certificate, chain, sslPolicyErrors) => { return true; };
try
{
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
Stream receiveStream = httpResponse.GetResponseStream();
StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
return readStream.ReadToEnd();
}
catch (Exception e)
{
var messageBoxStandardWindow = MessageBox.Avalonia.MessageBoxManager
.GetMessageBoxStandardWindow("DDragonRequest", e.Message);
messageBoxStandardWindow.Show();
return e.Message;
}
}
public static async Task<string> LCURequest(string endpoint, HttpMethod httpMethod, string requestBody = "")
{
ProcessModule leagueProcess = Process.GetProcessesByName("LeagueClientUx").First().MainModule;
string filename = leagueProcess.FileName;
int x = filename.IndexOf("LeagueClientUx.exe");
string dir_path = filename.Remove(x);
string lockfile = "";
using (FileStream stream = File.Open(dir_path + "lockfile", FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
using (StreamReader reader = new StreamReader(stream))
{
while (!reader.EndOfStream)
{
lockfile = lockfile + reader.ReadLine();
}
}
}
var httpContent = new StringContent(requestBody, Encoding.UTF8, "application/json");
string result = "";
HttpClient _httpClient = new();
var certCollection = new X509Certificate2Collection();
certCollection.Import("pem.pem");
var riotCert = certCollection[0];
HttpClientHandler handler = new()
{
ClientCertificateOptions = ClientCertificateOption.Manual,
SslProtocols = System.Security.Authentication.SslProtocols.Tls12 | System.Security.Authentication.SslProtocols.Tls11 | System.Security.Authentication.SslProtocols.Tls,
ServerCertificateCustomValidationCallback =
(httpRequestMessage, cert, cetChain, policyErrors) =>
{
return true;
}
};
handler.ClientCertificates.Add(riotCert);
_httpClient = new HttpClient(handler)
{
BaseAddress = new Uri($"https://127.0.0.1:{lockfile.Split(":")[2]}")
};
_httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.UTF8.GetBytes($"riot:{lockfile.Split(":")[3]}")));
var response = await _httpClient.SendAsync(new HttpRequestMessage(httpMethod, endpoint) { Content = httpContent });
string responseString = string.Empty;
if (!response.IsSuccessStatusCode) Console.WriteLine($"{response.StatusCode} for endpoint : {endpoint}");
responseString = await response.Content.ReadAsStringAsync();
result = responseString;
return responseString;
}
public static Bitmap getIcon(string iconId)
{
string url = "http://ddragon.leagueoflegends.com/cdn/" + version + "/img/profileicon/" + iconId + ".png";
WebRequest request = WebRequest.Create(url);
WebResponse response = request.GetResponse();
Stream responseStream = response.GetResponseStream();
System.Drawing.Bitmap bitmap2 = new System.Drawing.Bitmap(responseStream);
//If you get 'dllimport unknown'-, then add 'using System.Runtime.InteropServices;'
[DllImport("gdi32.dll", EntryPoint = "DeleteObject")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool DeleteObject([In] IntPtr hObject);
System.Drawing.Bitmap bitmapTmp = new System.Drawing.Bitmap(bitmap2);
var bitmapdata = bitmapTmp.LockBits(new Rectangle(0, 0, bitmapTmp.Width, bitmapTmp.Height), ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Bitmap bitmap1 = new Bitmap(Avalonia.Platform.PixelFormat.Bgra8888, Avalonia.Platform.AlphaFormat.Premul,
bitmapdata.Scan0,
new Avalonia.PixelSize(bitmapdata.Width, bitmapdata.Height),
new Avalonia.Vector(96, 96),
bitmapdata.Stride);
bitmapTmp.UnlockBits(bitmapdata);
bitmapTmp.Dispose();
return bitmap1;
}
public static Bitmap getBitmap(string url)
{
WebRequest request = WebRequest.Create(url);
WebResponse response = request.GetResponse();
Stream responseStream = response.GetResponseStream();
System.Drawing.Bitmap bitmap2 = new System.Drawing.Bitmap(responseStream);
//If you get 'dllimport unknown'-, then add 'using System.Runtime.InteropServices;'
[DllImport("gdi32.dll", EntryPoint = "DeleteObject")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool DeleteObject([In] IntPtr hObject);
System.Drawing.Bitmap bitmapTmp = new System.Drawing.Bitmap(bitmap2);
var bitmapdata = bitmapTmp.LockBits(new Rectangle(0, 0, bitmapTmp.Width, bitmapTmp.Height), ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Bitmap bitmap1 = new Bitmap(Avalonia.Platform.PixelFormat.Bgra8888, Avalonia.Platform.AlphaFormat.Premul,
bitmapdata.Scan0,
new Avalonia.PixelSize(bitmapdata.Width, bitmapdata.Height),
new Avalonia.Vector(96, 96),
bitmapdata.Stride);
bitmapTmp.UnlockBits(bitmapdata);
bitmapTmp.Dispose();
return bitmap1;
}
public static async Task getSummoner()
{
JObject summoner = JObject.Parse(await LCURequest("/lol-summoner/v1/current-summoner", HttpMethod.Get, ""));
currentSummoner.accountId = (string)summoner["accountId"];
currentSummoner.displayName = (string)summoner["displayName"];
currentSummoner.internalName = (string)summoner["internalName"];
currentSummoner.nameChangeFlag = (string)summoner["nameChangeFlag"];
currentSummoner.percentCompleteForNextLevel = (string)summoner["percentCompleteForNextLevel"];
if (currentSummoner.profileIconId != (string)summoner["profileIconId"])
{
icon = getIcon((string)summoner["profileIconId"]);
}
currentSummoner.profileIconId = (string)summoner["profileIconId"];
currentSummoner.puuid = (string)summoner["puuid"];
currentSummoner.summonerId = (string)summoner["summonerId"];
currentSummoner.summonerLevel = (string)summoner["summonerLevel"];
currentSummoner.unnamed = (string)summoner["unnamed"];
currentSummoner.xpSinceLastLevel = (string)summoner["xpSinceLastLevel"];
currentSummoner.xpUntilNextLevel = (string)summoner["xpUntilNextLevel"];
currentSummonerRerollPoints.currentPoints = (string)summoner["rerollPoints"]["currentPoints"];
currentSummonerRerollPoints.maxRolls = (string)summoner["rerollPoints"]["maxRolls"];
currentSummonerRerollPoints.numberOfRolls = (string)summoner["rerollPoints"]["numberOfRolls"];
currentSummonerRerollPoints.pointsCostToRoll = (string)summoner["rerollPoints"]["pointsCostToRoll"];
currentSummonerRerollPoints.pointsToReroll = (string)summoner["rerollPoints"]["pointsCostToReroll"];
}
public static async Task getAllChampions()
{
string tempJsonChamp = DDragonRequest("/data/" + lang + "/champion.json");
JObject championsJson = JObject.Parse(tempJsonChamp);
leagueOfLegendsChampions.Clear();
foreach (var champData in championsJson["data"].Values())
{
string lestring = champData.ToString();
champion lechamp = JsonConvert.DeserializeObject<champion>(lestring);
leagueOfLegendsChampions.Add(lechamp);
}
leagueOfLegendsChampions = leagueOfLegendsChampions.OrderBy(o => o.name).ToList();
}
public static async Task configSaveAsync()
{
string config = Newtonsoft.Json.JsonConvert.SerializeObject(configData);
string path = "C:\\Users\\" + Environment.UserName + "\\AppData\\Local\\LOL_Client_TOOL\\config\\";
Directory.CreateDirectory(path);
using (FileStream fs = File.Create(path + "config.json"))
{
byte[] data = new UTF8Encoding(true).GetBytes(config);
fs.Write(data, 0, data.Length);
}
}
public void setSummonerName()
{
labelSummonerDisplayName.Content = "caca";
}
public void formLogin_Show()
{
formLogin.Show();
}
private static async Task OnTimedEvent()
{
string currentState = await LCURequest("/lol-gameflow/v1/session", HttpMethod.Get);
int aaaaaaaled = 1000;
while (currentState.Contains("404"))
{
currentState = await LCURequest("/lol-gameflow/v1/session", HttpMethod.Get);
Thread.Sleep(aaaaaaaled);
aaaaaaaled += 1000;
}
if (!currentState.Contains("404") && alreadyRunning != true)
{
alreadyRunning = true;
JObject gameFlow = JObject.Parse(currentState);
//Keep json for the loop START
string lolChampSelectV1Session = "";
int timer = 0;
int delayMax = 0;
if (configData.autoReroll || configData.autoPick || configData.autoBan || configData.autoMessage || configData.autoSkin || configData.autoReroll)
{
if(gameFlow["phase"].ToString().ToLower() == "ChampSelect".ToLower())
{
lolChampSelectV1Session = await LCURequest("/lol-champ-select/v1/session", HttpMethod.Get);
if (lolChampSelectV1Session != "")
{
JObject json = JObject.Parse(lolChampSelectV1Session);
timer = Convert.ToInt32(json["timer"]["adjustedTimeLeftInPhase"]);
delayMax = Convert.ToInt32(json["timer"]["totalTimeInPhase"]);
}
}
}
//Keep json for the loop END
//auto accept start
if (configData.autoAccept && gameFlow["phase"].ToString().ToLower() == "readycheck")
{
LCURequest("/lol-matchmaking/v1/ready-check/accept", HttpMethod.Post, "");
}
//auto accept end
//Honor start
if (configData.autoHonor && gameFlow["phase"].ToString().ToLower() == "PreEndOfGame".ToLower())
{
//get best player for honor start
string tempBestSummonerId = "";
double tempBestSummonerKDA = 0;
string gameData = await LCURequest("/lol-end-of-game/v1/eog-stats-block", HttpMethod.Get, "");
if (gameData != "")
{
JObject gameDataJson = JObject.Parse(gameData);
string localPlayerTeam = gameDataJson["localPlayer"]["teamId"].ToString();
//calculate player team KDA
foreach (var team in gameDataJson["teams"])
{
if (team["teamId"].ToString() == localPlayerTeam)
{
foreach (var player in team["players"])
{
if (player["summonerId"].ToString() != currentSummoner.summonerId.ToString())
{
double KDA = (Convert.ToDouble(player["stats"]["ASSISTS"].ToString()) + Convert.ToDouble(player["stats"]["CHAMPIONS_KILLED"].ToString()) / Convert.ToDouble(player["stats"]["NUM_DEATHS"].ToString()));
if (KDA > tempBestSummonerKDA)
{
tempBestSummonerKDA = KDA;
tempBestSummonerId = player["summonerId"].ToString();
}
}
}
}
}
}
string honorData = await LCURequest("/lol-honor-v2/v1/ballot", HttpMethod.Get);
JObject json = JObject.Parse(honorData);
if (honorData != "")
{
string[] honorCategory = { "COOL", "SHOTCALLER", "HEART" };
string honorDataBody = "{\"gameId\": " + json["gameId"].ToString() + ",\"honorCategory\": \"" + honorCategory[2] + "\",\"summonerId\": " + tempBestSummonerId + "}";
LCURequest("/lol-honor-v2/v1/honor-player", HttpMethod.Post, honorDataBody);
}
}
//honor end
//auto pick/ban start
string actorCellId = "";
List<string> bans = new List<string>();
List<string> championPickIntent = new List<string>();
int selectedChampionId = 0;
string assignedPosition = "";
if ((configData.autoPick || configData.autoBan || configData.autoPrePick) && currentSummoner.summonerId != null && gameFlow["phase"].ToString().ToLower() == "ChampSelect".ToLower())
{
List<int> championPlayable = new List<int>();
if (lolChampSelectV1Session != "")
{
JObject json = JObject.Parse(lolChampSelectV1Session);
foreach (var tempBan in json["bans"]["myTeamBans"])
{
bans.Add(tempBan.ToString());
}
foreach (var tempBan in json["bans"]["theirTeamBans"])
{
bans.Add(tempBan.ToString());
}
foreach (var prePickedChamp in json["myTeam"])
{
championPickIntent.Add(prePickedChamp["championPickIntent"].ToString());
}
foreach (var player in json["myTeam"])
{
if (player["summonerId"].ToString() == currentSummoner.summonerId.ToString())
{
actorCellId = player["cellId"].ToString();
selectedChampionId = Convert.ToInt32(player["championId"]);
assignedPosition = player["assignedPosition"].ToString();
}
}
foreach (var actions in json["actions"])
{
foreach (var team in actions)
{
if (team["actorCellId"].ToString() == actorCellId)
{
string jsonChampionsMinimal = await LCURequest("/lol-champions/v1/owned-champions-minimal", HttpMethod.Get, "");
if (jsonChampionsMinimal != "")
{
var ownedChampionsMinimal = JArray.Parse(jsonChampionsMinimal);
foreach (var champ in ownedChampionsMinimal)
{
//MessageBox.Show(champ["ownership"]["owned"].ToString());
if (champ["active"].ToString().ToLower() == "True".ToLower())
{
if ((champ["ownership"]["owned"].ToString().ToLower() == "true" || champ["freeToPlay"].ToString().ToLower() == "true") && champ["active"].ToString().ToLower() == "true")
{
championPlayable.Add(Convert.ToInt32(champ["id"]));
}
}
}
}
string isInProgress = team["isInProgress"].ToString();
//PICK
if (isInProgress == "True" && team["type"].ToString().Contains("pick") && configData.autoPick)
{
await Task.Delay(configData.pickDelay);
//get the champ based on prioritie and bans
int maxPrio = 0;
string champId = "";
foreach (var player in json["myTeam"])
{
if (championPlayable.Contains(Convert.ToInt32(player["championId"].ToString())) && currentSummoner.summonerId != player["summonerId"].ToString())
{
championPlayable.Remove(Convert.ToInt32(player["championId"].ToString()));
}
}
foreach (var player in json["theirTeam"])
{
if (championPlayable.Contains(Convert.ToInt32(player["championId"].ToString())))
{
championPlayable.Remove(Convert.ToInt32(player["championId"].ToString()));
}
}
foreach (championPick tempPick in configData.championPickList)
{
if (!bans.Contains(tempPick.Id.ToString()) && tempPick.Pick > maxPrio && championPlayable.Contains(tempPick.Id))
{
maxPrio = tempPick.Pick;
champId = tempPick.Id.ToString();
}
}
//build and make the pick request
string jsonDataForLock = "{ \"actorCellId\": " + actorCellId + ", \"championId\": " + champId + ", \"completed\": true, \"id\": " + team["id"].ToString() + ", \"isAllyAction\": true, \"type\": \"string\"}";
var resp = await LCURequest("/lol-champ-select/v1/session/actions/" + team["id"].ToString(), HttpMethod.Patch, jsonDataForLock);
}
//BAN
if (isInProgress == "True" && team["type"].ToString().Contains("ban") && configData.autoBan)
{
if (configData.banDelay != 0)
{
await Task.Delay(configData.banDelay);
}
//get the champ based on prioritie and bans
int maxPrio = 0;
string champId = "";
foreach (championPick tempBan in configData.championPickList)
{
if (!bans.Contains(tempBan.Id.ToString()) && !championPickIntent.Contains(tempBan.Id.ToString()) && tempBan.Ban > maxPrio)
{
maxPrio = tempBan.Ban;
champId = tempBan.Id.ToString();
}
}
//build and make the pick request
string jsonDataForLock = "{ \"actorCellId\": " + actorCellId + ", \"championId\": " + champId + ", \"completed\": true, \"id\": " + team["id"].ToString() + ", \"isAllyAction\": true, \"type\": \"string\"}";
var resp = await LCURequest("/lol-champ-select/v1/session/actions/" + team["id"].ToString(), HttpMethod.Patch, jsonDataForLock);
}
//pre pick
if (configData.autoPrePick && team["completed"].ToString() == "True")
{
await Task.Delay(configData.prePickDelay);
//get the champ based on prioritie and bans
int maxPrio = 0;
string champId = "";
foreach (championPick tempPick in configData.championPickList)
{
if (!bans.Contains(tempPick.Id.ToString()) && tempPick.Pick > maxPrio && championPlayable.Contains(tempPick.Id))
{
maxPrio = tempPick.Pick;
champId = tempPick.Id.ToString();
}
}
//build and make the pick request
//string jsonDataForLock = "{ \"actorCellId\": " + actorCellId + ", \"championId\": " + champId + ", \"completed\": true, \"id\": " + team["id"].ToString() + ", \"isAllyAction\": true, \"type\": \"string\"}";
string jsonDataForLock = "{ \"championId\": " + champId + "}";
jsonDataForLock = "{ \"actorCellId\": " + actorCellId + ", \"championId\": " + champId + ", \"completed\": false, \"id\": " + team["id"].ToString() + ", \"isAllyAction\": true, \"type\": \"string\"}";
var resp = await LCURequest("/lol-champ-select/v1/session/actions/" + team["id"].ToString(), HttpMethod.Patch, jsonDataForLock);
}
//if (isInProgrss == "True" && team["type"].ToString().Contains("ban") && !bans.Contains(instaLockChampId) && checkBoxAutoBan.Checked)
//{
// string jsonDataForLock = "{ \"actorCellId\": " + actorCellId + ", \"championId\": " + instaLockChampId + ", \"completed\": true, \"id\": " + team["id"].ToString() + ", \"isAllyAction\": true, \"type\": \"string\"}";
// var resp = await LCURequest("/lol-champ-select/v1/session/actions/" + team["id"].ToString(), "PATCH", jsonDataForLock);
//}
}
}
}
string benchEnabled = json["benchEnabled"].ToString().ToLower();
//ARAM swap bench
if (configData.autoAramBenchSwap && benchEnabled != "false")
{
List<int> benchedChamps = new List<int>();
foreach (var id in json["benchChampionIds"])
{
benchedChamps.Add(Convert.ToInt32(id));
}
int maxPrio = 0;
string champId = "";
int currentChampionPrio = 0;
foreach (championPick tempPick in configData.championPickList)
{
if (tempPick.Id == selectedChampionId)
{
currentChampionPrio = Convert.ToInt32(tempPick.Aram);
}
if (!bans.Contains(tempPick.Id.ToString()) && tempPick.Aram > maxPrio && championPlayable.Contains(tempPick.Id) && benchedChamps.Contains(tempPick.Id))
{
maxPrio = tempPick.Aram;
champId = tempPick.Id.ToString();
}
}
//bench swap
if (champId != "" && currentChampionPrio < maxPrio)
{
var resp = await LCURequest("/lol-champ-select/v1/session/bench/swap/" + champId.ToString(), HttpMethod.Post);
}
}
//auto runes/ auto summoners
string currentChampionName = "";
if (configData.autoRunes || configData.autoSummoners)
{
foreach (champion champ in leagueOfLegendsChampions)
{
if (champ.key == selectedChampionId.ToString())
{
currentChampionName = champ.name;
}
}
}
//auto runes
//List<string> runes = new List<string>();
//if (configData.autoRunes && selectedChampionId != 0 && selectedChampionId.ToString() != lastRunePageBuilt)
//{
// string html = "";
// if (assignedPosition != "")
// {
// html = "https://u.gg/lol/champions/" + currentChampionName.ToLower() + "/build?rank=diamond_plus&role=" + assignedPosition;
// }
// else
// {
// html = "https://u.gg/lol/champions/" + currentChampionName.ToLower() + "/build?rank=diamond_plus";
// }
// lastRunePageBuilt = selectedChampionId.ToString();
// var agg = await LCURequest("/lol-perks/v1/currentpage", HttpMethod.Get);
// var currentRunePage = new JObject();
// string currentPageId = "";
// string currentPageEditable = "";
// if (!agg.Value.Contains("404"))
// {
// currentRunePage = JObject.Parse(agg.Value);
// currentPageId = currentRunePage["id"].ToString();
// currentPageEditable = currentRunePage["isEditable"].ToString().ToLower();
// }
// else
// {
// Random rnd = new Random();
// currentPageId = rnd.Next(10000, 100000).ToString();
// currentPageEditable = "true";
// }
// foreach (champion champ in leagueOfLegendsChampions)
// {
// if (champ.key == selectedChampionId.ToString() && currentPageEditable == "true")
// {
// string championName = champ.name;
// if (runeSource == "U.GG")
// {
// if (championName.ToLower().Contains("nunu"))
// {
// championName = "nunu";
// }
// //var node = htmlDoc.DocumentNode.SelectSingleNode("//head/title");
// string ClassToGet1 = "perk perk-active";
// string ClassToGet2 = "perk keystone perk-active";
// string ClassToGet3 = "shard shard-active";
// string splitRunes = "\\\"";
// string selector = "//div[contains(@class, '" + ClassToGet2 + "')]";
// var htmlDoc = new HtmlAgilityPack.HtmlDocument();
// HtmlWeb web = new HtmlWeb();
// htmlDoc = web.Load(html);
// htmlDoc.LoadHtml(htmlDoc.Text);
// var htmlNodes = htmlDoc.DocumentNode.SelectNodes(selector);
// foreach (HtmlNode node in htmlNodes)
// {
// //string frormed = node.InnerHtml.Split("alt");
// if (node.InnerHtml.Contains(ClassToGet2))
// {
// if (!runes.Contains(Regex.Split(node.InnerHtml, splitRunes)[Regex.Split(node.InnerHtml, splitRunes).Count() - 2]))
// {
// runes.Add(Regex.Split(node.InnerHtml, splitRunes)[Regex.Split(node.InnerHtml, splitRunes).Count() - 2]);
// }
// }
// }
// foreach (HtmlNode node in htmlDoc.DocumentNode.SelectNodes("//div[@class='" + ClassToGet1 + "']"))
// {
// if (!runes.Contains(Regex.Split(node.InnerHtml, splitRunes)[Regex.Split(node.InnerHtml, splitRunes).Count() - 2]))
// {
// runes.Add(Regex.Split(node.InnerHtml, splitRunes)[Regex.Split(node.InnerHtml, splitRunes).Count() - 2]);
// }
// }
// foreach (HtmlNode node in htmlDoc.DocumentNode.SelectNodes("//div[@class='" + ClassToGet3 + "']"))
// {
// runes.Add(Regex.Split(node.InnerHtml, splitRunes)[Regex.Split(node.InnerHtml, splitRunes).Count() - 2]);
// }
// runes.RemoveAt(runes.Count() - 1);
// runes.RemoveAt(runes.Count() - 1);
// runes.RemoveAt(runes.Count() - 1);
// //Console.WriteLine("Node Name: " + node.Name + "\n" + node.OuterHtml);
// string name = "";
// List<Tuple<string, string>> runePage = new List<Tuple<string, string>>();
// foreach (string perk in runes)
// {
// foreach (var style in runesReforged)
// {
// foreach (var slot in style["slots"])
// {
// foreach (var perkPage in slot["runes"])
// {
// name = perkPage["name"].ToString();
// if (perk.Contains(name))
// {
// runePage.Add(new Tuple<string, string>(perkPage["id"].ToString(), perkPage["name"].ToString()));
// }
// }
// }
// }
// foreach (var shard in shardsRunes)
// {
// if (perk.Contains(shard.Value))
// {
// runePage.Add(new Tuple<string, string>(shard.Key, shard.Value));
// }
// }
// }
// var resp = await LCURequest("/lol-perks/v1/styles", HttpMethod.Get);
// var styles = JArray.Parse(resp.Value);
// //set the runes
// //string boddy = "{\"autoModifiedSelections\":[],\"current\":true,\"id\":" + currentPageId + ",\"isActive\":true,\"isDeletable\":true,\"isEditable\":true,\"isValid\":true,\"lastModified\":" + currentRunePage["lastModified"] + ",\"name\":\"" + currentRunePage["name"] + "\",\"order\":0,\"primaryStyleId\":8000,\"selectedPerkIds\":[" + runePage.ToList()[0].Key + "," + runePage.ToList()[1].Key + "," + runePage.ToList()[2].Key + "," + runePage.ToList()[3].Key + "," + runePage.ToList()[4].Key + "," + runePage.ToList()[5].Key + "," + runePage.ToList()[6].Key + "," + runePage.ToList()[7].Key + "," + runePage.ToList()[8].Key + "],\"subStyleId\":8400}";
// string style1 = runePage[1].Item1.Substring(0, 2) + "00";
// string style2 = runePage[4].Item1.Substring(0, 2) + "00";
// if (style2.Substring(0, 1).Contains("9"))
// {
// style2 = "8000";
// }
// string lastModified = DateTime.Now.ToString("yyyyMMddHHmmssffff");
// string boddy = "{\"current\":true,\"id\":" + currentPageId + ",\"isActive\":true,\"isDeletable\":true,\"isEditable\":true,\"isValid\":true,\"lastModified\":" + lastModified + ",\"name\":\"" + "LOL Client TOOL" + "\",\"order\":0,\"primaryStyleId\":" + style1 + ",\"selectedPerkIds\":[" + runePage[0].Item1 + "," + runePage[1].Item1 + "," + runePage[2].Item1 + "," + runePage[3].Item1 + "," + runePage.ToList()[4].Item1 + "," + runePage.ToList()[5].Item1 + "," + runePage[6].Item1 + "," + runePage[7].Item1 + "," + runePage[8].Item1 + "],\"subStyleId\":" + style2 + "}";
// //string boddy = "{\"current\":true,\"id\":" + currentPageId + ",\"isActive\":true,\"isDeletable\":true,\"isEditable\":true,\"isValid\":true,\"lastModified\":" + currentRunePage["lastModified"] + ",\"name\":\"" + currentRunePage["name"] + "\",\"order\":0,\"selectedPerkIds\":[" + runePage[0].Item1 + "," + runePage[1].Item1 + "," + runePage[2].Item1 + "," + runePage[3].Item1 + "," + runePage.ToList()[4].Item1 + "," + runePage.ToList()[5].Item1 + "," + runePage[6].Item1 + "," + runePage[7].Item1 + "," + runePage[8].Item1 + "]}";
// //LCURequest("/lol-perks/v1/pages", HttpMethod.Post, boddy);
// LCURequest("/lol-perks/v1/pages/" + currentPageId, "DELETE");
// LCURequest("/lol-perks/v1/pages", HttpMethod.Post, boddy);
// }
// }