mirror of https://github.com/dirtbags/moth.git
Carry objective and success from static puzzles
This commit is contained in:
parent
fb22032638
commit
89a80ab8ef
|
@ -11,6 +11,10 @@ authors:
|
|||
- Arthur
|
||||
- Buster
|
||||
- DW
|
||||
objective: moo like a cow
|
||||
success:
|
||||
acceptable: say moo
|
||||
mastery: say mrr
|
||||
attachments:
|
||||
- moo.txt
|
||||
---
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue