How shasnow/starrailassistant works
Project Overview
• SRA is an automation tool for the game “崩坏: 星穹铁道” that leverages image recognition and simulated user inputs to automate various in-game tasks (launching, reward collection, task automation, and more).
• The software is built in Python and uses a GUI (with PySide6/PyQt or similar libraries) and modularizes logic into separate components for core automation, extensions (like fun features or additional modules), utilities, and update mechanisms.
• There’s also integration with CI/CD pipelines via GitHub workflows, helping to automate tests and releases.
Main Components
a. Application Entry Point:
• SRA.py: The main script that launches the application.
b. Core Automation Engine:
• Modules under SRACore/core (e.g., SRAssistant.py, AutoPlot.py, SRACloud.py) that implement the main automation logic, game interaction, and possibly image recognition flows.
c. Extension Plugins:
• Modules inside SRACore/extensions (for example, FuXuanDivination.py and QTHandler.py) represent additional features. This area can be seen as plugin/extensions that enhance or customize behavior.
d. Utility Library:
• The SRACore/utils package (with modules like Configure.py, Dialog.py, Encryption.py, Logger.py, WindowsPower.py, and WindowsProcess.py) which provides common functionality such as configuration management, logging, error handling, encryption, and interacting with the underlying OS.
e. Updater:
• SRAUpdater.py and version.json indicate a built-in updater mechanism that handles self-updating based on version control.
f. Resources and UI Assets:
• The “res” folder holds images, UI layout files (e.g., .ui files from Qt Designer) which are used by the application’s graphical interface.
g. Packaging and Deployment:
• Files like package.py, requirements.txt, and tools (e.g., the 7z.exe in the tools folder) hint at packaging/deployment support.
h. CI/CD and Community Contributions:
• The presence of .github workspaces and workflows demonstrate automated build, test, and release pipelines.
Relationships and Interactions
• The user (or automated process) starts the application via SRA.py.
• SRA.py invokes the core modules (from SRACore/core) and coordinates with the extensions (from SRACore/extensions) to execute game automation tasks.
• Utilities (SRACore/utils) are used by both the core and extension modules to handle configuration, logging, and OS-level interactions (e.g., manipulating Windows processes or power states).
• The GUI and interface components, stored in the “res” directory, are loaded by the appropriate modules (likely mediated by QT or PySide calls) to display the automation interface.
• The updater (SRAUpdater.py) may run either before launch or as a separate process to check version.json and handle automatic updates.
• CI/CD pipelines (.github/workflows) run automated tests and release scripts based on changes in the repository.
Architectural Patterns and Design Principles
• Modularization: The clear separation into “core”, “extensions”, and “utils” helps to manage responsibilities.
• Plugin/Extension architecture: The use of extensions indicates that features can be added or modified with minimal changes to the core.
• Separation of Concerns: Dividing UI resources from business logic and update mechanism ensures clarity.
• Automation and CI/CD: GitHub workflows support continuous integration.
Technologies, Frameworks, and Tools
• Programming Language: Python.
• GUI Framework: Likely PySide6 or PyQt (as indicated by mentions in the README).
• Image recognition & simulated operations: Fundamental for the automation tasks (though the libraries are not directly named in the file tree, they are implied by functionality).
• Build/Package Tools: Requirements file and packaging scripts, along with external tools like 7z.exe.
• CI/CD: GitHub Actions workflows.
Final Advice for the Principal Software Engineer
• Break out the plugin/extensions as optional add-ons that interface with the core system.
• Encapsulate utilities as supporting layers that are shared by both the core and extensions.
• Do not forget to include the updater flow that connects version checking and update execution.
• Incorporate the CI/CD pipelines as a separate side-panel or integration point, linking to the development and deployment lifecycle.