Skip to content

refactor: trim project code and comments - #7

Merged
Barbatosishere merged 3 commits into
mainfrom
refactor/project-code-cleanup
Oct 10, 2026
Merged

Barbatosishere merged 3 commits into
mainfrom
refactor/project-code-cleanup

Conversation

@Barbatosishere

Copy link
Copy Markdown
Owner

Summary

  • Remove unused code, comments, compatibility wrappers, and dead configuration noise across the project.
  • Simplify chess, Go, landlord, multiplayer, rendering, resource, and file-management paths while preserving behavior.
  • Reduce search allocations in the built-in chess AI and unify landlord straight, pair-straight, and triple-straight search.
  • Analyze landlord card patterns once per play and keep atomic duplicate-card validation.

Validation

  • gradlew.bat build --no-daemon --no-configuration-cache --max-workers=1 --console=plain
  • 38 test suites, 258 tests, 0 failures, 0 errors, 0 skipped
  • NeoForge client validation: 15 checks passed
  • Landlord run comparison: 116,000 cases, 0 mismatches
  • Landlord full-game comparison: 80 games, 3,212 moves, 0 mismatches
  • Chess search comparison: 32 fixed-depth cases, 8 cancellation rollback cases, 0 mismatches
  • git diff --check

The original untracked docs/第十轮修复计划.md was intentionally left out of the commit.

@kilo-code-bot

kilo-code-bot Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Code Review Summary: PR #7 (refactor: trim project code and comments)

Overall: The refactor removes ~2000 lines of comments and dead code across 88 files. Test suite passes (258 tests), NeoForge checks pass, Landlord/Go regression tests pass. However, several semantic changes and API reductions introduce risk.


🔴 Critical Issues (Runtime/Logic Bugs)

1. ChessRules.legalMoves loses move type flag — Breaks AI & Simulation

File: src/main/java/com/wzz/game_console/client/screens/games/chess/ChessRules.java:174

-    public static List<Move> legalMoves(Board board, PieceColor color) {
+    public static List<int[]> legalMoves(Board board, PieceColor color) {

Changed return type from List<Move> (containing type, promotion, castling, enPassant flags) to raw int[] arrays. BuiltInChessAI and ChessSimulationMain depend on move type metadata for promotion handling, castling rights, and en passant detection. This will cause illegal move generation or crashes in AI/simulation.

2. PianoTilesScreen.resize() accumulates widgets on every resize

File: src/main/java/com/wzz/game_console/client/screens/games/PianoTilesScreen.java:142

@Override public void resize(Minecraft mc, int width, int height) {
    this.width = width; this.height = height;
    initWidgets();  // Adds new widgets without clearing old ones
}

Each resize call appends to widgets list → memory leak, duplicate event handlers, visual corruption. Must clear list first: widgets.clear(); initWidgets();.

3. flappy_bird.png is 115 bytes — likely corrupt/placeholder

File: src/main/resources/assets/game_console/textures/games/flappy_bird.png
Binary size 115 bytes is not a valid PNG. Game will crash or show missing texture on load.


🟠 High Risk (API Surface Reduction / Breaking Changes)

4. ExternalFileManager — 17 public methods removed

File: src/main/java/com/wzz/game_console/util/ExternalFileManager.java
Removed: getGameDir(), getRootDir(), listFiles(), readTextFile(), readBytes(), writeBytes(), getFilePath(), fileExists(), ensureSubFolder(), isSafeFileName().
Impact: Any external mod/code using these APIs will fail at runtime with NoSuchMethodError. If this is an internal-only utility, acceptable; otherwise needs deprecation cycle.

5. GameRenderHelper — 14 public methods removed

File: src/main/java/com/wzz/game_console/util/GameRenderHelper.java
Removed: drawBlueButton, drawRedButton, drawOutlinedCenteredText, drawTopHUD(GuiGraphics,int,int) (signature changed), drawCheckerboard, drawGrid, drawMenuLayout, calcScale, calcOffsetX, calcOffsetY, tickAndRenderParticles, drawExitConfirmOverlay, Particle/FloatingText helpers.
Impact: Games using these may break. drawTopHUD signature change already broke TicTacToeScreen (fixed in diff).

6. ResourceUtil — Complete rewrite drops version compatibility

File: src/main/java/com/wzz/game_console/util/ResourceUtil.java

-        return createResourceLocation(namespace, path);  // Reflection-based multi-version support
+        return ResourceLocation.fromNamespaceAndPath(namespace, path);  // Requires newer mappings

Old code handled multiple Minecraft/NeoForge version differences via reflection. New code assumes fromNamespaceAndPath exists. Will crash on older versions where this method is named differently.

7. ModNetworks.PacketHandlerCompat removed — All call sites migrated

File: src/main/java/com/wzz/game_console/init/ModNetworks.java
Compatibility layer deleted. All usages in LandlordGameScreen, GameConsoleItem updated to PacketDistributor.sendToServer/Player. Verify no missed call sites (grep for ModNetworks.PACKET_HANDLER).

8. NetworkHandler.java deleted

File: src/main/java/com/wzz/game_console/util/NetworkHandler.java (deleted)
Functionality inlined to direct PacketDistributor calls. Same verification needed.

9. LandlordGame.validateStatePhase signature changed — Parameter removed

File: src/main/java/com/wzz/game_console/client/screens/games/landlord/LandlordGame.java:595

-    validateStatePhase(..., parsedHand, parsedLastCards, parsedBottom);
+    validateStatePhase(..., parsedLastCards, parsedBottom);

Method definition drops hand parameter. If any external code calls this, it breaks. Appears internal only.


🟡 Medium Risk (Logic Simplification / Edge Cases)

10. CardPattern.canBeat — Bomb logic simplified

File: src/main/java/com/wzz/game_console/client/screens/games/landlord/CardPattern.java:563

-        if (type != Type.BOMB && other.type == Type.BOMB) return false;
-        if (type == other.type && length == other.length) return value > other.value;
-        return false;
+        return type == other.type && length == other.length && value > other.value;

Old logic: non-bomb cannot beat bomb; bomb beats non-bomb implicitly. New logic: bomb vs non-bomb returns false (type differs). This changes game rules — bombs should beat non-bombs. Likely a bug.

11. LandlordGame.playCards calls analyzePattern twice

File: src/main/java/com/wzz/game_console/client/screens/games/landlord/LandlordGame.java:159

CardPattern played = analyzePattern(cards);  // Line 159
if (!isValidPlay(played)) { ... }            // isValidPlay calls analyzePattern again inside

Minor performance hit. Refactor isValidPlay to accept pre-analyzed pattern.

12. GoSimulationRegressionTest / MCTSGoAIRegressionTest — Method signatures changed

Files: src/test/java/com/wzz/game_console/client/screens/games/gogame/GoSimulationRegressionTest.java:10872, MCTSGoAIRegressionTest.java:10911
Reflection calls updated to match new method signatures. Verify production code matches — tests may pass but production method signatures could diverge.


🟢 Low Risk (Cleanup / Comments)

  • README.md, build.gradle, gradle.properties: Comment/formatting cleanup only
  • MultiplayerLobbyScreen, TicTacToe*, GameScoreStore, ChessScreen, Match3GameScreen: Comment removal, no logic change
  • ChessAI, GoAI: Comment removal
  • Card, CardPattern: Comment simplification
  • GameSettings.getGameSettings removed (verified unused)
  • neoforge.mods.toml: Boilerplate comment removal

✅ Verified Safe

  • All 258 tests pass
  • NeoForge 15 checks pass
  • Landlord 116k regression cases: 0 mismatches
  • Chess search 32 cases: 0 mismatches
  • Network migration appears complete across LandlordGameScreen, GameConsoleItem, ClientPayloadHandler

Required Fixes Before Merge

  1. Restore ChessRules.legalMoves return type or update all consumers (BuiltInChessAI, ChessSimulationMain)
  2. Fix PianoTilesScreen.resize() to clear widget list before re-initializing
  3. Replace flappy_bird.png with valid texture
  4. Fix CardPattern.canBeat to allow bombs beating non-bombs
  5. Audit ResourceUtil for version compatibility — either restore reflection logic or document minimum NeoForge version
  6. Document breaking API changes in ExternalFileManager and GameRenderHelper

Recommendation: Do not merge as-is. Critical issues #1-3 must be fixed.


Reviewed by free · Input: 369K · Output: 11.2K · Cached: 656.9K

@Barbatosishere
Barbatosishere merged commit d6912fd into main Oct 10, 2026
2 checks passed
@Barbatosishere
Barbatosishere deleted the refactor/project-code-cleanup branch October 16, 2026 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant