Skip to content

Replace hardcoded piece catalog with registry pattern #58

Open
francinv opened this issue Apr 6, 2026 · 0 comments
Open

Replace hardcoded piece catalog with registry pattern #58

francinv opened this issue Apr 6, 2026 · 0 comments
Assignees

Comments

@francinv
Copy link
Member

francinv commented Apr 6, 2026

Piece types are hardcoded via switch/case and arrays in multiple files. Adding a new piece requires touching 7+ files with 16 side-effect touchpoints.

Hardcoded locations:

  • PieceFactory.java:26-57 — three separate switch blocks
  • SetupPaletteWidget.java:25-31PIECE_NAMES / PIECE_COSTS arrays
  • SetupBoardCodec.java:20-25, 52-70 — numeric codes + instanceof chain
  • GameOverlayManager.java:171-176 — hardcoded promotion names

What to do:

  • Create a piece registry that maps type name → class, cost, texture, codec
  • PieceFactory, SetupPaletteWidget, SetupBoardCodec, and GameOverlayManager should read from the registry instead of maintaining their own hardcoded lists
  • Adding a new piece type should require: one new class + one registry entry + sprite assets

Ref: Architecture doc claims M2 (add piece in <5h with no side effects).

@francinv francinv self-assigned this Apr 6, 2026
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant