Feat: update stats
This commit is contained in:
		| @@ -71,6 +71,7 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) { | ||||
| 		abortWithError(w, err.Error()) | ||||
| 		return | ||||
| 	} | ||||
| 	updateStatsOnCardReveal(r.Context(), fi.State, color) | ||||
| 	fi.Room.UpdateCounter() | ||||
| 	action := models.Action{ | ||||
| 		Actor:      fi.State.Username, | ||||
| @@ -121,6 +122,7 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) { | ||||
| 		fi.Room.ActionHistory = append(fi.Room.ActionHistory, action) | ||||
| 		clearMarks = true | ||||
| 		StopTurnTimer(fi.Room.ID) | ||||
| 		updateStatsOnGameOver(r.Context(), fi.Room) | ||||
| 	case string(models.WordColorWhite), string(oppositeColor): | ||||
| 		log.Debug("opened white or opposite color word", "word", word, "opposite-color", oppositeColor) | ||||
| 		// end turn | ||||
| @@ -144,6 +146,7 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) { | ||||
| 				Action:     models.ActionTypeGameOver, | ||||
| 			} | ||||
| 			fi.Room.ActionHistory = append(fi.Room.ActionHistory, action) | ||||
| 			updateStatsOnGameOver(r.Context(), fi.Room) | ||||
| 		} | ||||
| 		if fi.Room.RedCounter == 0 { | ||||
| 			// red won | ||||
| @@ -158,6 +161,7 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) { | ||||
| 				Action:     models.ActionTypeGameOver, | ||||
| 			} | ||||
| 			fi.Room.ActionHistory = append(fi.Room.ActionHistory, action) | ||||
| 			updateStatsOnGameOver(r.Context(), fi.Room) | ||||
| 		} | ||||
| 	default: // same color as the team | ||||
| 		// check if game over | ||||
| @@ -173,6 +177,7 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) { | ||||
| 				Action:     models.ActionTypeGameOver, | ||||
| 			} | ||||
| 			fi.Room.ActionHistory = append(fi.Room.ActionHistory, action) | ||||
| 			updateStatsOnGameOver(r.Context(), fi.Room) | ||||
| 		} | ||||
| 	} | ||||
| 	if clearMarks { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder