From 2b77b040084939907eb28ab1f0a46d55bd1fc1ef Mon Sep 17 00:00:00 2001 From: Juzlus Date: Wed, 10 Jun 2026 14:20:22 +0200 Subject: [PATCH] update update_thanks --- .github/update_thanks.py | 4 +- .github/workflows/update_thanks.yml | 6 +- .../tools/RefactorSkills/Program.cs | 148 ------------------ .../RefactorSkills/RefactorSkills.csproj | 8 - 4 files changed, 5 insertions(+), 161 deletions(-) delete mode 100644 jRandomSkills - SRC Files/tools/RefactorSkills/Program.cs delete mode 100644 jRandomSkills - SRC Files/tools/RefactorSkills/RefactorSkills.csproj diff --git a/.github/update_thanks.py b/.github/update_thanks.py index 434ed95..544c873 100644 --- a/.github/update_thanks.py +++ b/.github/update_thanks.py @@ -14,7 +14,7 @@ DISCORD_USER_IDS = _env_list("DISCORD_USER_IDS") EXTRA_USERS_GITHUB = _env_list("EXTRA_USERS_GITHUB") CONTRIBUTORS_URL = "https://github.com/Juzlus/jRandomSkills/graphs/contributors" -AVATARS_DIR = "./avatars" +AVATARS_DIR = "./.github/avatars" AVATARS_RAW_URL = "https://raw.githubusercontent.com/Juzlus/jRandomSkills/main/.github/avatars" MARKER_GITHUB = "[CONTRIBUTORS]" @@ -213,7 +213,7 @@ def main(): print("Fetching Discord users...") discord_elements = get_discord_users(DISCORD_USER_IDS) - files = [("README.md", False), ("README-PL.md", True)] + files = [("readme.md", False), ("readme-pl.md", True)] for filename, is_pl in files: process_file(filename, github_elements, discord_elements, is_pl) diff --git a/.github/workflows/update_thanks.yml b/.github/workflows/update_thanks.yml index 806a3dc..9b39f76 100644 --- a/.github/workflows/update_thanks.yml +++ b/.github/workflows/update_thanks.yml @@ -27,14 +27,14 @@ jobs: - name: Run update script env: - DISCORD_USER_IDS: ${{ vars.DISCORD_USER_IDS }} - EXTRA_USERS_GITHUB: ${{ vars.EXTRA_USERS_GITHUB }} + DISCORD_USER_IDS: ${{ secrets.DISCORD_USER_IDS }} + EXTRA_USERS_GITHUB: ${{ secrets.EXTRA_USERS_GITHUB }} run: python .github/update_thanks.py - name: Commit changes run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - git add README.md README-PL.md .github/avatars/ + git add readme.md readme-pl.md .github/avatars/ git diff --cached --quiet || git commit -m "chore: update contributors and thanks" git push \ No newline at end of file diff --git a/jRandomSkills - SRC Files/tools/RefactorSkills/Program.cs b/jRandomSkills - SRC Files/tools/RefactorSkills/Program.cs deleted file mode 100644 index 5149960..0000000 --- a/jRandomSkills - SRC Files/tools/RefactorSkills/Program.cs +++ /dev/null @@ -1,148 +0,0 @@ -using System; -using System.IO; -using System.Text.RegularExpressions; - -var skillsDir = args.Length > 0 - ? args[0] - : Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..", "..", "..", "..", "src", "player", "skills")); - -if (!Directory.Exists(skillsDir)) -{ - Console.Error.WriteLine($"Skills directory not found: {skillsDir}"); - return 1; -} - -Console.WriteLine($"Refactoring skills in: {skillsDir}"); - -var skipFiles = new HashSet(StringComparer.OrdinalIgnoreCase) -{ - "OPTIMIZED_SKILL_TEMPLATE.cs", - "OPTIMIZATION_SUMMARY.cs" -}; - -var files = Directory.GetFiles(skillsDir, "*.cs"); -int updated = 0; - -foreach (var file in files) -{ - if (skipFiles.Contains(Path.GetFileName(file))) continue; - - var text = File.ReadAllText(file); - var original = text; - - text = ApplyRefactoring(text, file); - - if (text != original) - { - File.WriteAllText(file, text); - updated++; - Console.WriteLine($"Updated: {Path.GetFileName(file)}"); - } -} - -Console.WriteLine($"Refactor complete. Files updated: {updated}"); -return 0; - -static string ApplyRefactoring(string text, string filePath) -{ - // --- PlayerManager lookups (all FirstOrDefault variants) --- - text = Regex.Replace(text, - @"Instance\.SkillPlayer\.FirstOrDefault\(p => p\.SteamID == (\w+)\?\.SteamID\)", - "PlayerManager.GetPlayerByIndex($1.Index)"); - - text = Regex.Replace(text, - @"Instance\.SkillPlayer\.FirstOrDefault\(p => p\.SteamID == (\w+)\.SteamID\)", - "PlayerManager.GetPlayerByIndex($1.Index)"); - - text = Regex.Replace(text, - @"Instance\.SkillPlayer\.FirstOrDefault\([a-z]\s*=>\s*[a-z]\.SteamID\s*==\s*(\w+)\?\.SteamID\)", - "PlayerManager.GetPlayerByIndex($1.Index)"); - - text = Regex.Replace(text, - @"jRandomSkills\.Instance\.SkillPlayer\.FirstOrDefault\([a-z]\s*=>\s*[a-z]\.SteamID\s*==\s*(\w+)\?\.SteamID\)", - "PlayerManager.GetPlayerByIndex($1.Index)"); - - text = Regex.Replace(text, - @"jRandomSkills\.Instance\.SkillPlayer\.FirstOrDefault\([a-z]\s*=>\s*[a-z]\.SteamID\s*==\s*(\w+)\.Index\)", - "PlayerManager.GetPlayerByIndex($1.Index)"); - - text = Regex.Replace(text, - @"Instance\.SkillPlayer\.FirstOrDefault\([a-z]\s*=>\s*[a-z]\.Index\s*==\s*(\w+)\.Index\)", - "PlayerManager.GetPlayerByIndex($1.Index)"); - - text = Regex.Replace(text, - @"Instance\.SkillPlayer\.FirstOrDefault\([a-z]\s*=>\s*[a-z]\.Index\s*==\s*playerIndex\s*&&\s*[a-z]\.Skill\s*==\s*(\w+)\)", - "PlayerManager.GetPlayerByIndex(playerIndex) is { Skill: $1 } playerInfo ? playerInfo : null"); - - // --- ConcurrentDictionary ulong -> uint --- - text = Regex.Replace(text, @"ConcurrentDictionary<\s*ulong\s*,", "ConcurrentDictionary .Index for common player variables --- - foreach (var varName in new[] { "player", "enemy", "attacker", "victim", "target", "pl", "p", "e" }) - { - text = text.Replace($"{varName}.SteamID", $"{varName}.Index"); - } - - // --- ulong steamID local vars used as keys --- - text = Regex.Replace(text, @"ulong\s+steamID\s*=\s*(\w+)\.Index", "uint playerIndex = $1.Index"); - text = Regex.Replace(text, @"ulong\s+steamID\s*=\s*player\.Index", "uint playerIndex = player.Index"); - - // Replace steamID variable references with playerIndex when it was renamed - if (text.Contains("uint playerIndex = ")) - { - text = Regex.Replace(text, @"\bsteamID\b", "playerIndex"); - } - - // --- Remove bot restrictions from player filters --- - text = Regex.Replace(text, @"\s*&&\s*!p\.IsBot", "", RegexOptions.Multiline); - text = Regex.Replace(text, @"\s*&&\s*!(\w+)\.IsBot", "", RegexOptions.Multiline); - text = Regex.Replace(text, @"!p\.IsBot\s*&&\s*", "", RegexOptions.Multiline); - text = Regex.Replace(text, @"!(\w+)\.IsBot\s*&&\s*", "", RegexOptions.Multiline); - text = Regex.Replace(text, @"\|\|\s*(\w+)\.IsBot", "", RegexOptions.Multiline); - text = Regex.Replace(text, @"(\w+)\.IsBot\s*\|\|", "", RegexOptions.Multiline); - text = Regex.Replace(text, @"if\s*\([^)]*\.IsBot\)\s*continue;", "", RegexOptions.Multiline); - - // --- Menu enemy lookup: SteamID string -> index TryParse --- - text = Regex.Replace(text, - @"var\s+enemy\s*=\s*Utilities\.GetPlayers\(\)\.FirstOrDefault\(p\s*=>\s*p\.SteamID\.ToString\(\)\s*==\s*enemyId\)", - @"if (!uint.TryParse(enemyId, out uint enemyIndex)) { player.PrintToChat($"" {ChatColors.Red}"" + player.GetTranslation(""selectplayerskill_incorrect_enemy_index"")); return; } - var enemy = Utilities.GetPlayerFromIndex((int)enemyIndex)"); - - text = Regex.Replace(text, - @"var\s+enemy\s*=\s*Utilities\.GetPlayers\(\)\.FirstOrDefault\(p\s*=>\s*p\.Team\s*!=\s*player\.Team\s*&&\s*p\.Index\.ToString\(\)\s*==\s*enemyId\)", - @"if (!uint.TryParse(enemyId, out uint enemyIndex)) { player.PrintToChat($"" {ChatColors.Red}"" + player.GetTranslation(""selectplayerskill_incorrect_enemy_index"")); return; } - var enemy = Utilities.GetPlayerFromIndex((int)enemyIndex)"); - - // --- Add using src.utils if PlayerManager/EntityManager used but missing --- - if ((text.Contains("PlayerManager.") || text.Contains("EntityManager.")) - && !text.Contains("using src.utils;")) - { - var lastUsing = text.LastIndexOf("using ", StringComparison.Ordinal); - if (lastUsing >= 0) - { - var lineEnd = text.IndexOf('\n', lastUsing); - if (lineEnd >= 0) - text = text.Insert(lineEnd + 1, "using src.utils;\n"); - } - } - - // --- Null safety: common EnableSkill/DisableSkill entry points --- - if (text.Contains("public static void EnableSkill(CCSPlayerController player)") - && !text.Contains("if (player == null || !player.IsValid) return;") - && !text.Contains("if (player == null) return;")) - { - text = text.Replace( - "public static void EnableSkill(CCSPlayerController player)\n {", - "public static void EnableSkill(CCSPlayerController player)\n {\n if (player == null || !player.IsValid) return;"); - } - - if (text.Contains("public static void DisableSkill(CCSPlayerController player)") - && !Regex.IsMatch(text, @"DisableSkill\(CCSPlayerController player\)\s*\{[^}]*if \(player == null")) - { - text = text.Replace( - "public static void DisableSkill(CCSPlayerController player)\n {", - "public static void DisableSkill(CCSPlayerController player)\n {\n if (player == null) return;"); - } - - return text; -} diff --git a/jRandomSkills - SRC Files/tools/RefactorSkills/RefactorSkills.csproj b/jRandomSkills - SRC Files/tools/RefactorSkills/RefactorSkills.csproj deleted file mode 100644 index c76b054..0000000 --- a/jRandomSkills - SRC Files/tools/RefactorSkills/RefactorSkills.csproj +++ /dev/null @@ -1,8 +0,0 @@ - - - Exe - net8.0 - enable - enable - - \ No newline at end of file