Skip to content

Latest commit

ย 

History

61 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Clod - Territorial Strategy Game

A grid-based multiplayer territorial strategy game built with TypeScript and Node.js. Players compete to control zones, collect resources, and defend against AI enemies in turn-based tactical gameplay.

๐ŸŽฎ Game Features

  • Territorial Control: Claim zones by occupying them for 5 turns with progressive moon phases ๐ŸŒ‘๐ŸŒ’๐ŸŒ“๐ŸŒ”๐ŸŒ•
  • Shop System: 9x9 interactive shop area with walk-to-buy mechanics and emoji pricing
  • Zone-Specific Rewards: Corner zones generate ๐Ÿ’Ž diamonds (3pts), side zones generate โšก energy/๐Ÿ’ฐ gold (2pts)
  • Powerup System: โšก Sprint, ๐Ÿงฒ Pull, ๐Ÿ›ก๏ธ Shield with energy costs and charge mechanics
  • Relic System: Passive upgrades available after turn 10 for advanced strategy
  • Event System: Real-time feedback on territory control, resource generation, and combat
  • AI Enemies: ๐Ÿ‘ป Scouts and ๐Ÿค– destroyers that move toward controlled zones
  • Multiplayer: Real-time WebSocket-based multiplayer support
  • Offline Mode: Single-player vs AI gameplay

๐Ÿ“‹ Quick Start

Prerequisites

  • Node.js 20+
  • npm 10+

Installation & Setup

# Clone and install
git clone <repository>
cd clod
npm install

# Build all packages
npm run build

# Quick commands (recommended)
npm run play           # Play offline (human vs AI)
npm run server         # Start multiplayer server
npm run create         # Create multiplayer game (will prompt for name)

# Advanced commands  
npm run dev:cli -- -- --offline                    # Play offline
npm run dev:cli -- -- --create --name "YourName"   # Create game with name
npm run dev:cli -- -- --join GAMEID --name "Name"  # Join existing game

๐Ÿ—๏ธ Architecture

This is a monorepo with separate packages:

clod/
โ”œโ”€โ”€ packages/
โ”‚   โ”œโ”€โ”€ game-engine/     # Core game logic & rules
โ”‚   โ”œโ”€โ”€ game-server/     # WebSocket multiplayer server
โ”‚   โ””โ”€โ”€ cli-client/      # Terminal game client
โ”œโ”€โ”€ shared/              # Common types & protocols
โ””โ”€โ”€ package.json         # Workspace configuration

Package Details

packages/game-engine

  • Purpose: Core game mechanics, state management, and rule validation
  • Key Files:
    • TerritorialGameEngine.ts - Main game logic
    • ConsoleUI.ts - Terminal rendering
    • types/game.ts - Game state interfaces
  • Features: Turn-based movement, zone control, resource spawning, enemy AI

packages/game-server

  • Purpose: Multiplayer game coordination via WebSocket
  • Key Files:
    • index.ts - HTTP + WebSocket server setup
    • GameServer.ts - Game session management
  • API:
    • POST /api/games - Create new game
    • GET /api/games - List active games
    • GET /health - Server health check

packages/cli-client

  • Purpose: Terminal-based game interface
  • Key Files:
    • index.ts - CLI argument parsing
    • GameClient.ts - Game state & server communication
  • Features: Single-char input, offline/online modes, WebSocket client

shared/

  • Purpose: Common types and constants
  • Contents: WebSocket protocols, game constants, shared interfaces

๐ŸŽฏ Gameplay Guide

Objective

Control zones to generate resources and accumulate points while defending against AI enemies.

Game Elements

Symbol Meaning
๐Ÿ”ต ๐Ÿ”ด Player 1 & 2
๐ŸŸซ๐ŸŸช๐ŸŸจ๐ŸŸฉ๐ŸŸง๐Ÿ”ฒ Unclaimed zones A-F (color-coded)
๐ŸŸฆ ๐ŸŸฅ Controlled zones (blue/red for each player)
๐Ÿ’Ž ๐Ÿ’ฐ Diamonds (3pts) & Gold (2pts) resources
๐Ÿ‘ป ๐Ÿค– Scout/Destroyer enemies
โฌ› Empty space

Controls

  • WASD: Move player
  • Q: Quit game

Rules

  1. Turn Structure: Each player gets 1 move, then time-step processes
  2. Zone Control: Stay in a zone for 5 turns to claim it with progressive moon phases ๐ŸŒ‘๐ŸŒ’๐ŸŒ“๐ŸŒ”๐ŸŒ•
  3. Guaranteed Resources: Controlled zones generate resources every turn (100% guaranteed!)
  4. Zone Rewards: ๐ŸŸซ๐ŸŸฉ corners=๐Ÿ’Ž(3pts), ๐ŸŸช๐ŸŸง sides=โšกenergy/๐Ÿ’ฐgold(2pts), ๐ŸŸจ๐Ÿ”ฒ strategic=๐Ÿ’ฐ(2pts)
  5. Shop System: Walk over items or prices in central 9x9 area to buy with gold
  6. Powerups: Use 1/2/3 keys to activate โšกSprint, ๐ŸงฒPull, ๐Ÿ›ก๏ธShield abilities
  7. Enemy Movement: AI enemies move toward controlled zones and steal resources
  8. Events: โšก RECENT EVENTS panel shows all turn actions and results
  9. Winning: 15 points OR control 4 zones simultaneously

๐Ÿ”ง Development

Building

npm run build              # Build all packages
npm run build -w <package> # Build specific package

Running

npm run dev:server         # Start game server (port 3001)
npm run dev:engine         # Watch game engine changes
npm run dev:cli            # Run CLI in development mode

Testing

# Test offline mode
npm run play

# Test multiplayer (requires server running)
npm run server        # Terminal 1: Start server
npm run create         # Terminal 2: Create game  
npm run dev:cli -- -- --join GAMEID --name "Player2"  # Terminal 3: Join game

๐ŸŒ Multiplayer Protocol

HTTP API

# Create game
POST /api/games
Body: { "playerName": "string" }
Response: { "gameId": "string", "message": "string" }

# List games  
GET /api/games
Response: [{ "id": "string", "playerCount": number, "spectatorCount": number, "createdAt": "string" }]

WebSocket Messages

Client โ†’ Server

{
  type: 'join' | 'move' | 'spectate',
  gameId?: string,
  playerName?: string, 
  direction?: 'w' | 'a' | 's' | 'd'
}

Server โ†’ Client

{
  type: 'game-state' | 'error' | 'player-joined' | 'player-left',
  data?: GameState,
  message?: string
}

๐Ÿ“ Project History

This project evolved through several iterations:

  1. Initial Concept: Card-based roguelike inspired by Balatro
  2. Pivot 1: Prisoner's dilemma puzzle mechanics
  3. Pivot 2: Resource collection with sharing bonuses
  4. Final Form: Territorial control with strategic zone management

Key design decisions:

  • Immutable State: Clean game state management for multiplayer
  • Separation of Concerns: Game logic isolated from UI/networking
  • Client/Server Architecture: Enables real-time multiplayer
  • Monorepo Structure: Shared dependencies while maintaining modularity

๐Ÿš€ Roadmap (from IDEAS.md)

Phase 1: Core Systems โœ… COMPLETE

  • Powerup System: โšกSprint, ๐ŸงฒPull, ๐Ÿ›ก๏ธShield with energy costs and charges
  • Shop System: 9x9 interactive area with walk-to-buy mechanics and auto-refresh
  • Win Conditions: Hybrid victory system (15 points OR 4 zones control)
  • Relic System: Passive modifiers available after turn 10 (implemented but needs expansion)

Phase 2: Enhanced Mechanics

  • Cooperative Collection: +50% bonus when near teammate
  • Enhanced Enemy System: ๐Ÿ‘ป๐Ÿค–๐Ÿ•ท๐Ÿ›ก with specific counters
  • Capture Rewards: Powerup/relic shards on zone capture

Phase 3: Advanced Features

  • Preview Panel: Show projected zone progress and income
  • Stage Modifiers: Fog, tremors, tax, resource scaling
  • Overcharge System: Bank energy for instant powerup use
  • ASCII Rendering: Mono-width mode for alignment reliability

๐Ÿ“ Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make changes in appropriate packages
  4. Build and test locally
  5. Submit a pull request

๐Ÿ“„ License

ISC License - See package.json for details

About

Terminal-based multiplayer territorial strategy game built mainly to learn Claude Code

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages