diff --git a/Program.cs b/Program.cs
index 5fabe01..e1580c2 100644
--- a/Program.cs
+++ b/Program.cs
@@ -3,7 +3,9 @@
using Loly.src.Menus;
using Loly.src.Menus.Core;
using Loly.src.Tasks;
+using Loly.src.Tools;
using Loly.src.Variables;
+using Loly.src.Variables.Enums;
namespace Loly;
@@ -11,6 +13,8 @@ internal class Program
{
private static void Main()
{
+ AppDomain.CurrentDomain.UnhandledException += UnhandledException;
+
Settings.SetDefaultSettings();
Settings.CreateOrUpdateSettings();
@@ -29,4 +33,9 @@ private static void Main()
Interface.ShowArt();
MainMenu.StartMenu();
}
+
+ private static void UnhandledException(object sender, UnhandledExceptionEventArgs e)
+ {
+ Utils.LogNewError("Unhandled exception", LogModule.Loly, (Exception)e.ExceptionObject);
+ }
}
\ No newline at end of file
diff --git a/README.md b/README.md
index d0d23e7..f16e1e2 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
A set of several small tools for League Of Legends.
-### Works with the latest `14.4` update of League of Legends ([Patch Notes : 14.5](https://na.leagueoflegends.com/en-us/news/game-updates/patch-14-5-notes/))
+### Works with the latest `14.5` update of League of Legends ([Patch Notes : 14.5](https://na.leagueoflegends.com/en-us/news/game-updates/patch-14-5-notes/))

## `❗ Usage`
@@ -28,6 +28,9 @@ No need to install this if you have a more recent version installed.
More features coming soon...
## `📷 Screenshots`
+
+Click here to see all screenshots...
+
### Updater Menu
See screenshot...
@@ -64,6 +67,8 @@ More features coming soon...
+
+
## `❓ Bugs report / Suggestions`
If you want to report a bug or suggest a feature, you can open an issue [here](https://github.com/devRael1/LolyTools/issues) or contact me on Discord.
My Discord: `1043813027205619804`
diff --git a/Version.cs b/Version.cs
index 1b98480..d8c62a0 100644
--- a/Version.cs
+++ b/Version.cs
@@ -11,7 +11,7 @@ public static class Version
public static string FullVersionNoStage => $"{Major}.{Minor}.{Hotfix}";
private static int Major => 2;
- private static int Minor => 1;
+ private static int Minor => 2;
private static int Hotfix => 0;
}
}
diff --git a/src/Logs/Logger.cs b/src/Logs/Logger.cs
index f3c36f9..6405d46 100644
--- a/src/Logs/Logger.cs
+++ b/src/Logs/Logger.cs
@@ -179,10 +179,10 @@ private static void ExecuteLogRequest(IRequest valueOfRequest)
{
if (!string.IsNullOrWhiteSpace(request.Method) || !string.IsNullOrWhiteSpace(request.Url))
{
- contentFile.Append($"Request to API - Endpoint: {request.Url} - Method: {request.Method}");
+ contentFile.Append($"Request to API > Endpoint: {request.Url} - Method: {request.Method}");
if (!string.IsNullOrWhiteSpace(request.Body))
{
- contentFile.Append($"- Payload: {request.Body}");
+ contentFile.Append($" - Payload: {request.Body}");
}
}
}
@@ -191,10 +191,10 @@ private static void ExecuteLogRequest(IRequest valueOfRequest)
{
if (!string.IsNullOrWhiteSpace(response.Method))
{
- contentFile.Append($"Response from API - Status: {response.StatusCode} - Method: {response.Method}");
+ contentFile.Append($"Response from API > Endpoint: {response.Url} - Status: {response.StatusCode} - Method: {response.Method}");
if (response.Data != null)
{
- contentFile.Append($"- Response: {response.Data[1]}");
+ contentFile.Append($" - Response: {response.Data[1]}");
}
}
}
diff --git a/src/Tasks/Scheduled/AnalyzeSessionTask.cs b/src/Tasks/Scheduled/AnalyzeSessionTask.cs
index bf063fd..50838b5 100644
--- a/src/Tasks/Scheduled/AnalyzeSessionTask.cs
+++ b/src/Tasks/Scheduled/AnalyzeSessionTask.cs
@@ -20,79 +20,72 @@ public static void AnalyzeSession()
string[] gameSession = Requests.ClientRequest("GET", "lol-gameflow/v1/gameflow-phase", true);
if (gameSession[0] == "200")
{
- string phase = gameSession[1].Replace("\\", "").Replace("\"", "");
- if (Global.Session != phase)
- {
- Global.Session = phase;
- }
-
+ SessionPhase phase = (SessionPhase)Enum.Parse(typeof(SessionPhase), gameSession[1].Replace("\\", "").Replace("\"", ""));
+ if (Global.Session != phase) Global.Session = phase;
HandlePhaseLogic(phase);
}
}
}
- private static void HandlePhaseLogic(string phase)
+ private static void HandlePhaseLogic(SessionPhase phase)
{
switch (phase)
{
- case "Lobby":
+ case SessionPhase.Lobby:
Global.FetchedPlayers = false;
Global.AcceptedCurrentMatch = false;
- Global.ChampSelectInProgress = false;
Thread.Sleep(TimeSpan.FromSeconds(5));
break;
- case "Matchmaking":
+ case SessionPhase.Matchmaking:
Global.FetchedPlayers = false;
- Global.ChampSelectInProgress = false;
+ Global.AcceptedCurrentMatch = false;
Thread.Sleep(TimeSpan.FromSeconds(5));
break;
- case "ReadyCheck":
+ case SessionPhase.ReadyCheck:
HandleReadyCheckPhase();
+ Thread.Sleep(TimeSpan.FromSeconds(1));
break;
- case "ChampSelect":
+ case SessionPhase.ChampSelect:
HandleChampSelectPhase();
Thread.Sleep(TimeSpan.FromSeconds(5));
break;
- case "InProgress":
+ case SessionPhase.InProgress:
Thread.Sleep(TimeSpan.FromSeconds(10));
break;
- case "WaitingForStats":
+ case SessionPhase.WaitingForStats:
Thread.Sleep(TimeSpan.FromSeconds(15));
break;
- case "PreEndOfGame":
+ case SessionPhase.PreEndOfGame:
Thread.Sleep(TimeSpan.FromSeconds(10));
break;
- case "EndOfGame":
+ case SessionPhase.EndOfGame:
Thread.Sleep(TimeSpan.FromSeconds(15));
break;
- case "None":
- Global.ChampSelectInProgress = false;
+ case SessionPhase.None:
Global.FetchedPlayers = false;
+ Global.AcceptedCurrentMatch = false;
Thread.Sleep(TimeSpan.FromSeconds(5));
break;
default:
- Global.ChampSelectInProgress = false;
Global.FetchedPlayers = false;
+ Global.AcceptedCurrentMatch = false;
Thread.Sleep(TimeSpan.FromSeconds(10));
break;
}
- if (phase != "ChampSelect")
- {
- Global.LastChatRoom = "";
- }
+ if (phase != SessionPhase.ChampSelect) Global.LastChatRoom = "";
}
private static void HandleReadyCheckPhase()
{
Global.FetchedPlayers = false;
- Global.ChampSelectInProgress = false;
if (!Settings.AutoAccept)
{
Thread.Sleep(TimeSpan.FromSeconds(5));
return;
}
+
AutoAccept.AutoAcceptQueue();
}
@@ -101,24 +94,9 @@ private static void HandleChampSelectPhase()
// TODO: Create the detection of dodge champ select system
Global.AcceptedCurrentMatch = false;
- if (Settings.AutoAcceptOnce)
- {
- Settings.AutoAcceptOnce = false;
- Settings.AutoAccept = false;
- }
-
- if (Settings.LobbyRevealer && !Global.FetchedPlayers)
- {
- CreateTask(LobbyRevealer.GetLobbyRevealing, $"LobbyRevealing the current lobby", LogModule.Loly);
- }
-
- if (Settings.AutoChat || Settings.PicknBan)
- {
- CreateTask(ChampSelectSession.HandleChampSelect, $"ChampSelect session analyze", LogModule.Loly);
- }
-
- Thread.Sleep(TimeSpan.FromSeconds(2));
- Global.ChampSelectInProgress = true;
+ if (Settings.AutoAccept && Settings.AutoAcceptOnce) Settings.AutoAccept = false;
+ if (Settings.LobbyRevealer && !Global.FetchedPlayers) CreateBackgroundTask(LobbyRevealer.GetLobbyRevealing, $"LobbyRevealing the current lobby", LogModule.Loly);
+ if (Settings.AutoChat || Settings.PicknBan) ChampSelectSession.HandleChampSelect();
}
}
}
diff --git a/src/Tasks/Scheduled/LeagueClientTask.cs b/src/Tasks/Scheduled/LeagueClientTask.cs
index 946d696..72d3725 100644
--- a/src/Tasks/Scheduled/LeagueClientTask.cs
+++ b/src/Tasks/Scheduled/LeagueClientTask.cs
@@ -22,24 +22,19 @@ public static void LolClientTask()
Global.IsLeagueOpen = true;
Process client = Process.GetProcessesByName("LeagueClientUx").FirstOrDefault();
- if (Global.AuthClient.Count == 0 && Global.AuthRiot.Count == 0)
- {
- GetLeagueAuth();
- }
-
- LoadSummonerId(false);
+ if (Global.AuthClient.Count == 0 && Global.AuthRiot.Count == 0) GetLeagueAuth();
+ if (Global.SummonerLogged.SummonerId == null) LoadSummonerId();
if (Global.Region == "")
{
+ Logger.Info(LogModule.Loly, "Fetching region of your League Of Legends Client");
string response = Requests.WaitSuccessClientRequest("GET", "/riotclient/region-locale", true)[1];
PlayerRegion regionSplit = JsonConvert.DeserializeObject(response);
Global.Region = regionSplit.Region.ToLower();
+ Logger.Info(LogModule.Loly, $"Region fetched successfully : {Global.Region.ToUpper()}");
}
- if (!_lcuPid.Equals(client.Id))
- {
- _lcuPid = client.Id;
- }
+ if (!_lcuPid.Equals(client.Id)) _lcuPid = client.Id;
}
else
{
@@ -95,23 +90,15 @@ private static string Cmd(string gamename)
foreach (ManagementBaseObject managementBaseObject in mngmtClass.GetInstances())
{
ManagementObject o = (ManagementObject)managementBaseObject;
- if (o["Name"].Equals(gamename))
- {
- commandline = "[" + o["CommandLine"] + "]";
- }
+ if (o["Name"].Equals(gamename)) commandline = "[" + o["CommandLine"] + "]";
}
return commandline;
}
- private static void LoadSummonerId(bool force = false)
+ private static void LoadSummonerId()
{
- if (Global.SummonerLogged?.SummonerId != null && !force)
- {
- return;
- }
-
- Logger.Info(LogModule.Loly, "Getting your Summoner ID");
+ Logger.Info(LogModule.Loly, "Fetching your Summoner ID");
string[] currentSummoner = Requests.WaitSuccessClientRequest("GET", "lol-summoner/v1/current-summoner", true);
CurrentSummoner currentSum = JsonConvert.DeserializeObject(currentSummoner[1]);
@@ -124,7 +111,7 @@ private static void LoadSummonerId(bool force = false)
Global.SummonerLogged.AccountId = currentSum.AccountId;
Global.SummonerLogged.Puuid = currentSum.Puuid;
- Logger.Info(LogModule.Loly, $"Summoner ID loaded : {Global.SummonerLogged.SummonerId}");
+ Logger.Info(LogModule.Loly, $"Logged Summoner ID loaded : {Global.SummonerLogged.SummonerId}");
}
}
}
diff --git a/src/Tasks/ScheduledTask.cs b/src/Tasks/ScheduledTask.cs
index ae88c37..86efadf 100644
--- a/src/Tasks/ScheduledTask.cs
+++ b/src/Tasks/ScheduledTask.cs
@@ -35,7 +35,7 @@ public void Start()
{
if (runNow)
{
- Utils.CreateTask(taskAction, $"Task [{taskName}]", LogModule.Tasks);
+ Utils.CreateBackgroundTask(taskAction, $"Task [{taskName}]", LogModule.Tasks);
}
if (!infinite)
@@ -52,7 +52,7 @@ public void Stop()
private void TimerElapsed(object sender, ElapsedEventArgs e)
{
- Utils.CreateTask(taskAction, $"Task [{taskName}]", LogModule.Tasks);
+ Utils.CreateBackgroundTask(taskAction, $"Task [{taskName}]", LogModule.Tasks);
}
}
}
diff --git a/src/Tasks/TaskCore.cs b/src/Tasks/TaskCore.cs
index 8fbcdec..8b95301 100644
--- a/src/Tasks/TaskCore.cs
+++ b/src/Tasks/TaskCore.cs
@@ -10,23 +10,17 @@ public TaskCore()
{
_scheduledTasks.Add(new ScheduledTask(LeagueClientTask.LolClientTask, "LolClientTask", TimeSpan.FromSeconds(5), true, false));
_scheduledTasks.Add(new ScheduledTask(AnalyzeSessionTask.AnalyzeSession, "AnalyzeSession", TimeSpan.FromMinutes(1), true, true));
- _scheduledTasks.Add(new ScheduledTask(ClearLogsFilesTask.RunClearLogsFiles, "RunClearLogsFiles", TimeSpan.FromHours(2), true, false));
+ _scheduledTasks.Add(new ScheduledTask(ClearLogsFilesTask.RunClearLogsFiles, "RunClearLogsFiles", TimeSpan.FromHours(1), true, false));
}
public void StartAllTasks()
{
- foreach (ScheduledTask scheduledTask in _scheduledTasks)
- {
- scheduledTask.Start();
- }
+ foreach (ScheduledTask scheduledTask in _scheduledTasks) scheduledTask.Start();
}
public void StopAllTasks()
{
- foreach (ScheduledTask scheduledTask in _scheduledTasks)
- {
- scheduledTask.Stop();
- }
+ foreach (ScheduledTask scheduledTask in _scheduledTasks) scheduledTask.Stop();
}
}
}
diff --git a/src/Tools/AutoAccept.cs b/src/Tools/AutoAccept.cs
index 864a48c..6799f41 100644
--- a/src/Tools/AutoAccept.cs
+++ b/src/Tools/AutoAccept.cs
@@ -9,19 +9,17 @@ public class AutoAccept
{
public static void AutoAcceptQueue()
{
+ if (Global.AcceptedCurrentMatch) return;
+
string[] response = ClientRequest("POST", "lol-matchmaking/v1/ready-check/accept", true);
- if (response[0] != "200")
+ if (response[0] != "204")
{
- Logger.Info(LogModule.AutoAccept, "Failed to auto accept the current match");
- Logger.Info(LogModule.AutoAccept, "Check logs to get more informations.");
+ Logger.Warn(LogModule.AutoAccept, "Failed to auto accept the current match");
+ Logger.Warn(LogModule.AutoAccept, "Check Requests logs to get more informations.");
return;
}
- if (!Global.AcceptedCurrentMatch)
- {
- Logger.Info(LogModule.AutoAccept, "The current match has been auto accepted");
- }
-
+ Logger.Info(LogModule.AutoAccept, "The current match has been auto accepted");
Global.AcceptedCurrentMatch = true;
}
}
\ No newline at end of file
diff --git a/src/Tools/AutoChat.cs b/src/Tools/AutoChat.cs
index 0e40e80..a9501cc 100644
--- a/src/Tools/AutoChat.cs
+++ b/src/Tools/AutoChat.cs
@@ -11,7 +11,7 @@ public class AutoChat
public static void HandleChampSelectAutoChat()
{
- Logger.Info(LogModule.AutoChat, "Getting Chat & Summoner ID");
+ Logger.Info(LogModule.AutoChat, "Fetching Chat information & Summoner ID");
string[] myChatProfile = Requests.ClientRequest("GET", "lol-chat/v1/me", true);
ChatMe chatProfileJson = JsonConvert.DeserializeObject(myChatProfile[1]);
string currentChatId = chatProfileJson.Id;
@@ -38,7 +38,7 @@ public static void HandleChampSelectAutoChat()
count++;
}
- Thread.Sleep(attempts * 200);
+ Thread.Sleep(attempts * 100);
}
}
diff --git a/src/Tools/ChampSelectSession.cs b/src/Tools/ChampSelectSession.cs
index 35fa360..039f2eb 100644
--- a/src/Tools/ChampSelectSession.cs
+++ b/src/Tools/ChampSelectSession.cs
@@ -16,23 +16,16 @@ public class ChampSelectSession
public static bool CanSentMessages { get; set; }
public static long ChampSelectStart { get; set; }
public static InitRole CurrentRole { get; set; }
+ public static string AssignedRole { get; set; }
public static void HandleChampSelect()
{
- if (Global.ChampSelectInProgress)
- {
- return;
- }
-
string[] currentChampSelect = Requests.ClientRequest("GET", "lol-champ-select/v1/session", true);
- if (currentChampSelect[0] != "200")
- {
- return;
- }
+ if (currentChampSelect[0] != "200") return;
ChampSelectResponse champSelectResponse = JsonConvert.DeserializeObject(currentChampSelect[1]);
string currentChatRoom = champSelectResponse.ChatDetails.MultiUserChatId;
- if (Global.LastChatRoom != currentChatRoom || Global.LastChatRoom == "")
+ if (Global.LastChatRoom != currentChatRoom)
{
HoverPick = false;
LockedPick = false;
@@ -48,68 +41,56 @@ public static void HandleChampSelect()
{
Logger.Info(LogModule.PickAndBan, "Pick and Ban are locked. Waiting for game to start");
Thread.Sleep(TimeSpan.FromSeconds(10));
+ return;
}
- else
- {
- List myTeam = champSelectResponse.MyTeam;
- foreach (MemberTeam member in myTeam)
- {
- if (!member.SummonerId.Equals(Global.SummonerLogged.SummonerId))
- {
- continue;
- }
- string position = member.AssignedPosition;
- string assignedRole = position.ToLower() switch
- {
- "utility" => "Support",
- "middle" => "Mid",
- "jungle" => "Jungle",
- "bottom" => "Adc",
- "top" => "Top",
- _ => "Default"
- };
-
- CurrentRole = (InitRole)Settings.LoLRoles.GetType().GetProperty(assignedRole).GetValue(Settings.LoLRoles);
- Logger.Info(LogModule.PickAndBan, $"Assigned Role: {assignedRole}");
- break;
- }
+ List myTeam = champSelectResponse.MyTeam;
+ foreach (MemberTeam member in myTeam)
+ {
+ if (!member.SummonerId.Equals(Global.SummonerLogged.SummonerId)) continue;
- if (CurrentRole.PickChamp.Id == null)
+ string position = member.AssignedPosition;
+ string assignedRole = position.ToLower() switch
{
- HoverPick = true;
- LockedPick = true;
- }
+ "utility" => "Support",
+ "middle" => "Mid",
+ "jungle" => "Jungle",
+ "bottom" => "Adc",
+ "top" => "Top",
+ _ => "Default"
+ };
- if (CurrentRole.BanChamp.Id == null)
- {
- HoverBan = true;
- LockedBan = true;
- }
+ CurrentRole = (InitRole)Settings.LoLRoles.GetType().GetProperty(assignedRole).GetValue(Settings.LoLRoles);
+ break;
+ }
- if (Settings.AutoChat && Settings.ChatMessages.Count > 0)
- {
- if (Global.LastChatRoom != currentChatRoom)
- {
- CanSentMessages = true;
- }
- }
+ if (CurrentRole.PickChamp.Id == null)
+ {
+ HoverPick = true;
+ LockedPick = true;
+ }
- Global.LastChatRoom = currentChatRoom;
+ if (CurrentRole.BanChamp.Id == null)
+ {
+ HoverBan = true;
+ LockedBan = true;
+ }
- if (Settings.AutoChat && CanSentMessages)
- {
- CreateTask(AutoChat.HandleChampSelectAutoChat, $"Sending Auto Chat messages", LogModule.AutoChat);
- }
+ if (Settings.AutoChat && Settings.ChatMessages.Count > 0)
+ {
+ if (Global.LastChatRoom != currentChatRoom) CanSentMessages = true;
+ }
- if (!HoverPick || !LockedPick || !HoverBan || !LockedBan)
- {
- PicknBan.ChampSelectResponse = champSelectResponse;
- CreateTask(PicknBan.HandleChampSelectActions, $"Handling Pick and Ban", LogModule.PickAndBan);
- }
+ Global.LastChatRoom = currentChatRoom;
- CanSentMessages = false;
+ if (Settings.AutoChat && CanSentMessages) AutoChat.HandleChampSelectAutoChat();
+ if (!HoverPick || !LockedPick || !HoverBan || !LockedBan)
+ {
+ PicknBan.ChampSelectResponse = champSelectResponse;
+ PicknBan.HandleChampSelectActions();
}
+
+ CanSentMessages = false;
}
}
}
diff --git a/src/Tools/LobbyRevealer.cs b/src/Tools/LobbyRevealer.cs
index 2bff49c..b3d3bd4 100644
--- a/src/Tools/LobbyRevealer.cs
+++ b/src/Tools/LobbyRevealer.cs
@@ -14,27 +14,21 @@ public class LobbyRevealer
public static void GetTokenOpGg()
{
Logger.Info(LogModule.LobbyRevealer, "Fetching OP.GG token");
- string response = Requests.WebRequest("www.op.gg/multisearch", false);
+ string response = Requests.WebRequest("www.op.gg", false);
OpGGToken = Utils.LrParse(response, "\"buildId\":\"", "\",\"assetPrefix") ?? "null";
Logger.Info(LogModule.LobbyRevealer, $"Fetching OP.GG token successfully (Token: {OpGGToken})");
}
public static void GetLobbyRevealing()
{
- if (Global.ChampSelectInProgress)
- {
- return;
- }
-
if (OpGGToken == null)
{
GetTokenOpGg();
}
GetPlayers(Requests.ClientRequest("GET", "/chat/v5/participants/lol-champ-select", false)[1]);
- Utils.CreateTask(GetAdvancedPlayersStats, "Fetching Advanced player stats !", LogModule.LobbyRevealer);
-
Global.FetchedPlayers = true;
+ GetAdvancedPlayersStats();
}
public static void GetPlayers(string req)
@@ -79,7 +73,7 @@ public static void GetPlayers(string req)
public static void GetAdvancedPlayersStats()
{
- Logger.Info(LogModule.LobbyRevealer, $"Getting advanced stats of {Global.PlayerList.Count} players in background...");
+ Logger.Info(LogModule.LobbyRevealer, $"Fetching advanced stats of {Global.PlayerList.Count} players in background...");
Parallel.ForEach(Global.PlayerList, player =>
{
diff --git a/src/Tools/PicknBan.cs b/src/Tools/PicknBan.cs
index 5b1b2e5..6f97758 100644
--- a/src/Tools/PicknBan.cs
+++ b/src/Tools/PicknBan.cs
@@ -9,6 +9,11 @@ namespace Loly.src.Tools;
public class PicknBan
{
public static ChampSelectResponse ChampSelectResponse { get; set; }
+ private enum ActionType
+ {
+ Pick,
+ Ban
+ }
public static void HandleChampSelectActions()
{
@@ -17,144 +22,97 @@ public static void HandleChampSelectActions()
{
foreach (Action action in arrActions)
{
- if (action.ActorCellId != ChampSelectResponse.LocalPlayerCellId || action.Completed)
- {
- continue;
- }
-
- if (action.Type == "pick")
- {
- HandlePickAction(action);
- }
-
- if (action.Type == "ban")
- {
- HandleBanAction(action);
- }
+ if (action.ActorCellId != ChampSelectResponse.LocalPlayerCellId || action.Completed) continue;
+ if (action.Type == "pick") HandlePickAction(action);
+ if (action.Type == "ban") HandleBanAction(action);
}
}
}
private static void MarkPhaseStart(int actionId)
{
- if (actionId == Global.LastActionId)
- {
- return;
- }
-
+ if (actionId == Global.LastActionId) return;
Global.LastActionId = actionId;
}
private static void HandlePickAction(Action action)
{
- if (ChampSelectSession.CurrentRole.PickChamp.Id == null)
- {
- return;
- }
+ if (ChampSelectSession.CurrentRole.PickChamp.Id == null) return;
if (!ChampSelectSession.HoverPick)
{
string champSelectPhase = ChampSelectResponse.Timer.Phase;
long currentTime = DateTimeOffset.Now.ToUnixTimeMilliseconds();
- if (currentTime - 3000 > ChampSelectSession.ChampSelectStart || champSelectPhase != "PLANNING")
- {
- HoverChampion(action.Id, "pick");
- }
+ if (currentTime - 3000 > ChampSelectSession.ChampSelectStart || champSelectPhase != "PLANNING") HoverChampion(action.Id, ActionType.Pick);
}
- if (!action.IsInProgress)
- {
- return;
- }
+ if (!action.IsInProgress) return;
MarkPhaseStart(action.Id);
- if (ChampSelectSession.LockedPick)
- {
- return;
- }
+ if (ChampSelectSession.LockedPick) return;
Thread.Sleep(ChampSelectSession.CurrentRole.PickChamp.Delay);
- LockChampion(action.Id, "pick");
+ LockChampion(action.Id, ActionType.Pick);
}
private static void HandleBanAction(Action action)
{
- if (ChampSelectSession.CurrentRole.BanChamp.Id == null)
- {
- return;
- }
-
+ if (ChampSelectSession.CurrentRole.BanChamp.Id == null) return;
string champSelectPhase = ChampSelectResponse.Timer.Phase;
-
- if (!action.IsInProgress || champSelectPhase == "PLANNING")
- {
- return;
- }
+ if (!action.IsInProgress || champSelectPhase == "PLANNING") return;
MarkPhaseStart(action.Id);
- if (!ChampSelectSession.HoverBan)
- {
- HoverChampion(action.Id, "ban");
- }
-
- if (ChampSelectSession.LockedBan)
- {
- return;
- }
+ if (!ChampSelectSession.HoverBan) HoverChampion(action.Id, ActionType.Ban);
+ if (ChampSelectSession.LockedBan) return;
Thread.Sleep(ChampSelectSession.CurrentRole.BanChamp.Delay);
- LockChampion(action.Id, "ban");
+ LockChampion(action.Id, ActionType.Ban);
}
- private static void HoverChampion(int actionId, string actType)
+ private static void HoverChampion(int actionId, ActionType actionType)
{
- ChampItem champion = actType == "pick" ? ChampSelectSession.CurrentRole.PickChamp : ChampSelectSession.CurrentRole.BanChamp;
- Logger.Info(LogModule.PickAndBan, $"Hover '{champion.Name}' champion for {actType}");
+ ChampItem champion = actionType == ActionType.Pick ? ChampSelectSession.CurrentRole.PickChamp : ChampSelectSession.CurrentRole.BanChamp;
+ Logger.Info(LogModule.PickAndBan, $"Hover '{champion.Name}' champion for {actionType}");
string[] champSelectAction = Requests.ClientRequest("PATCH", $"lol-champ-select/v1/session/actions/{actionId}", true, $"{{\"championId\":{champion.Id}}}");
- if (champSelectAction[0] != "204")
- {
- return;
- }
+ if (champSelectAction[0] != "204") return;
- switch (actType)
+ switch (actionType)
{
- case "pick":
+ case ActionType.Pick:
ChampSelectSession.HoverPick = true;
break;
- case "ban":
+ case ActionType.Ban:
ChampSelectSession.HoverBan = true;
break;
}
- Logger.Info(LogModule.PickAndBan, $"'{champion.Name}' has been hovered for {actType}");
+ Logger.Info(LogModule.PickAndBan, $"'{champion.Name}' has been hovered for {actionType}");
+ int delay = actionType == ActionType.Pick ? ChampSelectSession.CurrentRole.PickChamp.Delay : ChampSelectSession.CurrentRole.BanChamp.Delay;
+ Logger.Info(LogModule.PickAndBan, $"Waiting {delay}ms to '{actionType}' him");
}
- private static void LockChampion(int actionId, string actType)
+ private static void LockChampion(int actionId, ActionType actionType)
{
- ChampItem champion = actType == "pick" ? ChampSelectSession.CurrentRole.PickChamp : ChampSelectSession.CurrentRole.BanChamp;
- Logger.Info(LogModule.PickAndBan, $"Locking '{champion.Name}' champion for {actType}");
+ ChampItem champion = actionType == ActionType.Pick ? ChampSelectSession.CurrentRole.PickChamp : ChampSelectSession.CurrentRole.BanChamp;
+ Logger.Info(LogModule.PickAndBan, $"Locking '{champion.Name}' champion for {actionType}");
string[] champSelectAction = Requests.ClientRequest("PATCH", $"lol-champ-select/v1/session/actions/{actionId}", true,
$"{{\"completed\":true,\"championId\":{champion.Id}}}");
- if (champSelectAction[0] != "204")
- {
- return;
- }
+ if (champSelectAction[0] != "204") return;
- switch (actType)
+ switch (actionType)
{
- case "pick":
+ case ActionType.Pick:
ChampSelectSession.LockedPick = true;
break;
- case "ban":
+ case ActionType.Ban:
ChampSelectSession.LockedBan = true;
break;
}
- Logger.Info(LogModule.PickAndBan, $"'{champion.Name}' has been locked for {actType}");
-
+ Logger.Info(LogModule.PickAndBan, $"'{champion.Name}' has been locked for {actionType}");
}
}
\ No newline at end of file
diff --git a/src/Tools/Requests.cs b/src/Tools/Requests.cs
index 51a76bf..4c9daea 100644
--- a/src/Tools/Requests.cs
+++ b/src/Tools/Requests.cs
@@ -49,19 +49,19 @@ public static string[] ClientRequest(string method, string url, bool useclient,
string responseFromServer = response.Content.ReadAsStringAsync().Result;
response.EnsureSuccessStatusCode();
- Logger.Request(new Response { Method = method, StatusCode = statusCode, Data = new[] { statusString, responseFromServer } });
+ Logger.Request(new Response { Method = method, Url = url, StatusCode = statusCode, Data = new[] { statusString, responseFromServer } });
response.Dispose();
return new[] { statusString, responseFromServer };
}
catch (HttpRequestException ex)
{
- Logger.Request(new Response { Method = method, StatusCode = 0, Exception = ex });
+ Logger.Request(new Response { Method = method, Url = url, StatusCode = Convert.ToInt32(ex.StatusCode), Exception = ex });
return new[] { "999", "" };
}
catch (Exception ex)
{
- Logger.Request(new Response { Method = method, StatusCode = 0, Exception = ex });
+ Logger.Request(new Response { Method = method, Url = url, StatusCode = 0, Exception = ex });
return new[] { "999", "" };
}
}
@@ -95,14 +95,14 @@ public static string WebRequest(string url, bool logResponse = true)
try
{
using HttpClient client = new();
+ client.DefaultRequestHeaders.UserAgent.ParseAdd(
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");
Logger.Request(new Request { Method = "GET", Url = url });
HttpResponseMessage response = client.GetAsync($"https://{url}").Result;
- if (!response.IsSuccessStatusCode)
- {
- return null;
- }
+ if (!response.IsSuccessStatusCode) return null;
+
HttpContent responseContent = response.Content;
string responseString = responseContent.ReadAsStringAsync().Result;
@@ -111,6 +111,7 @@ public static string WebRequest(string url, bool logResponse = true)
Logger.Request(new Response
{
Method = "GET",
+ Url = url,
StatusCode = (int)response.StatusCode,
Data = new[] { response.StatusCode.ToString(), logResponse ? responseString : "NOT LOGGED" }
});
@@ -119,12 +120,12 @@ public static string WebRequest(string url, bool logResponse = true)
}
catch (HttpRequestException ex)
{
- Logger.Request(new Response { Method = "GET", StatusCode = 0, Exception = ex });
+ Logger.Request(new Response { Method = "GET", Url = url, StatusCode = Convert.ToInt32(ex.StatusCode), Exception = ex });
return null;
}
catch (Exception ex)
{
- Logger.Request(new Response { Method = "GET", StatusCode = 0, Exception = ex });
+ Logger.Request(new Response { Method = "GET", Url = url, StatusCode = 0, Exception = ex });
return null;
}
}
diff --git a/src/Tools/Utils.cs b/src/Tools/Utils.cs
index d7ad674..a0625b4 100644
--- a/src/Tools/Utils.cs
+++ b/src/Tools/Utils.cs
@@ -56,8 +56,8 @@ public static string LrParse(string source, string left, string right, int innt
public static void LogNewError(string actionName, LogModule logModule, Exception ex)
{
Logger.Error(logModule, $"An error occured to execute : {actionName}", null);
- Logger.Error(logModule, "Please check the logs for more information.", null);
- Logger.Error(logModule, "Error message : ", ex);
+ Logger.Error(logModule, "Please check the logs file for more information.", null);
+ Logger.Error(logModule, "Error : ", ex);
}
public static string FormatStr(string str)
@@ -100,15 +100,12 @@ public static string FormatBytes(long bytes, bool seconds, int decimals = 2)
return $"{(bytes / Math.Pow(k, i)).ToString($"F{dm}")} {sizes[i]}{(seconds ? "/s" : "")}";
}
- public static void CreateTask(Action action, string errorMessage, LogModule logModule)
+ public static void CreateBackgroundTask(Action action, string errorMessage, LogModule logModule)
{
Task.Run(action)
.ContinueWith(t =>
{
- if (t.IsFaulted)
- {
- LogNewError(errorMessage, logModule, t.Exception);
- }
+ if (t.IsFaulted) LogNewError(errorMessage, logModule, t.Exception);
});
}
diff --git a/src/Variables/Class/Request.cs b/src/Variables/Class/Request.cs
index 95a9a00..7b481d3 100644
--- a/src/Variables/Class/Request.cs
+++ b/src/Variables/Class/Request.cs
@@ -3,6 +3,8 @@
public interface IRequest
{
public string Method { get; set; }
+ public string Url { get; set; }
+
public Exception Exception { get; set; }
}
@@ -17,6 +19,7 @@ public class Request : IRequest
public class Response : IRequest
{
public string Method { get; set; }
+ public string Url { get; set; }
public int StatusCode { get; set; }
public string[] Data { get; set; }
public Exception Exception { get; set; }
diff --git a/src/Variables/Enums/SessionPhase.cs b/src/Variables/Enums/SessionPhase.cs
new file mode 100644
index 0000000..8441521
--- /dev/null
+++ b/src/Variables/Enums/SessionPhase.cs
@@ -0,0 +1,15 @@
+namespace Loly.src.Variables.Enums
+{
+ public enum SessionPhase
+ {
+ Lobby,
+ Matchmaking,
+ ReadyCheck,
+ ChampSelect,
+ InProgress,
+ WaitingForStats,
+ PreEndOfGame,
+ EndOfGame,
+ None
+ }
+}
diff --git a/src/Variables/Global.cs b/src/Variables/Global.cs
index 72273cb..5c415b8 100644
--- a/src/Variables/Global.cs
+++ b/src/Variables/Global.cs
@@ -9,7 +9,7 @@ public class Global
public const string GithubPage = "https://github.com/devRael1/LolyTools";
public const string SoftName = "League of Legends - Loly Tools";
public const string SoftAuthor = "devRael";
- private static string _session = "";
+ private static SessionPhase _session = SessionPhase.None;
public static List PlayerList = new();
public static List ChampionsList = new();
@@ -25,10 +25,9 @@ public class Global
public static bool IsLeagueOpen { get; set; } = false;
public static bool LogsMenuEnable { get; set; } = false;
public static string Region { get; set; } = "";
- public static bool IsProdEnvironment { get; set; } = false;
- public static bool ChampSelectInProgress { get; set; } = false;
+ public static bool IsProdEnvironment { get; set; } = true;
- public static string Session
+ public static SessionPhase Session
{
get => _session;
set