bmad-method 4.2.0 → 4.4.1

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.
Files changed (176) hide show
  1. package/.claude/commands/analyst.md +14 -20
  2. package/.claude/commands/architect.md +15 -20
  3. package/.claude/commands/bmad-master.md +18 -26
  4. package/.claude/commands/bmad-orchestrator.md +80 -33
  5. package/.claude/commands/dev.md +5 -4
  6. package/.claude/commands/pm.md +11 -16
  7. package/.claude/commands/sm.md +20 -25
  8. package/.cursor/rules/analyst.mdc +13 -19
  9. package/.cursor/rules/architect.mdc +14 -19
  10. package/.cursor/rules/bmad-master.mdc +18 -26
  11. package/.cursor/rules/bmad-orchestrator.mdc +80 -33
  12. package/.cursor/rules/dev.mdc +5 -4
  13. package/.cursor/rules/pm.mdc +11 -16
  14. package/.cursor/rules/sm.mdc +19 -24
  15. package/.releaserc.json +2 -1
  16. package/.roo/README.md +0 -11
  17. package/.vscode/settings.json +4 -0
  18. package/.windsurf/rules/analyst.md +13 -19
  19. package/.windsurf/rules/architect.md +14 -19
  20. package/.windsurf/rules/bmad-master.md +18 -26
  21. package/.windsurf/rules/bmad-orchestrator.md +80 -33
  22. package/.windsurf/rules/dev.md +5 -4
  23. package/.windsurf/rules/pm.md +11 -16
  24. package/.windsurf/rules/sm.md +19 -24
  25. package/CHANGELOG.md +126 -2
  26. package/CONTRIBUTING.md +2 -0
  27. package/README.md +20 -2
  28. package/{.bmad-core → bmad-core}/agent-teams/team-all.yml +1 -3
  29. package/bmad-core/agent-teams/team-fullstack.yml +18 -0
  30. package/{.bmad-core → bmad-core}/agent-teams/team-no-ui.yml +0 -2
  31. package/{.bmad-core → bmad-core}/agents/analyst.md +14 -20
  32. package/{.bmad-core → bmad-core}/agents/architect.md +15 -20
  33. package/{.bmad-core → bmad-core}/agents/bmad-master.md +18 -26
  34. package/bmad-core/agents/bmad-orchestrator.md +128 -0
  35. package/{.bmad-core → bmad-core}/agents/dev.md +5 -4
  36. package/{.bmad-core → bmad-core}/agents/pm.md +11 -16
  37. package/{.bmad-core → bmad-core}/agents/qa.md +11 -17
  38. package/bmad-core/agents/sm.md +55 -0
  39. package/{.bmad-core → bmad-core}/agents/ux-expert.md +14 -20
  40. package/bmad-core/bmad-core-config.yml +60 -0
  41. package/bmad-core/data/bmad-kb.md +47 -0
  42. package/bmad-core/tasks/doc-migration-task.md +143 -0
  43. package/bmad-core/tasks/document-project.md +389 -0
  44. package/bmad-core/tasks/generate-ai-frontend-prompt.md +51 -0
  45. package/{.bmad-core → bmad-core}/tasks/index-docs.md +8 -3
  46. package/{.bmad-core → bmad-core}/tasks/shard-doc.md +5 -3
  47. package/{.bmad-core → bmad-core}/templates/architecture-tmpl.md +16 -13
  48. package/{.bmad-core → bmad-core}/templates/brownfield-architecture-tmpl.md +6 -6
  49. package/{.bmad-core → bmad-core}/templates/front-end-spec-tmpl.md +6 -6
  50. package/{.bmad-core → bmad-core}/templates/fullstack-architecture-tmpl.md +85 -103
  51. package/{.bmad-core → bmad-core}/templates/prd-tmpl.md +1 -1
  52. package/bmad-core/templates/simple-project-prd-tmpl.md +461 -0
  53. package/{.bmad-core → bmad-core}/templates/story-tmpl.md +2 -2
  54. package/{.bmad-core → bmad-core}/utils/agent-switcher.ide.md +6 -6
  55. package/{.bmad-core → bmad-core}/utils/workflow-management.md +14 -15
  56. package/{.bmad-core → bmad-core}/web-bundles/agents/analyst.txt +26 -21
  57. package/{.bmad-core → bmad-core}/web-bundles/agents/architect.txt +608 -236
  58. package/{.bmad-core → bmad-core}/web-bundles/agents/bmad-master.txt +467 -1049
  59. package/bmad-core/web-bundles/agents/bmad-orchestrator.txt +647 -0
  60. package/{.bmad-core → bmad-core}/web-bundles/agents/dev.txt +5 -4
  61. package/{.bmad-core → bmad-core}/web-bundles/agents/pm.txt +477 -18
  62. package/{.bmad-core → bmad-core}/web-bundles/agents/po.txt +3 -3
  63. package/{.bmad-core → bmad-core}/web-bundles/agents/qa.txt +11 -17
  64. package/{.bmad-core → bmad-core}/web-bundles/agents/sm.txt +22 -27
  65. package/{.bmad-core → bmad-core}/web-bundles/agents/ux-expert.txt +57 -70
  66. package/{.bmad-core → bmad-core}/workflows/greenfield-fullstack.yml +3 -3
  67. package/{.bmad-core → creator-tools}/tasks/create-agent.md +10 -12
  68. package/{.bmad-core/tasks/create-expansion-pack.md → creator-tools/tasks/generate-expansion-pack.md} +8 -6
  69. package/docs/bmad-workflow-guide.md +161 -0
  70. package/docs/claude-code-guide.md +119 -0
  71. package/docs/core-architecture.md +213 -0
  72. package/docs/cursor-guide.md +127 -0
  73. package/docs/how-to-contribute-with-pull-requests.md +141 -0
  74. package/docs/roo-code-guide.md +140 -0
  75. package/docs/user-guide.md +1044 -0
  76. package/docs/versioning-and-releases.md +4 -4
  77. package/docs/windsurf-guide.md +127 -0
  78. package/expansion-packs/README.md +1 -111
  79. package/expansion-packs/bmad-2d-phaser-game-dev/agent-teams/team-game-dev.yml +12 -0
  80. package/expansion-packs/bmad-2d-phaser-game-dev/agents/game-designer.md +58 -0
  81. package/expansion-packs/bmad-2d-phaser-game-dev/agents/game-developer.md +66 -0
  82. package/expansion-packs/bmad-2d-phaser-game-dev/agents/game-sm.md +51 -0
  83. package/expansion-packs/bmad-2d-phaser-game-dev/checklists/game-design-checklist.md +201 -0
  84. package/expansion-packs/bmad-2d-phaser-game-dev/checklists/game-story-dod-checklist.md +160 -0
  85. package/expansion-packs/bmad-2d-phaser-game-dev/data/bmad-kb.md +254 -0
  86. package/expansion-packs/bmad-2d-phaser-game-dev/data/development-guidelines.md +631 -0
  87. package/expansion-packs/bmad-2d-phaser-game-dev/manifest.yml +45 -0
  88. package/expansion-packs/bmad-2d-phaser-game-dev/tasks/advanced-elicitation.md +111 -0
  89. package/expansion-packs/bmad-2d-phaser-game-dev/tasks/create-game-story.md +216 -0
  90. package/expansion-packs/bmad-2d-phaser-game-dev/tasks/game-design-brainstorming.md +308 -0
  91. package/expansion-packs/bmad-2d-phaser-game-dev/templates/game-architecture-tmpl.md +560 -0
  92. package/expansion-packs/bmad-2d-phaser-game-dev/templates/game-brief-tmpl.md +345 -0
  93. package/expansion-packs/bmad-2d-phaser-game-dev/templates/game-design-doc-tmpl.md +331 -0
  94. package/expansion-packs/bmad-2d-phaser-game-dev/templates/game-story-tmpl.md +235 -0
  95. package/expansion-packs/bmad-2d-phaser-game-dev/templates/level-design-doc-tmpl.md +451 -0
  96. package/expansion-packs/bmad-2d-phaser-game-dev/web-bundles/agents/game-designer.txt +1758 -0
  97. package/expansion-packs/bmad-2d-phaser-game-dev/web-bundles/agents/game-developer.txt +1444 -0
  98. package/expansion-packs/bmad-2d-phaser-game-dev/web-bundles/agents/game-sm.txt +674 -0
  99. package/expansion-packs/bmad-2d-phaser-game-dev/web-bundles/team-game-dev.txt +4395 -0
  100. package/expansion-packs/bmad-2d-phaser-game-dev/web-bundles/teams/team-game-dev.txt +4395 -0
  101. package/expansion-packs/bmad-2d-phaser-game-dev/workflows/game-dev-greenfield.yml +183 -0
  102. package/expansion-packs/bmad-2d-phaser-game-dev/workflows/game-prototype.yml +175 -0
  103. package/expansion-packs/{infrastructure-devops → bmad-infrastructure-devops}/README.md +5 -5
  104. package/expansion-packs/{infrastructure-devops → bmad-infrastructure-devops}/agents/infra-devops-platform.md +3 -3
  105. package/expansion-packs/bmad-infrastructure-devops/manifest.yml +23 -0
  106. package/expansion-packs/bmad-infrastructure-devops/tasks/create-doc.md +74 -0
  107. package/expansion-packs/{infrastructure-devops → bmad-infrastructure-devops}/templates/infrastructure-platform-from-arch-tmpl.md +0 -0
  108. package/expansion-packs/bmad-infrastructure-devops/web-bundles/agents/infra-devops-platform.txt +2021 -0
  109. package/package.json +20 -14
  110. package/tools/builders/web-builder.js +207 -17
  111. package/tools/cli.js +55 -7
  112. package/tools/installer/README.md +2 -2
  113. package/tools/installer/bin/bmad.js +107 -28
  114. package/tools/installer/config/install.config.yml +43 -43
  115. package/tools/installer/lib/config-loader.js +39 -2
  116. package/tools/installer/lib/file-manager.js +20 -3
  117. package/tools/installer/lib/ide-setup.js +11 -1
  118. package/tools/installer/lib/installer.js +275 -29
  119. package/tools/installer/package-lock.json +538 -336
  120. package/tools/installer/package.json +8 -8
  121. package/tools/lib/dependency-resolver.js +2 -2
  122. package/tools/semantic-release-sync-installer.js +31 -0
  123. package/tools/sync-installer-version.js +34 -0
  124. package/tools/upgraders/v3-to-v4-upgrader.js +18 -13
  125. package/tools/version-bump.js +33 -26
  126. package/tools/yaml-format.js +54 -25
  127. package/.bmad-core/agent-teams/team-fullstack.yml +0 -26
  128. package/.bmad-core/agents/bmad-orchestrator.md +0 -81
  129. package/.bmad-core/agents/sm.md +0 -60
  130. package/.bmad-core/data/bmad-kb.md +0 -36
  131. package/.bmad-core/schemas/agent-team-schema.yml +0 -153
  132. package/.bmad-core/tasks/create-team.md +0 -229
  133. package/.bmad-core/tasks/doc-migration-task.md +0 -198
  134. package/.bmad-core/tasks/generate-ai-frontend-prompt.md +0 -58
  135. package/.bmad-core/web-bundles/agents/bmad-orchestrator.txt +0 -1455
  136. package/.bmad-core/web-bundles/teams/team-all.txt +0 -10315
  137. package/.bmad-core/web-bundles/teams/team-fullstack.txt +0 -9663
  138. package/.bmad-core/web-bundles/teams/team-no-ui.txt +0 -8504
  139. package/.claude/settings.local.json +0 -22
  140. package/expansion-packs/infrastructure-devops/manifest.yml +0 -38
  141. /package/{.bmad-core → bmad-core}/agents/po.md +0 -0
  142. /package/{.bmad-core → bmad-core}/checklists/architect-checklist.md +0 -0
  143. /package/{.bmad-core → bmad-core}/checklists/change-checklist.md +0 -0
  144. /package/{.bmad-core → bmad-core}/checklists/pm-checklist.md +0 -0
  145. /package/{.bmad-core → bmad-core}/checklists/po-master-checklist.md +0 -0
  146. /package/{.bmad-core → bmad-core}/checklists/story-dod-checklist.md +0 -0
  147. /package/{.bmad-core → bmad-core}/checklists/story-draft-checklist.md +0 -0
  148. /package/{.bmad-core → bmad-core}/data/technical-preferences.md +0 -0
  149. /package/{.bmad-core → bmad-core}/tasks/advanced-elicitation.md +0 -0
  150. /package/{.bmad-core → bmad-core}/tasks/brainstorming-techniques.md +0 -0
  151. /package/{.bmad-core → bmad-core}/tasks/brownfield-create-epic.md +0 -0
  152. /package/{.bmad-core → bmad-core}/tasks/brownfield-create-story.md +0 -0
  153. /package/{.bmad-core → bmad-core}/tasks/core-dump.md +0 -0
  154. /package/{.bmad-core → bmad-core}/tasks/correct-course.md +0 -0
  155. /package/{.bmad-core → bmad-core}/tasks/create-deep-research-prompt.md +0 -0
  156. /package/{.bmad-core → bmad-core}/tasks/create-doc.md +0 -0
  157. /package/{.bmad-core → bmad-core}/tasks/create-next-story.md +0 -0
  158. /package/{.bmad-core → bmad-core}/tasks/execute-checklist.md +0 -0
  159. /package/{.bmad-core → bmad-core}/templates/agent-tmpl.md +0 -0
  160. /package/{.bmad-core → bmad-core}/templates/brownfield-prd-tmpl.md +0 -0
  161. /package/{.bmad-core → bmad-core}/templates/competitor-analysis-tmpl.md +0 -0
  162. /package/{.bmad-core → bmad-core}/templates/expansion-pack-plan-tmpl.md +0 -0
  163. /package/{.bmad-core → bmad-core}/templates/front-end-architecture-tmpl.md +0 -0
  164. /package/{.bmad-core → bmad-core}/templates/market-research-tmpl.md +0 -0
  165. /package/{.bmad-core → bmad-core}/templates/project-brief-tmpl.md +0 -0
  166. /package/{.bmad-core → bmad-core}/templates/web-agent-startup-instructions-template.md +0 -0
  167. /package/{.bmad-core → bmad-core}/utils/template-format.md +0 -0
  168. /package/{.bmad-core → bmad-core}/workflows/brownfield-fullstack.yml +0 -0
  169. /package/{.bmad-core → bmad-core}/workflows/brownfield-service.yml +0 -0
  170. /package/{.bmad-core → bmad-core}/workflows/brownfield-ui.yml +0 -0
  171. /package/{.bmad-core → bmad-core}/workflows/greenfield-service.yml +0 -0
  172. /package/{.bmad-core → bmad-core}/workflows/greenfield-ui.yml +0 -0
  173. /package/expansion-packs/{infrastructure-devops → bmad-infrastructure-devops}/checklists/infrastructure-checklist.md +0 -0
  174. /package/expansion-packs/{infrastructure-devops → bmad-infrastructure-devops}/tasks/review-infrastructure.md +0 -0
  175. /package/expansion-packs/{infrastructure-devops → bmad-infrastructure-devops}/tasks/validate-infrastructure.md +0 -0
  176. /package/expansion-packs/{infrastructure-devops → bmad-infrastructure-devops}/templates/infrastructure-architecture-tmpl.md +0 -0
@@ -0,0 +1,631 @@
1
+ # Game Development Guidelines
2
+
3
+ ## Overview
4
+
5
+ This document establishes coding standards, architectural patterns, and development practices for 2D game development using Phaser 3 and TypeScript. These guidelines ensure consistency, performance, and maintainability across all game development stories.
6
+
7
+ ## TypeScript Standards
8
+
9
+ ### Strict Mode Configuration
10
+
11
+ **Required tsconfig.json settings:**
12
+
13
+ ````json
14
+ {
15
+ "compilerOptions": {
16
+ "strict": true,
17
+ "noImplicitAny": true,
18
+ "strictNullChecks": true,
19
+ "strictFunctionTypes": true,
20
+ "noImplicitReturns": true,
21
+ "noUnusedLocals": true,
22
+ "noUnusedParameters": true,
23
+ "exactOptionalPropertyTypes": true
24
+ }
25
+ }
26
+ ```text
27
+
28
+ ### Type Definitions
29
+
30
+ **Game Object Interfaces:**
31
+ ```typescript
32
+ // Core game entity interface
33
+ interface GameEntity {
34
+ readonly id: string;
35
+ position: Phaser.Math.Vector2;
36
+ active: boolean;
37
+ destroy(): void;
38
+ }
39
+
40
+ // Player controller interface
41
+ interface PlayerController {
42
+ readonly inputEnabled: boolean;
43
+ handleInput(input: InputState): void;
44
+ update(delta: number): void;
45
+ }
46
+
47
+ // Game system interface
48
+ interface GameSystem {
49
+ readonly name: string;
50
+ initialize(): void;
51
+ update(delta: number): void;
52
+ shutdown(): void;
53
+ }
54
+ ```text
55
+
56
+ **Scene Data Interfaces:**
57
+ ```typescript
58
+ // Scene transition data
59
+ interface SceneData {
60
+ [key: string]: any;
61
+ }
62
+
63
+ // Game state interface
64
+ interface GameState {
65
+ currentLevel: number;
66
+ score: number;
67
+ lives: number;
68
+ settings: GameSettings;
69
+ }
70
+
71
+ interface GameSettings {
72
+ musicVolume: number;
73
+ sfxVolume: number;
74
+ difficulty: 'easy' | 'normal' | 'hard';
75
+ controls: ControlScheme;
76
+ }
77
+ ```text
78
+
79
+ ### Naming Conventions
80
+
81
+ **Classes and Interfaces:**
82
+ - PascalCase for classes: `PlayerSprite`, `GameManager`, `AudioSystem`
83
+ - PascalCase with 'I' prefix for interfaces: `IGameEntity`, `IPlayerController`
84
+ - Descriptive names that indicate purpose: `CollisionManager` not `CM`
85
+
86
+ **Methods and Variables:**
87
+ - camelCase for methods and variables: `updatePosition()`, `playerSpeed`
88
+ - Descriptive names: `calculateDamage()` not `calcDmg()`
89
+ - Boolean variables with is/has/can prefix: `isActive`, `hasCollision`, `canMove`
90
+
91
+ **Constants:**
92
+ - UPPER_SNAKE_CASE for constants: `MAX_PLAYER_SPEED`, `DEFAULT_VOLUME`
93
+ - Group related constants in enums or const objects
94
+
95
+ **Files and Directories:**
96
+ - kebab-case for file names: `player-controller.ts`, `audio-manager.ts`
97
+ - PascalCase for scene files: `MenuScene.ts`, `GameScene.ts`
98
+
99
+ ## Phaser 3 Architecture Patterns
100
+
101
+ ### Scene Organization
102
+
103
+ **Scene Lifecycle Management:**
104
+ ```typescript
105
+ class GameScene extends Phaser.Scene {
106
+ private gameManager!: GameManager;
107
+ private inputManager!: InputManager;
108
+
109
+ constructor() {
110
+ super({ key: 'GameScene' });
111
+ }
112
+
113
+ preload(): void {
114
+ // Load only scene-specific assets
115
+ this.load.image('player', 'assets/player.png');
116
+ }
117
+
118
+ create(data: SceneData): void {
119
+ // Initialize game systems
120
+ this.gameManager = new GameManager(this);
121
+ this.inputManager = new InputManager(this);
122
+
123
+ // Set up scene-specific logic
124
+ this.setupGameObjects();
125
+ this.setupEventListeners();
126
+ }
127
+
128
+ update(time: number, delta: number): void {
129
+ // Update all game systems
130
+ this.gameManager.update(delta);
131
+ this.inputManager.update(delta);
132
+ }
133
+
134
+ shutdown(): void {
135
+ // Clean up resources
136
+ this.gameManager.destroy();
137
+ this.inputManager.destroy();
138
+
139
+ // Remove event listeners
140
+ this.events.off('*');
141
+ }
142
+ }
143
+ ````
144
+
145
+ **Scene Transitions:**
146
+
147
+ ````typescript
148
+ // Proper scene transitions with data
149
+ this.scene.start('NextScene', {
150
+ playerScore: this.playerScore,
151
+ currentLevel: this.currentLevel + 1
152
+ });
153
+
154
+ // Scene overlays for UI
155
+ this.scene.launch('PauseMenuScene');
156
+ this.scene.pause();
157
+ ```text
158
+
159
+ ### Game Object Patterns
160
+
161
+ **Component-Based Architecture:**
162
+ ```typescript
163
+ // Base game entity
164
+ abstract class GameEntity extends Phaser.GameObjects.Sprite {
165
+ protected components: Map<string, GameComponent> = new Map();
166
+
167
+ constructor(scene: Phaser.Scene, x: number, y: number, texture: string) {
168
+ super(scene, x, y, texture);
169
+ scene.add.existing(this);
170
+ }
171
+
172
+ addComponent<T extends GameComponent>(component: T): T {
173
+ this.components.set(component.name, component);
174
+ return component;
175
+ }
176
+
177
+ getComponent<T extends GameComponent>(name: string): T | undefined {
178
+ return this.components.get(name) as T;
179
+ }
180
+
181
+ update(delta: number): void {
182
+ this.components.forEach(component => component.update(delta));
183
+ }
184
+
185
+ destroy(): void {
186
+ this.components.forEach(component => component.destroy());
187
+ this.components.clear();
188
+ super.destroy();
189
+ }
190
+ }
191
+
192
+ // Example player implementation
193
+ class Player extends GameEntity {
194
+ private movement!: MovementComponent;
195
+ private health!: HealthComponent;
196
+
197
+ constructor(scene: Phaser.Scene, x: number, y: number) {
198
+ super(scene, x, y, 'player');
199
+
200
+ this.movement = this.addComponent(new MovementComponent(this));
201
+ this.health = this.addComponent(new HealthComponent(this, 100));
202
+ }
203
+ }
204
+ ```text
205
+
206
+ ### System Management
207
+
208
+ **Singleton Managers:**
209
+ ```typescript
210
+ class GameManager {
211
+ private static instance: GameManager;
212
+ private scene: Phaser.Scene;
213
+ private gameState: GameState;
214
+
215
+ constructor(scene: Phaser.Scene) {
216
+ if (GameManager.instance) {
217
+ throw new Error('GameManager already exists!');
218
+ }
219
+
220
+ this.scene = scene;
221
+ this.gameState = this.loadGameState();
222
+ GameManager.instance = this;
223
+ }
224
+
225
+ static getInstance(): GameManager {
226
+ if (!GameManager.instance) {
227
+ throw new Error('GameManager not initialized!');
228
+ }
229
+ return GameManager.instance;
230
+ }
231
+
232
+ update(delta: number): void {
233
+ // Update game logic
234
+ }
235
+
236
+ destroy(): void {
237
+ GameManager.instance = null!;
238
+ }
239
+ }
240
+ ```text
241
+
242
+ ## Performance Optimization
243
+
244
+ ### Object Pooling
245
+
246
+ **Required for High-Frequency Objects:**
247
+ ```typescript
248
+ class BulletPool {
249
+ private pool: Bullet[] = [];
250
+ private scene: Phaser.Scene;
251
+
252
+ constructor(scene: Phaser.Scene, initialSize: number = 50) {
253
+ this.scene = scene;
254
+
255
+ // Pre-create bullets
256
+ for (let i = 0; i < initialSize; i++) {
257
+ const bullet = new Bullet(scene, 0, 0);
258
+ bullet.setActive(false);
259
+ bullet.setVisible(false);
260
+ this.pool.push(bullet);
261
+ }
262
+ }
263
+
264
+ getBullet(): Bullet | null {
265
+ const bullet = this.pool.find(b => !b.active);
266
+ if (bullet) {
267
+ bullet.setActive(true);
268
+ bullet.setVisible(true);
269
+ return bullet;
270
+ }
271
+
272
+ // Pool exhausted - create new bullet
273
+ console.warn('Bullet pool exhausted, creating new bullet');
274
+ return new Bullet(this.scene, 0, 0);
275
+ }
276
+
277
+ releaseBullet(bullet: Bullet): void {
278
+ bullet.setActive(false);
279
+ bullet.setVisible(false);
280
+ bullet.setPosition(0, 0);
281
+ }
282
+ }
283
+ ````
284
+
285
+ ### Frame Rate Optimization
286
+
287
+ **Performance Monitoring:**
288
+
289
+ ````typescript
290
+ class PerformanceMonitor {
291
+ private frameCount: number = 0;
292
+ private lastTime: number = 0;
293
+ private frameRate: number = 60;
294
+
295
+ update(time: number): void {
296
+ this.frameCount++;
297
+
298
+ if (time - this.lastTime >= 1000) {
299
+ this.frameRate = this.frameCount;
300
+ this.frameCount = 0;
301
+ this.lastTime = time;
302
+
303
+ if (this.frameRate < 55) {
304
+ console.warn(`Low frame rate detected: ${this.frameRate} FPS`);
305
+ this.optimizePerformance();
306
+ }
307
+ }
308
+ }
309
+
310
+ private optimizePerformance(): void {
311
+ // Reduce particle counts, disable effects, etc.
312
+ }
313
+ }
314
+ ```text
315
+
316
+ **Update Loop Optimization:**
317
+ ```typescript
318
+ // Avoid expensive operations in update loops
319
+ class GameScene extends Phaser.Scene {
320
+ private updateTimer: number = 0;
321
+ private readonly UPDATE_INTERVAL = 100; // ms
322
+
323
+ update(time: number, delta: number): void {
324
+ // High-frequency updates (every frame)
325
+ this.updatePlayer(delta);
326
+ this.updatePhysics(delta);
327
+
328
+ // Low-frequency updates (10 times per second)
329
+ this.updateTimer += delta;
330
+ if (this.updateTimer >= this.UPDATE_INTERVAL) {
331
+ this.updateUI();
332
+ this.updateAI();
333
+ this.updateTimer = 0;
334
+ }
335
+ }
336
+ }
337
+ ```text
338
+
339
+ ## Input Handling
340
+
341
+ ### Cross-Platform Input
342
+
343
+ **Input Abstraction:**
344
+ ```typescript
345
+ interface InputState {
346
+ moveLeft: boolean;
347
+ moveRight: boolean;
348
+ jump: boolean;
349
+ action: boolean;
350
+ pause: boolean;
351
+ }
352
+
353
+ class InputManager {
354
+ private inputState: InputState = {
355
+ moveLeft: false,
356
+ moveRight: false,
357
+ jump: false,
358
+ action: false,
359
+ pause: false
360
+ };
361
+
362
+ private keys!: { [key: string]: Phaser.Input.Keyboard.Key };
363
+ private pointer!: Phaser.Input.Pointer;
364
+
365
+ constructor(private scene: Phaser.Scene) {
366
+ this.setupKeyboard();
367
+ this.setupTouch();
368
+ }
369
+
370
+ private setupKeyboard(): void {
371
+ this.keys = this.scene.input.keyboard.addKeys('W,A,S,D,SPACE,ESC,UP,DOWN,LEFT,RIGHT');
372
+ }
373
+
374
+ private setupTouch(): void {
375
+ this.scene.input.on('pointerdown', this.handlePointerDown, this);
376
+ this.scene.input.on('pointerup', this.handlePointerUp, this);
377
+ }
378
+
379
+ update(): void {
380
+ // Update input state from multiple sources
381
+ this.inputState.moveLeft = this.keys.A.isDown || this.keys.LEFT.isDown;
382
+ this.inputState.moveRight = this.keys.D.isDown || this.keys.RIGHT.isDown;
383
+ this.inputState.jump = Phaser.Input.Keyboard.JustDown(this.keys.SPACE);
384
+ // ... handle touch input
385
+ }
386
+
387
+ getInputState(): InputState {
388
+ return { ...this.inputState };
389
+ }
390
+ }
391
+ ```text
392
+
393
+ ## Error Handling
394
+
395
+ ### Graceful Degradation
396
+
397
+ **Asset Loading Error Handling:**
398
+ ```typescript
399
+ class AssetManager {
400
+ loadAssets(): Promise<void> {
401
+ return new Promise((resolve, reject) => {
402
+ this.scene.load.on('filecomplete', this.handleFileComplete, this);
403
+ this.scene.load.on('loaderror', this.handleLoadError, this);
404
+ this.scene.load.on('complete', () => resolve());
405
+
406
+ this.scene.load.start();
407
+ });
408
+ }
409
+
410
+ private handleLoadError(file: Phaser.Loader.File): void {
411
+ console.error(`Failed to load asset: ${file.key}`);
412
+
413
+ // Use fallback assets
414
+ this.loadFallbackAsset(file.key);
415
+ }
416
+
417
+ private loadFallbackAsset(key: string): void {
418
+ // Load placeholder or default assets
419
+ switch (key) {
420
+ case 'player':
421
+ this.scene.load.image('player', 'assets/defaults/default-player.png');
422
+ break;
423
+ default:
424
+ console.warn(`No fallback for asset: ${key}`);
425
+ }
426
+ }
427
+ }
428
+ ````
429
+
430
+ ### Runtime Error Recovery
431
+
432
+ **System Error Handling:**
433
+
434
+ ````typescript
435
+ class GameSystem {
436
+ protected handleError(error: Error, context: string): void {
437
+ console.error(`Error in ${context}:`, error);
438
+
439
+ // Report to analytics/logging service
440
+ this.reportError(error, context);
441
+
442
+ // Attempt recovery
443
+ this.attemptRecovery(context);
444
+ }
445
+
446
+ private attemptRecovery(context: string): void {
447
+ switch (context) {
448
+ case 'update':
449
+ // Reset system state
450
+ this.reset();
451
+ break;
452
+ case 'render':
453
+ // Disable visual effects
454
+ this.disableEffects();
455
+ break;
456
+ default:
457
+ // Generic recovery
458
+ this.safeShutdown();
459
+ }
460
+ }
461
+ }
462
+ ```text
463
+
464
+ ## Testing Standards
465
+
466
+ ### Unit Testing
467
+
468
+ **Game Logic Testing:**
469
+ ```typescript
470
+ // Example test for game mechanics
471
+ describe('HealthComponent', () => {
472
+ let healthComponent: HealthComponent;
473
+
474
+ beforeEach(() => {
475
+ const mockEntity = {} as GameEntity;
476
+ healthComponent = new HealthComponent(mockEntity, 100);
477
+ });
478
+
479
+ test('should initialize with correct health', () => {
480
+ expect(healthComponent.currentHealth).toBe(100);
481
+ expect(healthComponent.maxHealth).toBe(100);
482
+ });
483
+
484
+ test('should handle damage correctly', () => {
485
+ healthComponent.takeDamage(25);
486
+ expect(healthComponent.currentHealth).toBe(75);
487
+ expect(healthComponent.isAlive()).toBe(true);
488
+ });
489
+
490
+ test('should handle death correctly', () => {
491
+ healthComponent.takeDamage(150);
492
+ expect(healthComponent.currentHealth).toBe(0);
493
+ expect(healthComponent.isAlive()).toBe(false);
494
+ });
495
+ });
496
+ ```text
497
+
498
+ ### Integration Testing
499
+
500
+ **Scene Testing:**
501
+ ```typescript
502
+ describe('GameScene Integration', () => {
503
+ let scene: GameScene;
504
+ let mockGame: Phaser.Game;
505
+
506
+ beforeEach(() => {
507
+ // Mock Phaser game instance
508
+ mockGame = createMockGame();
509
+ scene = new GameScene();
510
+ });
511
+
512
+ test('should initialize all systems', () => {
513
+ scene.create({});
514
+
515
+ expect(scene.gameManager).toBeDefined();
516
+ expect(scene.inputManager).toBeDefined();
517
+ });
518
+ });
519
+ ```text
520
+
521
+ ## File Organization
522
+
523
+ ### Project Structure
524
+
525
+ ````
526
+
527
+ src/
528
+ ├── scenes/
529
+ │ ├── BootScene.ts # Initial loading and setup
530
+ │ ├── PreloadScene.ts # Asset loading with progress
531
+ │ ├── MenuScene.ts # Main menu and navigation
532
+ │ ├── GameScene.ts # Core gameplay
533
+ │ └── UIScene.ts # Overlay UI elements
534
+ ├── gameObjects/
535
+ │ ├── entities/
536
+ │ │ ├── Player.ts # Player game object
537
+ │ │ ├── Enemy.ts # Enemy base class
538
+ │ │ └── Collectible.ts # Collectible items
539
+ │ ├── components/
540
+ │ │ ├── MovementComponent.ts
541
+ │ │ ├── HealthComponent.ts
542
+ │ │ └── CollisionComponent.ts
543
+ │ └── ui/
544
+ │ ├── Button.ts # Interactive buttons
545
+ │ ├── HealthBar.ts # Health display
546
+ │ └── ScoreDisplay.ts # Score UI
547
+ ├── systems/
548
+ │ ├── GameManager.ts # Core game state management
549
+ │ ├── InputManager.ts # Cross-platform input handling
550
+ │ ├── AudioManager.ts # Sound and music system
551
+ │ ├── SaveManager.ts # Save/load functionality
552
+ │ └── PerformanceMonitor.ts # Performance tracking
553
+ ├── utils/
554
+ │ ├── ObjectPool.ts # Generic object pooling
555
+ │ ├── MathUtils.ts # Game math helpers
556
+ │ ├── AssetLoader.ts # Asset management utilities
557
+ │ └── EventBus.ts # Global event system
558
+ ├── types/
559
+ │ ├── GameTypes.ts # Core game type definitions
560
+ │ ├── UITypes.ts # UI-related types
561
+ │ └── SystemTypes.ts # System interface definitions
562
+ ├── config/
563
+ │ ├── GameConfig.ts # Phaser game configuration
564
+ │ ├── GameBalance.ts # Game balance parameters
565
+ │ └── AssetConfig.ts # Asset loading configuration
566
+ └── main.ts # Application entry point
567
+
568
+ ```
569
+
570
+ ## Development Workflow
571
+
572
+ ### Story Implementation Process
573
+
574
+ 1. **Read Story Requirements:**
575
+ - Understand acceptance criteria
576
+ - Identify technical requirements
577
+ - Review performance constraints
578
+
579
+ 2. **Plan Implementation:**
580
+ - Identify files to create/modify
581
+ - Consider component architecture
582
+ - Plan testing approach
583
+
584
+ 3. **Implement Feature:**
585
+ - Follow TypeScript strict mode
586
+ - Use established patterns
587
+ - Maintain 60 FPS performance
588
+
589
+ 4. **Test Implementation:**
590
+ - Write unit tests for game logic
591
+ - Test cross-platform functionality
592
+ - Validate performance targets
593
+
594
+ 5. **Update Documentation:**
595
+ - Mark story checkboxes complete
596
+ - Document any deviations
597
+ - Update architecture if needed
598
+
599
+ ### Code Review Checklist
600
+
601
+ **Before Committing:**
602
+ - [ ] TypeScript compiles without errors
603
+ - [ ] All tests pass
604
+ - [ ] Performance targets met (60 FPS)
605
+ - [ ] No console errors or warnings
606
+ - [ ] Cross-platform compatibility verified
607
+ - [ ] Memory usage within bounds
608
+ - [ ] Code follows naming conventions
609
+ - [ ] Error handling implemented
610
+ - [ ] Documentation updated
611
+
612
+ ## Performance Targets
613
+
614
+ ### Frame Rate Requirements
615
+ - **Desktop**: Maintain 60 FPS at 1080p
616
+ - **Mobile**: Maintain 60 FPS on mid-range devices, minimum 30 FPS on low-end
617
+ - **Optimization**: Implement dynamic quality scaling when performance drops
618
+
619
+ ### Memory Management
620
+ - **Total Memory**: Under 100MB for full game
621
+ - **Per Scene**: Under 50MB per gameplay scene
622
+ - **Asset Loading**: Progressive loading to stay under limits
623
+ - **Garbage Collection**: Minimize object creation in update loops
624
+
625
+ ### Loading Performance
626
+ - **Initial Load**: Under 5 seconds for game start
627
+ - **Scene Transitions**: Under 2 seconds between scenes
628
+ - **Asset Streaming**: Background loading for upcoming content
629
+
630
+ These guidelines ensure consistent, high-quality game development that meets performance targets and maintains code quality across all implementation stories.
631
+ ```
@@ -0,0 +1,45 @@
1
+ name: bmad-2d-phaser-game-dev
2
+ version: 1.0.0
3
+ description: 2D Game Development expansion pack for BMAD Method - Phaser 3 & TypeScript focused
4
+ author: BMAD Team
5
+ files:
6
+ - source: agents/game-designer.md
7
+ destination: .bmad-core/agents/game-designer.md
8
+ - source: agents/game-developer.md
9
+ destination: .bmad-core/agents/game-developer.md
10
+ - source: agents/game-sm.md
11
+ destination: .bmad-core/agents/game-sm.md
12
+ - source: team-game-dev.yml
13
+ destination: .bmad-core/agent-teams/team-game-dev.yml
14
+ - source: templates/game-design-doc-tmpl.md
15
+ destination: .bmad-core/templates/game-design-doc-tmpl.md
16
+ - source: templates/game-architecture-tmpl.md
17
+ destination: .bmad-core/templates/game-architecture-tmpl.md
18
+ - source: templates/level-design-doc-tmpl.md
19
+ destination: .bmad-core/templates/level-design-doc-tmpl.md
20
+ - source: templates/game-story-tmpl.md
21
+ destination: .bmad-core/templates/game-story-tmpl.md
22
+ - source: templates/game-brief-tmpl.md
23
+ destination: .bmad-core/templates/game-brief-tmpl.md
24
+ - source: tasks/create-game-story.md
25
+ destination: .bmad-core/tasks/create-game-story.md
26
+ - source: tasks/game-design-brainstorming.md
27
+ destination: .bmad-core/tasks/game-design-brainstorming.md
28
+ - source: tasks/advanced-elicitation.md
29
+ destination: .bmad-core/tasks/advanced-elicitation.md
30
+ - source: checklists/game-story-dod-checklist.md
31
+ destination: .bmad-core/checklists/game-story-dod-checklist.md
32
+ - source: checklists/game-design-checklist.md
33
+ destination: .bmad-core/checklists/game-design-checklist.md
34
+ - source: data/bmad-kb.md
35
+ destination: .bmad-core/data/bmad-kb.md
36
+ - source: data/development-guidelines.md
37
+ destination: .bmad-core/data/development-guidelines.md
38
+ - source: workflows/game-dev-greenfield.yml
39
+ destination: .bmad-core/workflows/game-dev-greenfield.yml
40
+ - source: workflows/game-prototype.yml
41
+ destination: .bmad-core/workflows/game-prototype.yml
42
+ dependencies:
43
+ - architect
44
+ - developer
45
+ - sm