have hosts talk when no answer

trunk
vilmibm 2023-02-10 20:05:06 +00:00
parent 4dbeb6984f
commit ea484671ed
1 changed files with 27 additions and 6 deletions

View File

@ -112,6 +112,7 @@ func cli(s *streams) error {
Description string
InBuff io.ReadWriter
InLength int
Host *character
}
scenes := map[string]*scene{
@ -132,6 +133,7 @@ func cli(s *streams) error {
just say it out loud. as many times as you need. to get it right.
when you're ready to move on, [-:-:b]/nod[-:-:-]
`),
Host: newCharacter("wire guy", "a lil homonculus made of discarded computer cables"),
InBuff: bytes.NewBuffer([]byte{}),
},
"nodded": {
@ -154,6 +156,7 @@ func cli(s *streams) error {
against a tree.
`),
InBuff: bytes.NewBuffer([]byte{}),
Host: newCharacter("the shrike", "a little grey bird. it has a pretty song."),
},
"leaned": {
Description: heredoc.Doc(`
@ -171,6 +174,7 @@ func cli(s *streams) error {
around in this void.
`),
InBuff: bytes.NewBuffer([]byte{}),
Host: newCharacter("the vcr", "a black and grey VCR from 1991"),
},
"spun": {
Description: heredoc.Doc(`
@ -193,6 +197,7 @@ func cli(s *streams) error {
store. just [-:-:b]/open[-:-:-] the door.
`),
InBuff: bytes.NewBuffer([]byte{}),
Host: newCharacter("the mop", "a greying mop with a wooden handle."),
},
"done": {
Description: heredoc.Doc(`
@ -220,7 +225,7 @@ func cli(s *streams) error {
}
switch strings.TrimPrefix(trimmed, "/") {
case "quit":
os.Exit(0)
app.Stop()
case "look":
fmt.Fprintln(msgScroll, "")
fmt.Fprintln(msgScroll, scenes[currentScene].Description)
@ -229,28 +234,44 @@ func cli(s *streams) error {
if currentScene != "start" {
return
}
if scenes[currentScene].InLength > 0 {
currentScene = "nodded"
sceneTransition(scenes[currentScene].Description)
} else {
// say sorry, ask for input
if scenes[currentScene].InLength == 0 {
fmt.Fprintln(msgScroll,
scenes[currentScene].Host.Say("i'm sorry, before going further could you share an email with me?"))
return
}
currentScene = "nodded"
sceneTransition(scenes[currentScene].Description)
case "lean":
if currentScene != "nodded" {
return
}
if scenes[currentScene].InLength == 0 {
fmt.Fprintln(msgScroll,
scenes[currentScene].Host.Say("phweeturpff"))
return
}
currentScene = "leaned"
sceneTransition(scenes[currentScene].Description)
case "spin":
if currentScene != "leaned" {
return
}
if scenes[currentScene].InLength == 0 {
fmt.Fprintln(msgScroll,
scenes[currentScene].Host.Say("hmm did you say something?"))
return
}
currentScene = "spun"
sceneTransition(scenes[currentScene].Description)
case "open":
if currentScene != "spun" {
return
}
if scenes[currentScene].InLength == 0 {
fmt.Fprintln(msgScroll,
scenes[currentScene].Host.Say("just the one last thing please"))
return
}
currentScene = "done"
sceneTransition(scenes[currentScene].Description)
}