Go Game (Drupal module)
=======================

Summary (<=200 chars)
---------------------
A plug-and-play multiplayer Go board for Drupal. Create a game, share an invite link, and play in near real time on a beautiful board—no extra services or complex setup required.

Overview
--------
Go Game lets you host and play the classic board game Go right on your Drupal site. It provides a modern, responsive board UI, lightweight real-time updates via REST polling, and a simple invite-link flow so anyone can join your game quickly.

Features
--------
- Create games and share a unique invite link (e.g., /go/abcdef12).
- Join via link; players automatically assigned Black/White.
- Modern canvas board: star points, shaded stones, last-move marker, responsive.
- Real-time updates with periodic polling (no external servers needed).
- Core rules: turn-taking, captures, suicide prevention, pass, resign.
- Finish detection on two consecutive passes (demo scoring placeholder).

Requirements
------------
- Drupal core 11 (or compatible 11.x).
- No extra Composer packages or external services required.

Installation
------------
1) Place this folder at: web/modules/custom/go_game (or modules/custom/go_game).
2) Enable the module via the Drupal UI (Extend) or Drush:

   Drush (zsh):
   drush en go_game -y
   drush cr

Uninstall
---------
- Uninstalling will drop the `go_game` table (if present). To keep existing data, disable instead of uninstalling.
  Drush (zsh):
  drush pmu go_game -y   # uninstall (drops table)
  drush pm:dis go_game -y  # disable only

Usage (Post-Installation)
-------------------------
- Go to /go to launch the game UI.
- Click "Create game" to generate a match and copy the invite link.
- Share the link; the first visitor becomes the opponent (White).
- The board updates every ~1.5s to keep both players in sync.
- Use Pass/Resign in the top bar. Two consecutive passes end the game.

Configuration and Permissions
-----------------------------
- No configuration pages are required.
- Pages provided:
  - /go        — Create and manage a game
  - /go/{id}   — Join or view a specific game by invite link
- Access: routes use the "access content" permission by default.

Technical Details
-----------------
- Module machine name: go_game
- Library: go_game/go-ui (loads JS and CSS)
- drupalSettings: goGame
- Data storage: `go_game` table stores game state (id, size, board JSON, turn, players, last_move, status, winner, passes, updated_at).

Routes (selected)
-----------------
Pages:
- GET /go                 → game launcher
- GET /go/{id}            → specific game by invite link

API:
- POST /go/api/create     → create a game (returns id, size, invite)
- POST /go/api/join       → join a game (assigns color)
- GET  /go/api/state/{id} → current game state
- POST /go/api/move       → place a stone (enforces captures/suicide)
- POST /go/api/pass       → pass turn; two passes finish game
- POST /go/api/resign     → resign and finish game

Limitations (Demo Rules)
------------------------
- Ko rule and full territory scoring are not implemented in this demo.
- "Winner: score" after two passes indicates the game finished without full scoring.
- Session-based identity assigns colors; integrating Drupal user accounts is possible.

Recommended Enhancements (Optional)
-----------------------------------
- WebSockets or Server-Sent Events (SSE) for instant, push-based updates.
- Persistent user accounts for named players and a game history view.
- Full rules: ko detection and territory scoring.

Similar Projects
----------------
- Other game modules may provide different board games or tournament features. This module focuses on a clean invite-link experience, modern UI, and minimal setup.

Support and Contributions
-------------------------
- Feedback, issues, and pull requests are welcome. Sponsorship or collaboration ideas are appreciated.

License
-------
- Unless otherwise noted, this module is provided under an open-source license compatible with Drupal.org norms.
