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
|
- Arthur
|
||||||
- Buster
|
- Buster
|
||||||
- DW
|
- DW
|
||||||
|
objective: moo like a cow
|
||||||
|
success:
|
||||||
|
acceptable: say moo
|
||||||
|
mastery: say mrr
|
||||||
attachments:
|
attachments:
|
||||||
- moo.txt
|
- moo.txt
|
||||||
---
|
---
|
||||||
|
|
|
@ -188,10 +188,14 @@ func (fp FsPuzzle) Puzzle() (Puzzle, error) {
|
||||||
return puzzle, err
|
return puzzle, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Println(static)
|
||||||
|
|
||||||
// Convert to an exportable Puzzle
|
// Convert to an exportable Puzzle
|
||||||
puzzle.Debug = static.Debug
|
puzzle.Debug = static.Debug
|
||||||
puzzle.Answers = static.Answers
|
puzzle.Answers = static.Answers
|
||||||
puzzle.Authors = static.Authors
|
puzzle.Authors = static.Authors
|
||||||
|
puzzle.Objective = static.Objective
|
||||||
|
puzzle.Success = static.Success
|
||||||
puzzle.Body = string(body)
|
puzzle.Body = string(body)
|
||||||
puzzle.AnswerPattern = static.AnswerPattern
|
puzzle.AnswerPattern = static.AnswerPattern
|
||||||
puzzle.Attachments = make([]string, len(static.Attachments))
|
puzzle.Attachments = make([]string, len(static.Attachments))
|
||||||
|
@ -202,8 +206,6 @@ func (fp FsPuzzle) Puzzle() (Puzzle, error) {
|
||||||
for i, script := range static.Scripts {
|
for i, script := range static.Scripts {
|
||||||
puzzle.Scripts[i] = script.Filename
|
puzzle.Scripts[i] = script.Filename
|
||||||
}
|
}
|
||||||
empty := Puzzle{}
|
|
||||||
puzzle.Debug = empty.Debug
|
|
||||||
puzzle.computeAnswerHashes()
|
puzzle.computeAnswerHashes()
|
||||||
|
|
||||||
return puzzle, nil
|
return puzzle, nil
|
||||||
|
|
|
@ -26,6 +26,15 @@ func TestPuzzle(t *testing.T) {
|
||||||
if (len(p.Authors) != 3) || (p.Authors[1] != "Buster") {
|
if (len(p.Authors) != 3) || (p.Authors[1] != "Buster") {
|
||||||
t.Error("Authors are wrong", p.Authors)
|
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" {
|
if p.Body != "<p>YAML body</p>\n" {
|
||||||
t.Errorf("Body parsed wrong: %#v", p.Body)
|
t.Errorf("Body parsed wrong: %#v", p.Body)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue