示例#1
0
func TestFinishProgressForClueTeam(t *T) {
	beforeTeamProgressTest()

	now := time.Now()

	err := table.FinishProgressForClueTeam(now, 1, 1)
	rdtest.Assert(t, err == nil, err)

	p, err := table.FindProgressByClueTeam(1, 1)
	rdtest.Assert(t, err == nil, err)
	rdtest.Assert(
		t,
		int64(math.Abs(float64(p.AnswerTime.Time.Unix()-now.Unix()))) <= 1,
		"%d != %d", p.AnswerTime.Time.Unix(), now.Unix())
}
示例#2
0
文件: advance.go 项目: pjherring/ggc
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)
}
示例#3
0
文件: progress.go 项目: pjherring/ggc
//advances the team to the next clue
func advanceProgress(c *record.Clue, t *record.Team) error {

	//mark progress as answered
	table.FinishProgressForClueTeam(time.Now(), c.ClueId, t.TeamId)

	//get next clue in track
	track, err := table.FindTrack(t.TrackId)
	if err != nil {
		return err
	}

	//get next clue id
	nextClueId, err := track.NextClue(c.ClueId)
	if err != nil {
		return err
	}

	//create new progress for the next clue id
	return table.StartProgress(nextClueId, t.TeamId)
}