Feat: game over event to be seen in backog
This commit is contained in:
@ -90,6 +90,13 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) {
|
||||
fi.Room.IsRunning = false
|
||||
fi.Room.IsOver = true
|
||||
fi.Room.TeamWon = oppositeColor
|
||||
action := models.Action{
|
||||
Actor: fi.State.Username,
|
||||
ActorColor: string(fi.State.Team),
|
||||
WordColor: "black",
|
||||
Action: "game over",
|
||||
}
|
||||
fi.Room.ActionHistory = append(fi.Room.ActionHistory, action)
|
||||
case "white", string(oppositeColor):
|
||||
// end turn
|
||||
fi.Room.TeamTurn = oppositeColor
|
||||
@ -101,12 +108,26 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) {
|
||||
fi.Room.IsRunning = false
|
||||
fi.Room.IsOver = true
|
||||
fi.Room.TeamWon = "blue"
|
||||
action := models.Action{
|
||||
Actor: fi.State.Username,
|
||||
ActorColor: string(fi.State.Team),
|
||||
WordColor: "blue",
|
||||
Action: "game over",
|
||||
}
|
||||
fi.Room.ActionHistory = append(fi.Room.ActionHistory, action)
|
||||
}
|
||||
if fi.Room.RedCounter == 0 {
|
||||
// red won
|
||||
fi.Room.IsRunning = false
|
||||
fi.Room.IsOver = true
|
||||
fi.Room.TeamWon = "red"
|
||||
action := models.Action{
|
||||
Actor: fi.State.Username,
|
||||
ActorColor: string(fi.State.Team),
|
||||
WordColor: "red",
|
||||
Action: "game over",
|
||||
}
|
||||
fi.Room.ActionHistory = append(fi.Room.ActionHistory, action)
|
||||
}
|
||||
if err := saveFullInfo(fi); err != nil {
|
||||
abortWithError(w, err.Error())
|
||||
|
Reference in New Issue
Block a user