Fix: number of guesses
This commit is contained in:
		| @@ -51,7 +51,6 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) { | ||||
| 		return | ||||
| 	} | ||||
| 	color, exists := fi.Room.WCMap[word] | ||||
| 	log.Debug("got show-color request", "word", word, "color", color) | ||||
| 	if !exists { | ||||
| 		abortWithError(w, "word is not found") | ||||
| 		return | ||||
| @@ -74,17 +73,20 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) { | ||||
| 	// if opened card is of color of opp team, change turn | ||||
| 	oppositeColor := fi.Room.GetOppositeTeamColor() | ||||
| 	fi.Room.OpenedThisTurn++ | ||||
| 	if fi.Room.ThisTurnLimit > 0 { | ||||
| 		if fi.Room.ThisTurnLimit >= fi.Room.OpenedThisTurn { | ||||
| 			// end turn | ||||
| 			fi.Room.TeamTurn = oppositeColor | ||||
| 			fi.Room.MimeDone = false | ||||
| 			fi.Room.OpenedThisTurn = 0 | ||||
| 			fi.Room.ThisTurnLimit = 0 | ||||
| 		} | ||||
| 	log.Debug("got show-color request", "word", word, "color", color, | ||||
| 		"limit", fi.Room.ThisTurnLimit, "opened", fi.Room.OpenedThisTurn, | ||||
| 		"team-turn", fi.Room.TeamTurn, "opposite-color", oppositeColor) | ||||
| 	if fi.Room.OpenedThisTurn >= fi.Room.ThisTurnLimit { | ||||
| 		log.Debug("reached limit", "room", fi.Room) | ||||
| 		// end turn | ||||
| 		fi.Room.TeamTurn = oppositeColor | ||||
| 		fi.Room.MimeDone = false | ||||
| 		fi.Room.OpenedThisTurn = 0 | ||||
| 		fi.Room.ThisTurnLimit = 0 | ||||
| 	} | ||||
| 	switch string(color) { | ||||
| 	case "black": | ||||
| 		log.Debug("opened black word", "room", fi.Room) | ||||
| 		// game over | ||||
| 		fi.Room.IsRunning = false | ||||
| 		fi.Room.IsOver = true | ||||
| @@ -99,6 +101,7 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) { | ||||
| 		fi.Room.ThisTurnLimit = 0 | ||||
| 		fi.Room.ActionHistory = append(fi.Room.ActionHistory, action) | ||||
| 	case "white", string(oppositeColor): | ||||
| 		log.Debug("opened opposite color word", "room", fi.Room, "opposite-color", oppositeColor) | ||||
| 		// end turn | ||||
| 		fi.Room.TeamTurn = oppositeColor | ||||
| 		fi.Room.MimeDone = false | ||||
| @@ -116,8 +119,6 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) { | ||||
| 				WordColor:  models.WordColorBlue, | ||||
| 				Action:     models.ActionTypeGameOver, | ||||
| 			} | ||||
| 			fi.Room.OpenedThisTurn = 0 | ||||
| 			fi.Room.ThisTurnLimit = 0 | ||||
| 			fi.Room.ActionHistory = append(fi.Room.ActionHistory, action) | ||||
| 		} | ||||
| 		if fi.Room.RedCounter == 0 { | ||||
| @@ -131,8 +132,6 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) { | ||||
| 				WordColor:  models.WordColorRed, | ||||
| 				Action:     models.ActionTypeGameOver, | ||||
| 			} | ||||
| 			fi.Room.OpenedThisTurn = 0 | ||||
| 			fi.Room.ThisTurnLimit = 0 | ||||
| 			fi.Room.ActionHistory = append(fi.Room.ActionHistory, action) | ||||
| 		} | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder