{"id":19300747,"url":"https://github.com/textgamex/paradoxpower","last_synced_at":"2025-06-16T04:37:49.015Z","repository":{"id":254090868,"uuid":"845452139","full_name":"textGamex/ParadoxPower","owner":"textGamex","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-02T06:50:18.000Z","size":115,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-03T09:08:44.919Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"F#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/textGamex.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-21T09:27:23.000Z","updated_at":"2025-01-02T06:50:21.000Z","dependencies_parsed_at":"2024-08-21T11:17:08.180Z","dependency_job_id":"9756d71d-6332-42f1-98ab-2f33724d6696","html_url":"https://github.com/textGamex/ParadoxPower","commit_stats":null,"previous_names":["textgamex/paradoxpower"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/textGamex%2FParadoxPower","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/textGamex%2FParadoxPower/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/textGamex%2FParadoxPower/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/textGamex%2FParadoxPower/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/textGamex","download_url":"https://codeload.github.com/textGamex/ParadoxPower/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240402609,"owners_count":19795769,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T23:15:43.348Z","updated_at":"2025-06-16T04:37:49.002Z","avatar_url":"https://github.com/textGamex.png","language":"F#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ParadoxPower\n\nA Paradox parser, used for parsing Paradox script files\n\n一个解析器, 用来解析 Paradox 脚本文件\n\n## Usage\n\nInstall `ParadoxPower` and  `ParadoxPower.CSharpExtensions`\n\n## Example\n\n```c#\nvar parser = new TextParser(filePath);\nif (parser.IsFailure)\n{\n    return;\n}\nvar rootNode = result.GetResult();\n\n// 或者\nif (!TextParser.TryParse(filePath, out var rootNode, out _))\n{\n    return;\n}\n```\n\n\n\n```c#\nvar text = \"\"\"\n    state={\n    \tid=1\n        name=\"STATE_1\" # Corsica\n\n        provinces={\n        \t3838 9851 11804 \n    \t}\n\t}\n\"\"\"\n\nvar rootNode = new TextParser(\"\", text).GetResult();\nif (!rootNode.TryGetNode(\"state\", out var stateNode))\n{\n    return;\n}\n\n// 获取 provinces 下所有元素\nvar provinces = new List\u003cint\u003e();\nif (stateNode.TryGetNode(\"provinces\", out var provincesNode))\n{\n    foreach (var item in provincesNode.LeafValues)\n    {\n        if (int.TryParse(item.ValueText, out int provinceId))\n        {\n            provinces.Add(provinceId);\n        }\n    }\n}\n\n// 获取 Id\nif (stateNode.TryGetLeaf(\"id\", out var leaf))\n{\n    string id = leaf.ValueText;\n}\n// 或者 (不推荐)\n// string id = stateNode.GetLeaf(\"id\")!.Value.ValueText;\n\n// 输出 State 下所有元素的 Key\nforeach (var child in stateNode.AllArray)\n{\n    if (child.TryGetNode(out var node))\n    {\n        Console.WriteLine(node.Key);\n    }\n    else if (child.TryGetLeaf(out var leafChild))\n    {\n        Console.WriteLine(leafChild.Key);\n    }\n}\n\n// 修改id为2\nleaf.Value = Types.Value.NewInt(2);\n\n// 修改 name 为 \"STATE_2\"\nif (stateNode.TryGetLeaf(\"name\", out var nameLeaf))\n{\n\tnameLeaf.Value = Types.Value.NewQString(\"STATE_2\");\n}\n\n// rootNode转化为脚本字符串\nstring output = rootNode.ToScript();\nConsole.WriteLine(output);\n```\n\n\n\nAbout Color\n\n```c#\n// 关于颜色, 其中 \"rgb\" 被划分为了 color 节点下的 Leaf, 而在 CWTools 中 rgb 在 AST 中是不存在的\nvar color = \"color = rgb { 255 1 1 }\";\n```\n\n## Used Project\n\n- [VModer: HOI4 vscode extension](https://github.com/textGamex/VModer)\n\n## Supported Games\n\n- Europa Universalis IV (欧陆风云4)\n- Hearts of Iron IV (钢铁雄心4)\n- Victoria (维多利亚)\n- Stellaris (群星)\n\n## Thanks\n\nThis project is built upon [CWTools](https://github.com/cwtools/cwtools), and it would not have been possible without the foundation provided by [CWTools](https://github.com/cwtools/cwtools).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftextgamex%2Fparadoxpower","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftextgamex%2Fparadoxpower","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftextgamex%2Fparadoxpower/lists"}