Carry objective and success from static puzzles

This commit is contained in:
Neale Pickett 2021-02-25 13:07:44 -07:00
parent fb22032638
commit 89a80ab8ef
3 changed files with 17 additions and 2 deletions

View File

@ -11,6 +11,10 @@ authors:
- Arthur
- Buster
- DW
objective: moo like a cow
success:
acceptable: say moo
mastery: say mrr
attachments:
- moo.txt
---

View File

@ -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

View File

@ -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 != "<p>YAML body</p>\n" {
t.Errorf("Body parsed wrong: %#v", p.Body)
}