Randomize all the options if omitted

If an option for a pronoun, verb, noun, or noun_phrase is omitted it
will be randomized.
This commit is contained in:
Zorchenhimer 2021-02-21 20:07:42 -05:00
parent de79b26f57
commit 92e3a5aeb0
Signed by: Zorchenhimer
GPG Key ID: 70A1AB767AAB9C20
1 changed files with 15 additions and 5 deletions

View File

@ -272,9 +272,11 @@ func (g *english) consumeWord(fmtString string, idx int, output *strings.Builder
switch wordtype { switch wordtype {
case "pronoun": case "pronoun":
var plural bool var plural bool = rand.Int() % 2 == 0
if sliceContains(opts, "plural") { if sliceContains(opts, "plural") {
plural = true plural = true
} else if sliceContains(opts, "singular")
plural = false
} }
word, err = g.randomPronoun(plural) word, err = g.randomPronoun(plural)
@ -300,25 +302,33 @@ func (g *english) consumeWord(fmtString string, idx int, output *strings.Builder
} }
case "noun_phrase": case "noun_phrase":
var definite bool = true var definite bool = rand.Int() % 2 == 0
var hasAdj bool = true var hasAdj bool = rand.Int() % 2 == 0
var plural bool = false var plural bool = rand.Int() % 2 == 0
var compound bool = false var compound bool = rand.Int() % 2 == 0
if sliceContains(opts, "indefinite") { if sliceContains(opts, "indefinite") {
definite = false definite = false
} else if sliceContains(opts, "definite") {
definite = true
} }
if sliceContains(opts, "noadj") { if sliceContains(opts, "noadj") {
hasAdj = false hasAdj = false
} else if sliceContains(opts, "adj") {
hasAdj = true
} }
if sliceContains(opts, "plural") { if sliceContains(opts, "plural") {
plural = true plural = true
} else if sliceContains(opts, "singular") {
plural = false
} }
if sliceContains(opts, "compound") { if sliceContains(opts, "compound") {
compound = true compound = true
} else if sliceContains(opts, "simple") {
compound = false
} }
word, err = g.nounPhrase(definite, hasAdj, plural, compound) word, err = g.nounPhrase(definite, hasAdj, plural, compound)