Feat: start game
This commit is contained in:
		| @@ -161,3 +161,27 @@ func HandleEndTurn(w http.ResponseWriter, r *http.Request) { | ||||
| 	} | ||||
| 	tmpl.ExecuteTemplate(w, "base", fi) | ||||
| } | ||||
|  | ||||
| func HandleStartGame(w http.ResponseWriter, r *http.Request) { | ||||
| 	fi, err := getFullInfoByCtx(r.Context()) | ||||
| 	if err != nil { | ||||
| 		abortWithError(w, err.Error()) | ||||
| 		return | ||||
| 	} | ||||
| 	// TODO: check if enough players; also button should be hidden if already running | ||||
| 	fi.Room.IsRunning = true | ||||
| 	fi.Room.IsOver = false | ||||
| 	fi.Room.TeamTurn = "blue" | ||||
| 	fi.Room.LoadTestCards() | ||||
| 	if err := saveFullInfo(fi); err != nil { | ||||
| 		abortWithError(w, err.Error()) | ||||
| 		return | ||||
| 	} | ||||
| 	// return html | ||||
| 	tmpl, err := template.ParseGlob("components/*.html") | ||||
| 	if err != nil { | ||||
| 		abortWithError(w, err.Error()) | ||||
| 		return | ||||
| 	} | ||||
| 	tmpl.ExecuteTemplate(w, "room", fi) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder