forked from tildetown/town
have wire guy respond to email
parent
3d877ea184
commit
2f6164635f
|
@ -31,9 +31,10 @@ type scene struct {
|
|||
SorryMsg string
|
||||
Input *bytes.Buffer
|
||||
OnAdvance func(*scene)
|
||||
OnMsg func(*scene, *tview.TextView, string)
|
||||
}
|
||||
|
||||
func newScene(name, desc, sorryMsg string, host *character, onAdvance func(*scene)) *scene {
|
||||
func newScene(name, desc, sorryMsg string, host *character, onAdvance func(*scene), onMsg func(*scene, *tview.TextView, string)) *scene {
|
||||
return &scene{
|
||||
Name: name,
|
||||
Description: desc,
|
||||
|
@ -41,6 +42,7 @@ func newScene(name, desc, sorryMsg string, host *character, onAdvance func(*scen
|
|||
Host: host,
|
||||
Input: bytes.NewBuffer([]byte{}),
|
||||
OnAdvance: onAdvance,
|
||||
OnMsg: onMsg,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -200,7 +202,12 @@ func _main(l *log.Logger, db *sql.DB) error {
|
|||
`),
|
||||
"i'm sorry, before going further could you share an email with me?",
|
||||
newCharacter("wire guy", "a lil homonculus made of discarded computer cables"),
|
||||
func(s *scene) { su.Email = string(s.Input.Bytes()) }),
|
||||
func(s *scene) { su.Email = string(s.Input.Bytes()) },
|
||||
func(s *scene, tv *tview.TextView, msg string) {
|
||||
// TODO could check and see if it's email shaped and admonish if not
|
||||
trimmed := strings.TrimSpace(msg)
|
||||
fmt.Fprintln(tv, s.Host.Say(fmt.Sprintf("I heard '%s'. Is that right?", trimmed)))
|
||||
}),
|
||||
newScene("how", heredoc.Doc(`
|
||||
The workshop fades away. You hear the sound of a dial up modem
|
||||
in the distance.
|
||||
|
@ -221,7 +228,7 @@ func _main(l *log.Logger, db *sql.DB) error {
|
|||
`),
|
||||
"phweeturpff",
|
||||
newCharacter("the shrike", "a little grey bird. it has a pretty song."),
|
||||
func(s *scene) { su.How = string(s.Input.Bytes()) }),
|
||||
func(s *scene) { su.How = string(s.Input.Bytes()) }, nil),
|
||||
newScene("what", heredoc.Doc(`
|
||||
You sink down into soft mossy floor of the forest. You find yourself floating in darkness.
|
||||
|
||||
|
@ -237,7 +244,7 @@ func _main(l *log.Logger, db *sql.DB) error {
|
|||
`),
|
||||
"hmm did you say something?",
|
||||
newCharacter("the vcr", "a black and grey VCR from 1991"),
|
||||
func(s *scene) { su.Why = string(s.Input.Bytes()) }),
|
||||
func(s *scene) { su.Why = string(s.Input.Bytes()) }, nil),
|
||||
newScene("link", heredoc.Doc(`
|
||||
You realize your eyes have been shut. You open them and, in an instant,
|
||||
the neon grid and polygons are gone. You're in a convenience store. Outside
|
||||
|
@ -258,7 +265,7 @@ func _main(l *log.Logger, db *sql.DB) error {
|
|||
`),
|
||||
"just the one last thing please",
|
||||
newCharacter("the mop", "a greying mop with a wooden handle."),
|
||||
func(s *scene) { su.Links = string(s.Input.Bytes()) }),
|
||||
func(s *scene) { su.Links = string(s.Input.Bytes()) }, nil),
|
||||
newScene("done", heredoc.Doc(`
|
||||
thank you for applying to tilde.town!
|
||||
|
||||
|
@ -274,7 +281,7 @@ func _main(l *log.Logger, db *sql.DB) error {
|
|||
`),
|
||||
"",
|
||||
newCharacter("the æther", "the very air around you"),
|
||||
nil),
|
||||
nil, nil),
|
||||
}
|
||||
|
||||
sm := newSceneManager(msgScroll, scenes)
|
||||
|
@ -321,6 +328,9 @@ func _main(l *log.Logger, db *sql.DB) error {
|
|||
}
|
||||
fmt.Fprintln(msgScroll, player.Say(msg))
|
||||
fmt.Fprintln(sm.Current.Input, msg)
|
||||
if sm.Current.OnMsg != nil {
|
||||
sm.Current.OnMsg(sm.Current, msgScroll, msg)
|
||||
}
|
||||
msgScroll.ScrollToEnd()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue