game workflow corrected
This commit is contained in:
@@ -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.
Reference in New Issue
Block a user