more refact
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
package inc
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
|
||||
inkwell "git.teletypegames.org/engines/inkwell"
|
||||
)
|
||||
|
||||
func useWithFail(item string, h *inkwell.Hotspot) inkwell.Action {
|
||||
key := "fail." + item + "." + h.Name
|
||||
World.G.State.NoteTalked(key)
|
||||
n := World.G.State.Talked(key)
|
||||
|
||||
return inkwell.Seq(
|
||||
inkwell.Say(Paul, pick(paulFails, n)),
|
||||
inkwell.Say(Dex, dexFail(n)),
|
||||
)
|
||||
}
|
||||
|
||||
var paulFails = []string{
|
||||
"No. That's not going to work.",
|
||||
"Tried that. It didn't improve.",
|
||||
"All right, I know that one doesn't work.",
|
||||
"Now it's personal.",
|
||||
}
|
||||
|
||||
var dexDry = []string{
|
||||
"No. Not like that.",
|
||||
"I heard it. Nothing happened.",
|
||||
}
|
||||
|
||||
var dexTease = []string{
|
||||
"Twice the same. The second one rarely goes better.",
|
||||
"Do it a few more times, maybe physics reconsiders.",
|
||||
}
|
||||
|
||||
func dexFail(n int) string {
|
||||
switch {
|
||||
case n <= 1:
|
||||
return pick(dexDry, n)
|
||||
case n == 2:
|
||||
return pick(dexTease, n)
|
||||
default:
|
||||
return "Paul. Leave it. Look again at what you're carrying — that's where it is."
|
||||
}
|
||||
}
|
||||
|
||||
func pick(s []string, n int) string {
|
||||
switch {
|
||||
case len(s) == 0:
|
||||
return ""
|
||||
case n <= 0:
|
||||
return s[0]
|
||||
case n-1 < len(s):
|
||||
return s[n-1]
|
||||
default:
|
||||
return s[rand.Intn(len(s))]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user