summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2019-01-06 12:44:07 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2019-01-06 12:44:07 +0000
commit5efe8fddc7b4db3033e72dbdf577b77a856a0937 (patch)
tree8f3a30e333d597a7bbe6d6247dcaf7bb56a58a06
parentEnsure no sound escapes between activities (diff)
downloadtoy-5efe8fddc7b4db3033e72dbdf577b77a856a0937.zip
Split out sentence composer
-rw-r--r--scripts/toy.groovy10
1 files changed, 7 insertions, 3 deletions
diff --git a/scripts/toy.groovy b/scripts/toy.groovy
index e927151..049ee56 100644
--- a/scripts/toy.groovy
+++ b/scripts/toy.groovy
@@ -238,11 +238,15 @@ def gagText = { t, p ->
def showButtonG = { s, p, t = null ->
return t != null ? showButton(gagText(s, p), t) : showButton(gagText(s, p));
};
+def compose = { texts ->
+ if (!texts || texts.isEmpty()) return null;
+ return texts.collect {
+ t -> t[getRandom(t.size())]
+ }.join(" ").capitalize();
+};
def present = { imageSpec, texts ->
if (texts) {
- show(texts.collect {
- t -> t[getRandom(t.size())]
- }.join(" ").capitalize());
+ show(compose(texts));
}
if (imageSpec) {
return showImage(imageSpec);