Пример #1
0
func TestIncrementHintsTakenForClueTeam(t *T) {
	beforeTeamProgressTest()

	err := table.IncrementHintsTakenForClueTeam(1, 1)
	rdtest.Assert(t, err == nil, err)
	currentClue, err := table.FindClueWithProgressForTeam(1)
	rdtest.Assert(t, err == nil)
	rdtest.Assert(t, currentClue.HintCnt == 1)
}
Пример #2
0
//Ask should get the current hint for team
//It should return nothing when all hints have been taken
//This assumes each clue only has two hints
func Ask(teamId int64) (string, error) {

	currentClue, err := table.FindClueWithProgressForTeam(teamId)
	if err != nil {
		return "", err
	}

	if currentClue.HintCnt < 2 {
		err = table.IncrementHintsTakenForClueTeam(currentClue.Clue.ClueId, teamId)
		if err != nil {
			return "", err
		}
	}

	switch currentClue.HintCnt {
	case 0:
		return currentClue.Clue.HintOne, nil
	case 1:
		return currentClue.Clue.HintTwo, nil
	default:
		return "", NoHintsLeft
	}
}