WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

icco/gotak

Repository files navigation

GoTak

Tests CodeQL GoDoc Go Report Card

A complete Tak game server implementation in Go with REST API, database persistence, and comprehensive game logic.

Overview

GoTak is a production-ready server for the board game Tak, providing:

  • Complete Tak Game Logic: Full implementation of official Tak rules including road detection, piece limits, and win conditions
  • PTN Support: Parse and generate Portable Tak Notation (PTN) for game recording and replay
  • REST API: HTTP endpoints for game creation, move submission, and state retrieval
  • Database Persistence: PostgreSQL storage with automatic migrations
  • Web Interface: Dynamic home page with endpoint documentation
  • Developer Tools: Comprehensive testing, Swagger documentation, and CI/CD integration

Applications

The project includes three main applications:

  1. Web Server (./cmd/server) - Production HTTP API server
  2. CLI Tool (./cmd/gotak) - Command-line game demonstration
  3. PTN Parser (./cmd/parse-ptn) - Parse and validate PTN files

Quick Start

Running the Server

# Set database connection
export DATABASE_URL="postgres://user:password@localhost/gotak?sslmode=disable"

# Start the server
go run ./server

# Or build and run
go build -o gotak-server ./server
./gotak-server

The server will start on port 8080 and automatically run database migrations.

Running Tests

# Run all tests with coverage
go test -v -cover ./...

# Run specific package tests
go test -v ./server

Building Applications

# Build the main CLI tool
go build -o gotak ./cmd/gotak

# Build the PTN parser
go build -o parse-ptn ./cmd/parse-ptn

# Build the server
go build -o gotak-server ./server

API Usage

Create a New Game

curl -X POST http://localhost:8080/game/new \
  -H "Content-Type: application/json" \
  -d '{"size": "8"}'

Join a Game

curl -X POST http://localhost:8080/game/{slug}/join \
  -H "Authorization: Bearer YOUR_TOKEN"

Make a Move

curl -X POST http://localhost:8080/game/{slug}/move \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"player": 1, "move": "a1", "turn": 1}'

Get Game State

curl http://localhost:8080/game/{slug}

Architecture

  • Core Logic: Game rules, board state, and PTN parsing in root *.go files
  • Server: HTTP API with Chi router, middleware, and PostgreSQL storage
  • Database: Schema with games, moves, and tags tables
  • Security: Input sanitization, CORS, security headers
  • Documentation: Auto-generated Swagger docs with GitHub Actions integration

Development

See CLAUDE.md for detailed development commands and architecture information.

Inspirations

Sponsor this project