打包计划
This plan details the steps to build a self-contained, ready-to-run Windows ZIP package for the refactored Genshin RPG project, including a slimmed-down MySQL instance, custom startup/shutdown scripts, and compiled binaries.
Proposed Changes
Section titled “Proposed Changes”We will construct the distribution in E:\AI\zcode\object\ke-she\dist\genshinrpg\.
1. File Structure and Components
Section titled “1. File Structure and Components”The main entry point for the user. It will call start_mysql.bat, compile/run the application, and call stop_mysql.bat upon exit.
Detects if port 3306 is open, dynamically generates my.ini with absolute paths mapping to the current folder, initializes MySQL if data/mysql is missing, starts mysqld.exe in the background, and polls the port until ready.
Attempts to read mysql/mysqld.pid and kill the process cleanly, or defaults to killing the local mysqld.exe process if the PID is not found.
Instructions for the end-user (requirements, launch steps, admin password, troubleshooting).
Standard ignore rules for runtime files (e.g., mysql/data/, mysql/my.ini, mysql/mysqld.pid).
2. MySQL Embedded Database (Slimming Down)
Section titled “2. MySQL Embedded Database (Slimming Down)”Copy E:\SQL\mysql\ to E:\AI\zcode\object\ke-she\dist\genshinrpg\mysql\ and apply the following slimming rules:
- Delete from
bin/:bin/*.pdb(~360MB total)- All
.exefiles exceptmysqld.exe. (Keepmysqld.exeand all.dllfiles in thebin/folder).
- Delete from
lib/:lib/*.lib(e.g.libmysql.lib,mysqlclient.lib,mysqlservices.lib)lib/private/
- Delete directories:
include/docs/
- Clean up
data/:- We will copy
E:\SQL\mysql\databut delete:binlog.*,*.err,*.pid,auto.cnf,ib_logfile*,ibdata1,undo_*,#innodb_temp,mysql.sock. - We will keep:
mysql/,genshin_rpg/(pre-created game DB),sys/,performance_schema/,*.pem,ib_buffer_pool.
- We will copy
3. Application Source and Dependencies
Section titled “3. Application Source and Dependencies”Copy all files from E:\AI\zcode\object\ke-she\refactored\src\ to E:\AI\zcode\object\ke-she\dist\genshinrpg\src\.
Copy mysql-connector-j-8.0.33.jar to E:\AI\zcode\object\ke-she\dist\genshinrpg\lib\.
Copy E:\C\cDownKeShe\db\genshin_rpg.sql to E:\AI\zcode\object\ke-she\dist\genshinrpg\db\.
Output folder for compiled classes. We will compile the sources here using javac.
4. Code Modification (DBConnector.java)
Section titled “4. Code Modification (DBConnector.java)”Modify only the database path resolution segment inside connectDB() to use relative paths instead of E:\SQL\mysql.
Verification Plan
Section titled “Verification Plan”Automated Verification / Testing
Section titled “Automated Verification / Testing”We will run a series of terminal tests in PowerShell:
- Compilation Check:
- Run
javac -encoding UTF-8 -d bin @sources.txtin the package root. Verify that compilation completes with0errors.
- Run
- Environment Simulation:
- Stop any existing local MySQL service (e.g. via taskkill or
net stop). - Run
start_mysql.batin a new CMD/PowerShell session and ensuremy.iniis generated correctly. - Run
stop_mysql.batand ensure the database shuts down.
- Stop any existing local MySQL service (e.g. via taskkill or
- Clean Database Boot:
- Delete
dist\genshinrpg\mysql\datacompletely and runrun.batto test the fallback initialization usingmysqld --initialize-insecure.
- Delete
Manual Verification
Section titled “Manual Verification”- Run the application using
run.bat. - Register a new user, log in, perform a battle, and verify that the data persists successfully to the local database.
- Exit the application, re-run
run.bat, and verify that the startup script detects the existing port and skips the initialization sequence. - Package the folder into a ZIP and check that the file size is under 50MB.
- Create
dist\PACK_NOTE.mddetailing the results.