func Begin(teamId int64) error { track, err := table.FindTrackForTeam(teamId) if err != nil { return err } _, err = table.CreateTeamProgress(teamId, track.QuestionIdOrder[0]) return err }
func Advance(clueId, teamId int64) error { err := table.FinishProgressForClueTeam(time.Now(), clueId, teamId) if err != nil { return err } track, err := table.FindTrackForTeam(teamId) if err != nil { return err } //get next clue id nextClueId, err := track.NextClue(clueId) if err != nil { return err } //create new progress for the next clue id return table.StartProgress(nextClueId, teamId) }
func TestFindTrackForTeam(t *T) { beforeTrackTest() track, err := table.FindTrackForTeam(1) rdtest.Assert(t, err == nil, err) rdtest.Assert(t, track.TrackId == 1, "%d", track.TrackId) }