game workflow corrected

This commit is contained in:
magdo
2025-11-06 19:37:32 +01:00
parent 5a4be5b7d3
commit 5b177c77fc
3 changed files with 63 additions and 1 deletions
+32
View File
@@ -970,6 +970,8 @@ socket.on('game:ended', {
message: string;
finalPositions: PlayerPosition[];
timestamp: string;
reason?: string; // Optional: 'gamemaster_left' if GM disconnected
gamemasterName?: string; // Optional: GM name if GM left
});
// Server → All Players: Cleanup complete
@@ -980,6 +982,36 @@ socket.on('game:cleanup-complete', {
});
```
**Game End Scenarios**:
1. **Normal Win** (Player reaches position 100):
```typescript
{
winner: "player-uuid",
winnerName: "Alice",
message: "🎉 Alice won the game! Congratulations!",
finalPositions: [...],
timestamp: "2025-11-06T..."
}
```
2. **Gamemaster Disconnect** (Game cancelled):
```typescript
{
reason: "gamemaster_left",
gamemasterName: "Bob",
message: "🎭 Gamemaster Bob left. Game has ended.",
timestamp: "2025-11-06T..."
}
```
**Behavior**:
- Game immediately cancelled when gamemaster disconnects
- All players notified via `game:ended` event
- Database updated: `state = CANCELLED`, `enddate = now`
- All Redis data and socket connections cleaned up
- No winner recorded (game didn't complete normally)
---
#### Error Events
Binary file not shown.