Phase 2 — Combat & Game Logic

Phase 2 added the core gameplay — turn-based fire mechanics, hit/miss detection, player elimination, and persistent stat tracking.

Architecture

  • Fire endpoint enforces full turn logic: validates game status, confirms it's the player's turn, checks coordinate bounds, and rejects duplicate shots
  • Turn advancement uses current_turn_index modulo active (non-eliminated) players sorted by turn_order, so eliminated players are automatically skipped
  • Hit/miss detection checks fired coordinates against all opponents' ship positions, and a player is eliminated when all their ships are hit
  • Player stats (wins, losses, total shots, hits, accuracy) are updated atomically when a game ends
  • Move history endpoint returns a chronological log of every shot with player_id, coordinates, result, and timestamp

My Contributions

Implemented the fire endpoint logic, coordinate validation, and the stats aggregation queries.

← Back to Portfolio