示例#1
0
func TestCurrentClueForTeam_NoProgress(t *testing.T) {
	beforeCurrentTest()

	clue, err := clues.CurrentForTeam(2, clues.NoExpectedId)
	rdtest.Assert(t, err == nil, err)
	rdtest.Assert(t, clue.ClueId == 1)
}
示例#2
0
文件: clue.go 项目: pjherring/ggc
func solveClue(ctx *_Context) (err error) {

	req := ctx.req.(*_SolveClueReq)
	err = clues.Answer(
		ctx.urlParams["clue_id"].(int64),
		ctx.loggedIn.Team.TeamId,
		req.Answer,
	)

	if err != nil {
		return
	}

	curr, err := clues.CurrentForTeam(
		ctx.loggedIn.Team.TeamId,
		clues.NoExpectedId,
	)

	//never display an advancement reason after answering a question
	curr.AdvancementReason = ""

	ctx.resp = curr

	return
}
示例#3
0
func TestCurrentClueForTeam_ClueDisabled(t *testing.T) {
	beforeCurrentTest()

	log.Println("before")
	clue, err := clues.CurrentForTeam(1, 2)

	rdtest.Assert(t, err == nil, err)
	rdtest.Assert(t, clue.ClueId == 3)
	rdtest.Assert(t, clue.AdvancementReason == clues.DisabledAdvancement, "Actual (%s)", clue.AdvancementReason)
}
示例#4
0
func TestCurrentClueForTeam_NoMoreHints(t *testing.T) {
	beforeCurrentTest()

	clue, err := clues.CurrentForTeam(2, 1)

	rdtest.Assert(t, err == nil, err)
	rdtest.Assert(t, clue.ClueId == 1)
	rdtest.Assert(t, len(clue.Hints) == 2, "Actual (%d)", len(clue.Hints))
	rdtest.Assert(t, clue.Hints[0] == "Hint 1A")
	rdtest.Assert(t, clue.Hints[1] == "Hint 1B")
	rdtest.Assert(t, !clue.MoreHintsExist)
}
示例#5
0
func TestCurrentClueForTeam_ClueAnswered(t *testing.T) {

	beforeCurrentTest()

	clue, err := clues.CurrentForTeam(3, 3)

	rdtest.Assert(t, err == nil, err)
	rdtest.Assert(t, clue.ClueId == 4)
	rdtest.Assert(t, clue.AdvancementReason == clues.AnsweredAdvancement)
	rdtest.Assert(t, len(clue.Hints) == 1)
	rdtest.Assert(t, clue.Hints[0] == "Hint 4A")
	rdtest.Assert(t, clue.MoreHintsExist)
}
示例#6
0
文件: clue.go 项目: pjherring/ggc
func currentClue(ctx *_Context) error {

	var err error

	expectedClueId := clues.NoExpectedId

	if v, ok := ctx.urlParams["clue_id"]; ok {
		expectedClueId = v.(int64)
	}

	ctx.resp, err = clues.CurrentForTeam(ctx.loggedIn.Team.TeamId, expectedClueId)

	return err
}