Fix: check game over by opening cards
This commit is contained in:
@ -138,6 +138,21 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) {
|
||||
fi.Room.ActionHistory = append(fi.Room.ActionHistory, action)
|
||||
fi.Room.ClearMarks()
|
||||
}
|
||||
default: // same color as the team
|
||||
// check if game over
|
||||
if fi.Room.RedCounter == 0 || fi.Room.BlueCounter == 0 {
|
||||
fi.Room.IsRunning = false
|
||||
fi.Room.IsOver = true
|
||||
fi.Room.TeamWon = fi.State.Team
|
||||
action := models.Action{
|
||||
Actor: fi.State.Username,
|
||||
ActorColor: string(fi.State.Team),
|
||||
WordColor: models.WordColorRed,
|
||||
Action: models.ActionTypeGameOver,
|
||||
}
|
||||
fi.Room.ActionHistory = append(fi.Room.ActionHistory, action)
|
||||
fi.Room.ClearMarks()
|
||||
}
|
||||
}
|
||||
if err := saveFullInfo(fi); err != nil {
|
||||
abortWithError(w, err.Error())
|
||||
|
Reference in New Issue
Block a user