starwards-colyseus

仓库创建 2019年3月17日最近提交 22 天前SkillHot 收录 20 天前
▸ 精选理由

明确服务端权威与状态变更模式,利于修复同步/竞态问题

这个 Skill 做什么

Colyseus 多人同步与房间架构、状态为单一可信源的开发规范

多人实时同步的老实规矩:把所有游戏状态放在服务端的单一“真相”上,客户端只收更新并发出命令。适用于用 Colyseus 架构房间、用装饰器定义 state、用 JSON Pointer 或命令修改状态的多人游戏,能避免常见的同步坑。特别强调 server-authoritative 模式和房间/状态设计规范,帮你写出稳定一致的游戏同步逻辑。

▸ 展开 SKILL.md 英文原文

Colyseus multiplayer patterns for Starwards - @gameField decorators, state sync, JSON Pointer commands, room architecture, and avoiding common Colyseus pitfalls; state is source of truth, server authoritative

垂直行业Colyseus状态同步多人联机通用
42
Stars
2
Forks
17
仓库内 Skill
+0
7 日增星
安装 / 使用
给你的 Agent 一句话(通用)
帮我安装这个 skill:https://raw.githubusercontent.com/starwards/starwards/master/.claude/skills/starwards-colyseus/SKILL.md
或 curl 直取 SKILL.md
curl -fsSL "https://raw.githubusercontent.com/starwards/starwards/master/.claude/skills/starwards-colyseus/SKILL.md"
SKILL.MD 节选查看完整文件 ↗
# Colyseus Multiplayer Patterns for Starwards

## Overview

Starwards uses Colyseus v0.15 for real-time multiplayer state synchronization. Understanding decorators, rooms, and state sync prevents bugs.

**Core principle:** State is the source of truth. Commands modify state. Clients receive automatic updates.

## Architecture

```
Client (Browser)
  ↓ WebSocket connection
Room (Server)
  ↓ owns
State (Schema)
  ↓ syncs to
Client State (Mirror)
```

**Flow:**
1. Client sends command → Room
2. Room modifies State
3. Colyseus patches → Client
4. Client state updates automatically
5. UI reacts to state changes

## The @gameField Decorator

**Purpose:** Marks properties for automatic Colyseus syn
via SKILL·HOT · 数据来自 GitHub 公开信息 · 原文版权归作者所有