Version : 2.51.0 Branche : feature/memory-multi-teams Timeline : 2h estimées Dépendances : Aucune
internal/game/: Modèles (models.go), moteur (engine.go)internal/server/: HTTP, WebSocket, TCP/UDPinternal/protocol/: Définition des actions
models.go (L172) :
- GameState struct avec 15+ champs existants
- À AJOUTER 3 champs : MemoryCurrentTeam, MemoryTeamPairs, MemoryParticipatingTeams
Question struct (L140+) :
- À AJOUTER champ : MEMORY_MODE string
protocol/messages.go :
- ActionFlipMemoryCard = "FLIP_MEMORY_CARD" (existant)
- À AJOUTER : ActionMemorySetTeams = "MEMORY_SET_TEAMS"
engine.go :
- FlipMemoryCard(cardID string) error (existant, Phase 5)
- À AJOUTER : rotateToNextTeam() fonction
- À MODIFIER : logique FlipMemoryCard()
http.go / websocket.go :
- Handlers WebSocket pour traiter les actions
Ajouter après les champs QCM :
MEMORY_MODE string `json:"MEMORY_MODE,omitempty"`Notes:
- Absence de champ = défaut "SOLO" (rétrocompatibilité)
- Valeurs : "SOLO" | "CHACUN_SON_TOUR" | "TANT_QUE_JE_GAGNE"
Après MemoryErrors int (L184), ajouter :
MemoryCurrentTeam string `json:"MEMORY_CURRENT_TEAM,omitempty"`
MemoryTeamPairs map[string]int `json:"MEMORY_TEAM_PAIRS,omitempty"`
MemoryParticipatingTeams []string `json:"MEMORY_PARTICIPATING_TEAMS,omitempty"`Notes:
- Initialiser maps et slices proprement en fonction
- JSON tags avec omitempty pour optionalité
const (
ActionMemorySetTeams = "MEMORY_SET_TEAMS"
)
type MemorySetTeamsPayload struct {
Teams []string `json:"Teams"`
}Dans le handler WebSocket (http.go ou websocket.go), ajouter case:
case protocol.ActionMemorySetTeams:
// Valider payload
// Vérifier question est MEMORY
// Valider min 2 équipes en multi-équipes
// Initialiser GameState.MemoryParticipatingTeams
// Initialiser GameState.MemoryCurrentTeam = premier
// Initialiser GameState.MemoryTeamPairs (map vide)
// Broadcast GAME_STATE mis à jourfunc (gs *GameState) rotateToNextTeam() {
// Trouver index équipe courante
// Passer à l'index suivant (modulo)
// Mettre à jour MemoryCurrentTeam
}Ajouter après logique flip :
Pour Mode CHACUN_SON_TOUR :
- Après 2 cartes révélées, appeler rotateToNextTeam()
- Peu importe match ou non
Pour Mode TANT_QUE_JE_GAGNE :
- Si match : incrémenter MemoryTeamPairs, continuer
- Si non-match : incrémenter erreurs, appeler rotateToNextTeam()
Pour Mode SOLO :
- Comportement identique Phase 5
Après appel rotateToNextTeam(), broadcaster :
{
"ACTION": "MEMORY_TEAM_CHANGED",
"MSG": {
"CurrentTeam": "...",
"TeamIndex": 0,
"PairsCount": {...}
}
}Ajouter champs à l'événement :
"Mode": "CHACUN_SON_TOUR",
"TeamResults": {
"Équipe1": {"Pairs": 2, "Points": 20},
"Équipe2": {"Pairs": 1, "Points": 10}
}Avant de push :
- go build doit passer (compilation sans erreur)
- go test ./... doit passer (tous les tests existants)
- Rétrocompatibilité : Questions Phase 5 sans MEMORY_MODE doivent marcher
- Logique rotation : modulo fonctionne correctement
- Scores : MemoryTeamPairs mis à jour et broadcaté
- feat(models): Add MEMORY_MODE to Question and multi-team fields to GameState
- feat(protocol): Add MEMORY_SET_TEAMS action definition
- feat(engine): Implement rotateToNextTeam and multi-team flip logic
- feat(websocket): Handle MEMORY_SET_TEAMS action and broadcast MEMORY_TEAM_CHANGED
- feat(history): Enrich MEMORY_COMPLETED with multi-team results
- Contrats API : contracts/memory-phase6.md
- Plan : IMPLEMENTATION_PLAN_PHASE6.md
- Backlog Phase 6 : backlog/En-Cours/memory-game.md (section Phase 6)
EOF