npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

jubensha-sdk

v0.1.6

Published

Multiplayer Online Script Murder Game SDK

Readme

Jubensha SDK (剧本杀 SDK)

这是一个用于快速开发多人在线剧本杀游戏(Jubensha)的 TypeScript SDK。它提供了房间管理、游戏流程控制和状态同步的核心功能。

特性

  • 房间管理: 创建、加入、离开房间。
  • 游戏流程控制: 管理游戏阶段(阅读、搜证、投票等)。
  • 状态同步: 基于事件的实时状态更新。
  • TypeScript 支持: 完整的类型定义。
  • 模拟网络层: 内置 Mock 网络层,方便本地开发调试。

安装

使用 pnpm 安装:

pnpm install jubensha-sdk

(注意:本项目目前为本地开发包,尚未发布到 npm registry)

快速开始

1. 初始化客户端

import { JubenshaClient } from 'jubensha-sdk';

const client = new JubenshaClient({
  serverUrl: 'ws://localhost:8080', // 游戏服务器地址
  debug: true
});

// 连接服务器
await client.connect();

2. 房间管理

创建房间

// 创建一个容纳 6 人的房间,使用剧本 'script_001'
const roomId = await client.room.createRoom('script_001', 6);
console.log(`Room created: ${roomId}`);

加入房间

await client.room.joinRoom(roomId, 'PlayerName');

监听房间事件

client.room.on('left', () => {
  console.log('Left the room');
});

3. 游戏流程控制

开始游戏

await client.game.startGame();

监听游戏阶段变化

import { GamePhase } from 'jubensha-sdk';

client.game.on('phaseChange', (phase: GamePhase) => {
  switch (phase) {
    case GamePhase.READING:
      console.log('进入阅读阶段');
      break;
    case GamePhase.SEARCH:
      console.log('进入搜证阶段');
      break;
    case GamePhase.VOTE:
      console.log('进入投票阶段');
      break;
  }
});

推进游戏阶段

// 进入下一个阶段
await client.game.nextPhase();

4. 游戏操作

提交线索

// 发现线索 'clue_123'
await client.game.submitClue('clue_123');

监听状态更新

client.game.on('stateUpdate', (state) => {
  console.log('当前已发现线索:', state.cluesFound);
  console.log('当前回合:', state.round);
});

API 参考

JubenshaClient

  • connect(): 连接服务器。
  • disconnect(): 断开连接。
  • room: RoomManager 实例。
  • game: GameManager 实例。

RoomManager

  • createRoom(scriptId: string, maxPlayers: number): 创建房间。
  • joinRoom(roomId: string, playerName: string): 加入房间。
  • leaveRoom(): 离开房间。

GameManager

  • startGame(): 开始游戏。
  • nextPhase(): 进入下一阶段。
  • submitClue(clueId: string): 提交线索。
  • state: 当前 GameState 对象。

开发

构建

pnpm run build

开发模式 (监听文件变化)

pnpm run dev