@gamerstake/game-core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +22 -0
- package/.testing-guide-summary.md +261 -0
- package/DEVELOPER_GUIDE.md +996 -0
- package/MANUAL_TESTING.md +369 -0
- package/QUICK_START.md +368 -0
- package/README.md +379 -0
- package/TESTING_OVERVIEW.md +378 -0
- package/dist/index.d.ts +1266 -0
- package/dist/index.js +1632 -0
- package/dist/index.js.map +1 -0
- package/examples/simple-game/README.md +176 -0
- package/examples/simple-game/client.ts +201 -0
- package/examples/simple-game/package.json +14 -0
- package/examples/simple-game/server.ts +233 -0
- package/jest.config.ts +39 -0
- package/package.json +54 -0
- package/src/core/GameLoop.ts +214 -0
- package/src/core/GameRules.ts +103 -0
- package/src/core/GameServer.ts +200 -0
- package/src/core/Room.ts +368 -0
- package/src/entities/Entity.ts +118 -0
- package/src/entities/Registry.ts +161 -0
- package/src/index.ts +51 -0
- package/src/input/Command.ts +41 -0
- package/src/input/InputQueue.ts +130 -0
- package/src/network/Network.ts +112 -0
- package/src/network/Snapshot.ts +59 -0
- package/src/physics/AABB.ts +104 -0
- package/src/physics/Movement.ts +124 -0
- package/src/spatial/Grid.ts +202 -0
- package/src/types/index.ts +117 -0
- package/src/types/protocol.ts +161 -0
- package/src/utils/Logger.ts +112 -0
- package/src/utils/RingBuffer.ts +116 -0
- package/tests/AABB.test.ts +38 -0
- package/tests/Entity.test.ts +35 -0
- package/tests/GameLoop.test.ts +58 -0
- package/tests/GameServer.test.ts +64 -0
- package/tests/Grid.test.ts +28 -0
- package/tests/InputQueue.test.ts +42 -0
- package/tests/Movement.test.ts +37 -0
- package/tests/Network.test.ts +39 -0
- package/tests/Registry.test.ts +36 -0
- package/tests/RingBuffer.test.ts +38 -0
- package/tests/Room.test.ts +80 -0
- package/tests/Snapshot.test.ts +19 -0
- package/tsconfig.json +28 -0
- package/tsup.config.ts +14 -0
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": [
|
|
3
|
+
"eslint:recommended",
|
|
4
|
+
"plugin:@typescript-eslint/recommended",
|
|
5
|
+
"plugin:@typescript-eslint/recommended-requiring-type-checking"
|
|
6
|
+
],
|
|
7
|
+
"parser": "@typescript-eslint/parser",
|
|
8
|
+
"parserOptions": {
|
|
9
|
+
"project": "./tsconfig.json",
|
|
10
|
+
"ecmaVersion": 2022,
|
|
11
|
+
"sourceType": "module"
|
|
12
|
+
},
|
|
13
|
+
"plugins": ["@typescript-eslint"],
|
|
14
|
+
"rules": {
|
|
15
|
+
"@typescript-eslint/no-explicit-any": "error",
|
|
16
|
+
"@typescript-eslint/explicit-function-return-type": "warn",
|
|
17
|
+
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
|
|
18
|
+
"@typescript-eslint/no-floating-promises": "error",
|
|
19
|
+
"@typescript-eslint/no-misused-promises": "error"
|
|
20
|
+
},
|
|
21
|
+
"ignorePatterns": ["dist", "node_modules", "*.js"]
|
|
22
|
+
}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
# Testing & Developer Resources - Summary
|
|
2
|
+
|
|
3
|
+
## What Was Created
|
|
4
|
+
|
|
5
|
+
I've created comprehensive testing and developer resources for the `@gamerstake/game-core` package:
|
|
6
|
+
|
|
7
|
+
### Documentation (4 New Guides)
|
|
8
|
+
|
|
9
|
+
1. **QUICK_START.md** - Get running in 5 minutes
|
|
10
|
+
2. **DEVELOPER_GUIDE.md** - Complete 300+ line tutorial with examples
|
|
11
|
+
3. **MANUAL_TESTING.md** - Step-by-step manual testing instructions
|
|
12
|
+
4. **TESTING_OVERVIEW.md** - Master index of all resources
|
|
13
|
+
|
|
14
|
+
### Manual Testing Example (3 Files)
|
|
15
|
+
|
|
16
|
+
5. **examples/simple-game/server.ts** - Full test server with game rules
|
|
17
|
+
6. **examples/simple-game/client.ts** - Automated test client
|
|
18
|
+
7. **examples/simple-game/README.md** - Testing instructions
|
|
19
|
+
|
|
20
|
+
### Updated Files
|
|
21
|
+
|
|
22
|
+
8. **README.md** - Added links to all new resources
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## How to Use
|
|
27
|
+
|
|
28
|
+
### For Quick Testing
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# 1. Build the package
|
|
32
|
+
pnpm build
|
|
33
|
+
|
|
34
|
+
# 2. Start test server (Terminal 1)
|
|
35
|
+
node examples/simple-game/server.js
|
|
36
|
+
|
|
37
|
+
# 3. Start test clients (Terminal 2, 3, 4...)
|
|
38
|
+
node examples/simple-game/client.js
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
You'll see a live multiplayer game server with:
|
|
42
|
+
|
|
43
|
+
- Automatic player movement testing
|
|
44
|
+
- Real-time state synchronization
|
|
45
|
+
- Performance metrics logging
|
|
46
|
+
- Multiple player support
|
|
47
|
+
|
|
48
|
+
### For Learning
|
|
49
|
+
|
|
50
|
+
Start here based on your needs:
|
|
51
|
+
|
|
52
|
+
| I want to... | Read this... |
|
|
53
|
+
| --------------------- | -------------------------------------------- |
|
|
54
|
+
| Get started quickly | [QUICK_START.md](./QUICK_START.md) |
|
|
55
|
+
| Build a complete game | [DEVELOPER_GUIDE.md](./DEVELOPER_GUIDE.md) |
|
|
56
|
+
| Test the engine | [MANUAL_TESTING.md](./MANUAL_TESTING.md) |
|
|
57
|
+
| See all options | [TESTING_OVERVIEW.md](./TESTING_OVERVIEW.md) |
|
|
58
|
+
|
|
59
|
+
### For Development
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Run automated tests
|
|
63
|
+
pnpm test
|
|
64
|
+
|
|
65
|
+
# Run with coverage
|
|
66
|
+
pnpm test:coverage
|
|
67
|
+
|
|
68
|
+
# Watch mode (TDD)
|
|
69
|
+
pnpm test:watch
|
|
70
|
+
|
|
71
|
+
# Type checking
|
|
72
|
+
pnpm typecheck
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## What Each Guide Contains
|
|
78
|
+
|
|
79
|
+
### QUICK_START.md (5-minute tutorial)
|
|
80
|
+
|
|
81
|
+
- Installation instructions
|
|
82
|
+
- Complete server code example
|
|
83
|
+
- Complete client code example
|
|
84
|
+
- Step-by-step instructions
|
|
85
|
+
- Next steps
|
|
86
|
+
|
|
87
|
+
### DEVELOPER_GUIDE.md (Complete tutorial)
|
|
88
|
+
|
|
89
|
+
- Core concepts explanation
|
|
90
|
+
- Architecture overview
|
|
91
|
+
- "Build your first game" tutorial (Tag game)
|
|
92
|
+
- Advanced topics (collision, spatial queries, custom entities)
|
|
93
|
+
- Performance optimization guide
|
|
94
|
+
- Common patterns (state machines, abilities, events)
|
|
95
|
+
- Troubleshooting
|
|
96
|
+
- Best practices
|
|
97
|
+
|
|
98
|
+
### MANUAL_TESTING.md (Testing guide)
|
|
99
|
+
|
|
100
|
+
- Why manual testing matters
|
|
101
|
+
- Step-by-step instructions
|
|
102
|
+
- What to observe (server & client)
|
|
103
|
+
- 5 testing scenarios
|
|
104
|
+
- Customization guide
|
|
105
|
+
- Troubleshooting
|
|
106
|
+
- Result interpretation
|
|
107
|
+
|
|
108
|
+
### TESTING_OVERVIEW.md (Master index)
|
|
109
|
+
|
|
110
|
+
- Documentation structure
|
|
111
|
+
- "Choose your path" guide
|
|
112
|
+
- Testing methods comparison
|
|
113
|
+
- Coverage report
|
|
114
|
+
- Quick command reference
|
|
115
|
+
- Learning path for different skill levels
|
|
116
|
+
|
|
117
|
+
### examples/simple-game/ (Working code)
|
|
118
|
+
|
|
119
|
+
- **server.ts** - Complete game server with:
|
|
120
|
+
- SimpleGameRules implementation
|
|
121
|
+
- Socket.io connection handling
|
|
122
|
+
- Metrics logging
|
|
123
|
+
- 5 obstacle entities
|
|
124
|
+
- Player movement with boundaries
|
|
125
|
+
- **client.ts** - Automated test client with:
|
|
126
|
+
- Connection handling
|
|
127
|
+
- Automated movement patterns
|
|
128
|
+
- Position logging
|
|
129
|
+
- Action testing
|
|
130
|
+
- **README.md** - Detailed usage instructions
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Key Features
|
|
135
|
+
|
|
136
|
+
### Manual Testing Setup
|
|
137
|
+
|
|
138
|
+
**Working out of the box** - Just build and run
|
|
139
|
+
**Automated client** - Tests movement without manual input
|
|
140
|
+
**Multiple clients** - Test with as many as you need
|
|
141
|
+
**Performance metrics** - Real-time monitoring
|
|
142
|
+
**Full coverage** - Tests all major features
|
|
143
|
+
|
|
144
|
+
### Developer Guide
|
|
145
|
+
|
|
146
|
+
**Complete tag game example** - Build from scratch
|
|
147
|
+
**Advanced patterns** - State machines, abilities, ECS
|
|
148
|
+
**Performance tips** - Zero-allocation patterns
|
|
149
|
+
**Best practices** - Do's and don'ts
|
|
150
|
+
**Troubleshooting** - Common issues solved
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Documentation Stats
|
|
155
|
+
|
|
156
|
+
- **4 new guide documents** (10,000+ words)
|
|
157
|
+
- **3 example files** (500+ lines of code)
|
|
158
|
+
- **1 updated README** with navigation
|
|
159
|
+
- **Complete API coverage** from basics to advanced
|
|
160
|
+
- **Working examples** for immediate testing
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Learning Path
|
|
165
|
+
|
|
166
|
+
### Beginner Path (30 minutes)
|
|
167
|
+
|
|
168
|
+
1. Read QUICK_START.md (5 min)
|
|
169
|
+
2. Run the example (10 min)
|
|
170
|
+
3. Skim DEVELOPER_GUIDE.md (15 min)
|
|
171
|
+
4. Start building!
|
|
172
|
+
|
|
173
|
+
### Intermediate Path (1 hour)
|
|
174
|
+
|
|
175
|
+
1. Read DEVELOPER_GUIDE.md fully (30 min)
|
|
176
|
+
2. Run manual tests (10 min)
|
|
177
|
+
3. Modify the example (20 min)
|
|
178
|
+
4. Build your game!
|
|
179
|
+
|
|
180
|
+
### Advanced Path (2 hours)
|
|
181
|
+
|
|
182
|
+
1. Read all guides (45 min)
|
|
183
|
+
2. Study source code (30 min)
|
|
184
|
+
3. Build complete game (45 min)
|
|
185
|
+
4. Deploy!
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## What You Can Do Now
|
|
190
|
+
|
|
191
|
+
### Manual Testing
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
cd /path/to/game-core
|
|
195
|
+
pnpm build
|
|
196
|
+
node examples/simple-game/server.js
|
|
197
|
+
# In new terminal:
|
|
198
|
+
node examples/simple-game/client.js
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Build Your Game
|
|
202
|
+
|
|
203
|
+
Follow the complete tag game tutorial in DEVELOPER_GUIDE.md
|
|
204
|
+
|
|
205
|
+
### Understand Architecture
|
|
206
|
+
|
|
207
|
+
Read the core concepts section in DEVELOPER_GUIDE.md
|
|
208
|
+
|
|
209
|
+
### Run Tests
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
pnpm test # Unit tests
|
|
213
|
+
pnpm test:coverage # With coverage
|
|
214
|
+
pnpm test:watch # Watch mode
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## File Locations
|
|
220
|
+
|
|
221
|
+
```
|
|
222
|
+
game-core/
|
|
223
|
+
QUICK_START.md ..................... 5-minute tutorial
|
|
224
|
+
DEVELOPER_GUIDE.md ................. Complete guide
|
|
225
|
+
MANUAL_TESTING.md .................. Testing instructions
|
|
226
|
+
TESTING_OVERVIEW.md ................ Master index
|
|
227
|
+
README.md .......................... Updated with links
|
|
228
|
+
|
|
229
|
+
examples/
|
|
230
|
+
simple-game/
|
|
231
|
+
server.ts .................. Test server
|
|
232
|
+
client.ts .................. Test client
|
|
233
|
+
README.md .................. Instructions
|
|
234
|
+
package.json ............... NPM scripts
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
## Summary
|
|
240
|
+
|
|
241
|
+
You now have:
|
|
242
|
+
|
|
243
|
+
**Complete documentation** for developers
|
|
244
|
+
**Working manual test setup** that runs immediately
|
|
245
|
+
**Step-by-step tutorials** from beginner to advanced
|
|
246
|
+
**Real multiplayer examples** you can modify
|
|
247
|
+
**Performance monitoring** built-in
|
|
248
|
+
**Best practices** and patterns documented
|
|
249
|
+
|
|
250
|
+
**Everything you need to test and build multiplayer games with game-core!**
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## Questions?
|
|
255
|
+
|
|
256
|
+
- Start with [QUICK_START.md](./QUICK_START.md) for basics
|
|
257
|
+
- See [DEVELOPER_GUIDE.md](./DEVELOPER_GUIDE.md) for advanced topics
|
|
258
|
+
- Check [MANUAL_TESTING.md](./MANUAL_TESTING.md) for testing help
|
|
259
|
+
- Review [TESTING_OVERVIEW.md](./TESTING_OVERVIEW.md) for the big picture
|
|
260
|
+
|
|
261
|
+
Happy building!
|