Beta Release

This commit is contained in:
2020-10-16 15:39:07 -05:00
parent c1f7e8ae91
commit 5f07ea41d2
5 changed files with 162 additions and 8 deletions

View File

@@ -21,6 +21,7 @@ type Ship struct {
Hold map[string]string `json:"-"` // Where dynamic values are stored
Args map[string]string `json:"-"` // Arguments passed in from the command line
Raw []byte `json:"-"`
Deliver string `json:"-"`
loaded bool `json:"-"`
}
@@ -137,16 +138,32 @@ func (s *Ship) Sail(q *Quest) int {
cli.PrintErr(err.Error())
return 1
}
fmt.Println(string(rbody))
err = s.SaveHold()
if err != nil {
cli.PrintErr(err.Error())
return 1
}
if err = s.StandAndDeliver(q, rbody); err != nil {
cli.PrintErr(err.Error())
return 1
}
return 0
}
func (s *Ship) StandAndDeliver(q *Quest, body []byte) error {
if s.Deliver == "" {
fmt.Println(string(body))
} else {
v, ok := s.Hold[s.Deliver]
if ok {
fmt.Println(v)
} else {
fmt.Printf("No value for %s in Hold\n", s.Deliver)
}
}
return nil
}
func (s *Ship) Plunder(q *Quest, body []byte) error {
plunder, ok := s.PlunderRules[q.Name]
if !ok {
@@ -161,7 +178,6 @@ func (s *Ship) Plunder(q *Quest, body []byte) error {
s.Hold[k] = val
}
}
return nil
}