Multiplayer game builder

From abcnuts/manus-skills · View interactive version

Multiplayer game builder is an AI agent skill from the GitHub repository abcnuts/manus-skills. Build multiplayer turn-based games using template-based rapid development, TDD, and real-time Socket.IO integration. Use when creating card games, board games, or any turn-based multiplayer game with real-time synchronization.

How to use this skill

Skill file

Multiplayer Game Builder

Build multiplayer turn-based games from scratch using a proven workflow that combines template-based rapid development, Test-Driven Development (TDD), and real-time Socket.IO integration.

When to Use This Skill

Use this skill when building:

Core Principles

  1. Template-Based Rapid Development: Find and adapt existing open-source templates to save 50%+ development time
  2. Test-Driven Development: Write tests first, implement to pass tests, ensure high code quality
  3. Immutable State: Never mutate game state, always return new objects
  4. Progressive Implementation: Build in phases, test each before moving forward
  5. Comprehensive Documentation: Maintain implementation plans and execution logs

The Development Workflow

Phase 1: Research & Planning (1-2 days)

Research Game Rules

Deeply understand and document the complete rules. Create a rulebook that covers:

Find Similar Templates

Use the find_game_templates.py script to search GitHub:

python /home/ubuntu/skills/multiplayer-game-builder/scripts/find_game_templates.py "hearts card game"

Evaluate Templates

Use criteria from references/github-template-evaluation.md:

Create Implementation Plan

Use templates/implementation-plan-template.md to structure the project.

Phase 2: Core Game Logic (TDD) (1-2 weeks)

Follow strict Test-Driven Development. See references/tdd-workflow.md for detailed workflow.

Setup Test Infrastructure

Generate boilerplate test files:

python /home/ubuntu/skills/multiplayer-game-builder/scripts/generate_test_suite.py "my-game"

TDD Cycle for Each Module

For each game logic module (deck, bidding, playing, scoring):

  1. Write a failing test
  2. Run test to verify it fails
  3. Write minimal code to pass
  4. Run tests again to verify pass
  5. Refactor if needed
  6. Commit with clear message

Example: Deck Creation

// test/deck.test.js
it("should create a deck of 52 cards", () => {
  const deck = createDeck();
  assert.strictEqual(deck.length, 52);
});

// game-logic/deck.js
function createDeck() {
  // Implementation here
}

Validate Game State

During development, validate game state structure:

python /home/ubuntu/skills/multiplayer-game-builder/scripts/validate_game_state.py "game_state.json"

Key Modules to Implement

Phase 3: Real-Time Multiplayer (1 week)

Integrate game logic with Socket.IO. See references/socketio-patterns.md for patterns.

Setup Socket Handlers

Start with templates/socket-handler-template.js:

const games = {}; // In-memory game store

module.exports = function(io, socket) {
  socket.on("create_game", (data, ack) => {
    const gameId = generateId();
    games[gameId] = createGame();
    ack({ gameId });
  });
  
  socket.on("join_game", (data, ack) => {
    // Join logic
  });
  
  socket.on("play_card", (data) => {
    try {
      const game = games[data.gameId];
      const updatedGame = playCard(game, data.card, data.player);
      games[data.gameId] = updatedGame;
      io.to(data.gameId).emit("card_played", updatedGame);
    } catch (error) {
      socket.emit("error", { message: error.message });
    }
  });
};

Key Patterns

Phase 4: User Interface (1 week)

Build client-side interface that connects to Socket.IO.

UI Components

Client-Side Socket Integration

const socket = io();

socket.emit("join_game", { gameId, userId });

socket.on("card_played", (data) => {
  renderGameState(data);
});

$("#play-card-btn").click(() => {
  socket.emit("play_card", { gameId, card, player });
});

State Rendering

Update UI in real-time as server broadcasts state changes.

Phase 5: Polish & Production (1-2 weeks)

Game-Over Condition

Implement logic to end game and declare winner.

Persistence (Optional)

Integrate database (PostgreSQL, Redis) to save game state.

UI/UX Polish

Deployment

Deploy to production server with proper monitoring.

Best Practices

Immutable State Management

See references/game-state-management.md for patterns:

// Bad: Mutation
game.currentPlayer = nextPlayer;

// Good: Immutable
return { ...game, currentPlayer: nextPlayer };

Error Handling

Always wrap game logic in try/catch and emit errors to specific players.

Logging

Use templates/execution-log-template.md to track:

Common Game Patterns

See references/common-game-patterns.md for reusable patterns:

Resources

Scripts (scripts/):

Templates (templates/):

References (references/):

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.