Enha: mime move check; start game backlog msg
This commit is contained in:
		| @@ -41,7 +41,7 @@ func HandleShowColor(w http.ResponseWriter, r *http.Request) { | |||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 	if fi.State.Role != "guesser" { | 	if fi.State.Role != "guesser" { | ||||||
| 		err = errors.New("need to guesser to open the card") | 		err = errors.New("need to be guesser to open the card") | ||||||
| 		abortWithError(w, err.Error()) | 		abortWithError(w, err.Error()) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -180,6 +180,15 @@ func HandleStartGame(w http.ResponseWriter, r *http.Request) { | |||||||
| 	loadCards(fi.Room) | 	loadCards(fi.Room) | ||||||
| 	fi.Room.UpdateCounter() | 	fi.Room.UpdateCounter() | ||||||
| 	fi.Room.TeamWon = "" | 	fi.Room.TeamWon = "" | ||||||
|  | 	action := models.Action{ | ||||||
|  | 		Actor:      fi.State.Username, | ||||||
|  | 		ActorColor: string(fi.State.Team), | ||||||
|  | 		WordColor:  string(fi.State.Team), | ||||||
|  | 		Action:     "game started", | ||||||
|  | 		// Word:       clue, | ||||||
|  | 		// Number:     num, | ||||||
|  | 	} | ||||||
|  | 	fi.Room.ActionHistory = append(fi.Room.ActionHistory, action) | ||||||
| 	if err := saveFullInfo(fi); err != nil { | 	if err := saveFullInfo(fi); err != nil { | ||||||
| 		abortWithError(w, err.Error()) | 		abortWithError(w, err.Error()) | ||||||
| 		return | 		return | ||||||
| @@ -196,6 +205,7 @@ func HandleStartGame(w http.ResponseWriter, r *http.Request) { | |||||||
| 	} | 	} | ||||||
| 	// to update only the room that should be updated | 	// to update only the room that should be updated | ||||||
| 	notify(models.NotifyRoomUpdatePrefix+fi.Room.ID, "") | 	notify(models.NotifyRoomUpdatePrefix+fi.Room.ID, "") | ||||||
|  | 	// notify(models.NotifyBacklogPrefix+fi.Room.ID, "game started") | ||||||
| 	tmpl.ExecuteTemplate(w, "room", fi) | 	tmpl.ExecuteTemplate(w, "room", fi) | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -240,6 +250,23 @@ func HandleGiveClue(w http.ResponseWriter, r *http.Request) { | |||||||
| 		abortWithError(w, err.Error()) | 		abortWithError(w, err.Error()) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
|  | 	// validations === | ||||||
|  | 	if fi.State.Team != models.UserTeam(fi.Room.TeamTurn) { | ||||||
|  | 		err = errors.New("not your team's move") | ||||||
|  | 		abortWithError(w, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	if fi.State.Role != "mime" { | ||||||
|  | 		err = errors.New("need to be mime to open the card") | ||||||
|  | 		abortWithError(w, err.Error()) | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	if fi.Room.MimeDone { | ||||||
|  | 		// team already have a clue | ||||||
|  | 		abortWithError(w, "your team already has a clue") | ||||||
|  | 		return | ||||||
|  | 	} | ||||||
|  | 	// === | ||||||
| 	action := models.Action{ | 	action := models.Action{ | ||||||
| 		Actor:      fi.State.Username, | 		Actor:      fi.State.Username, | ||||||
| 		ActorColor: string(fi.State.Team), | 		ActorColor: string(fi.State.Team), | ||||||
|   | |||||||
							
								
								
									
										3
									
								
								todos.md
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								todos.md
									
									
									
									
									
								
							| @@ -19,6 +19,5 @@ | |||||||
| ### issues | ### issues | ||||||
| - after the game started (isrunning) players should be able join guessers, but not switch team, or join as a mime; | - after the game started (isrunning) players should be able join guessers, but not switch team, or join as a mime; | ||||||
| - do not let wrong team press buttons; | - do not let wrong team press buttons; | ||||||
| - mime can give clues out of turn; |  | ||||||
| - guesser can guess the word before the clue; |  | ||||||
| - cleanup backlog after new game is started; | - cleanup backlog after new game is started; | ||||||
|  | - guesser: word is not found | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder