From 89a80ab8ef57cbc5ee4a620a656a6ae3de65e7c5 Mon Sep 17 00:00:00 2001 From: Neale Pickett Date: Thu, 25 Feb 2021 13:07:44 -0700 Subject: [PATCH] Carry objective and success from static puzzles --- pkg/transpile/common_test.go | 4 ++++ pkg/transpile/puzzle.go | 6 ++++-- pkg/transpile/puzzle_test.go | 9 +++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/pkg/transpile/common_test.go b/pkg/transpile/common_test.go index f151208..6a51cfc 100644 --- a/pkg/transpile/common_test.go +++ b/pkg/transpile/common_test.go @@ -11,6 +11,10 @@ authors: - Arthur - Buster - DW +objective: moo like a cow +success: + acceptable: say moo + mastery: say mrr attachments: - moo.txt --- diff --git a/pkg/transpile/puzzle.go b/pkg/transpile/puzzle.go index eacde24..8c8360c 100644 --- a/pkg/transpile/puzzle.go +++ b/pkg/transpile/puzzle.go @@ -188,10 +188,14 @@ func (fp FsPuzzle) Puzzle() (Puzzle, error) { return puzzle, err } + fmt.Println(static) + // Convert to an exportable Puzzle puzzle.Debug = static.Debug puzzle.Answers = static.Answers puzzle.Authors = static.Authors + puzzle.Objective = static.Objective + puzzle.Success = static.Success puzzle.Body = string(body) puzzle.AnswerPattern = static.AnswerPattern puzzle.Attachments = make([]string, len(static.Attachments)) @@ -202,8 +206,6 @@ func (fp FsPuzzle) Puzzle() (Puzzle, error) { for i, script := range static.Scripts { puzzle.Scripts[i] = script.Filename } - empty := Puzzle{} - puzzle.Debug = empty.Debug puzzle.computeAnswerHashes() return puzzle, nil diff --git a/pkg/transpile/puzzle_test.go b/pkg/transpile/puzzle_test.go index 4d4d6b1..a8a6be4 100644 --- a/pkg/transpile/puzzle_test.go +++ b/pkg/transpile/puzzle_test.go @@ -26,6 +26,15 @@ func TestPuzzle(t *testing.T) { if (len(p.Authors) != 3) || (p.Authors[1] != "Buster") { t.Error("Authors are wrong", p.Authors) } + if p.Objective != "moo like a cow" { + t.Error("Wrong objective") + } + if p.Success.Acceptable != "say moo" { + t.Error("Wrong Success.Acceptable") + } + if p.Success.Mastery != "say mrr" { + t.Error("Wrong Success.Mastery") + } if p.Body != "

YAML body

\n" { t.Errorf("Body parsed wrong: %#v", p.Body) }