Skip to content

Main Street: Grid-based street adjacency (distance-based) #777

Description

@SorraTheOrc

Problem statement

Main Street currently stores street cards in a 10-slot array but adjacency/synergy still behaves like a linear strip. The scene now renders a 2x5 board, so adjacency should be distance-based on that grid.

Users

  • Players: expect nearby cards on the 2x5 board to synergize consistently with visual layout.
  • Designers/QA: need deterministic, testable adjacency that matches board geometry.
  • Developers: need reusable mapping helpers from slot index to grid cell and distance-based neighbor calculation.

Success criteria

  1. Adjacency uses 2x5 grid coordinates (5 columns x 2 rows) instead of linear neighbors.
  2. Default synergy range (range=1) counts orthogonal neighbors by Manhattan distance (up/down/left/right), no diagonals.
  3. Extended range from upgrades (synergyRangeBonus) expands Manhattan radius correctly.
  4. Existing APIs remain stable for callers (neighbors, computeSynergyBonus, computeBusinessIncome, computeIncome, applyIncome).
  5. Unit tests cover edge/corner/middle cells, range extension, and asymmetry when only one business has upgraded range.
  6. Main Street regression suite passes (npm test and npm run build).
  7. Documentation explains the grid-distance adjacency model and migration notes for future balancing.

Constraints

  • Keep the streetGrid storage shape as a 10-slot array for compatibility.
  • Preserve deterministic behavior and avoid randomization changes.
  • Do not introduce breaking changes to scene or transcript formats.

Implementation approach

  • Implement index<->cell mapping helpers inside MainStreetAdjacency.ts.
  • Recompute neighbors(index, range) from Manhattan distance over 2x5 coordinates.
  • Update adjacency tests in tests/main-street/adjacency.test.ts to match the new geometry.
  • Update docs (docs/main-street/prd-milestone-4.md) with the grid-distance rule.

Related work

  • Parent milestone: Main Street: PRD Milestone 4 -- Visual Polish, Animation, and Audio (CG-0MM4RF91E1LR5RSY)
  • Discovered from: Unify card dimensions across UI (CG-0MO4NFMY4005DK66)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions