diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-07-08 21:02:59 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-07-08 21:02:59 +0100 |
commit | 6d1e69e8aa279a17894fbb67cbd6cb58cb471a7c (patch) | |
tree | f8a8c6371c4630189d5a738fa9c8a7e49435b05f /scripts | |
parent | Tag all activities (diff) | |
download | toy-6d1e69e8aa279a17894fbb67cbd6cb58cb471a7c.zip |
Extract meets into a tag matching helper
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/toy.groovy | 7 | ||||
-rw-r--r-- | scripts/toy/imagery.groovy | 7 |
2 files changed, 8 insertions, 6 deletions
diff --git a/scripts/toy.groovy b/scripts/toy.groovy index a77c5dd..018c32f 100644 --- a/scripts/toy.groovy +++ b/scripts/toy.groovy @@ -266,6 +266,13 @@ return new Object() { } return tt; }; + final matchTags = { spec -> + return { obj -> + spec.every({ s -> + return (s[0] == "!") ? obj.tags.indexOf(s.drop(1)) == -1 : obj.tags.indexOf(s) != -1; + }); + }; + }; // Session def sessionSummon = { imageSpec -> diff --git a/scripts/toy/imagery.groovy b/scripts/toy/imagery.groovy index 201531e..9b56faf 100644 --- a/scripts/toy/imagery.groovy +++ b/scripts/toy/imagery.groovy @@ -32,17 +32,12 @@ }(); toy.metaClass.selectImage { domme, set, spec -> - final meets = { i -> - return spec.every({ s -> - return (s[0] == "!") ? i.tags.indexOf(s.drop(1)) == -1 : i.tags.indexOf(s) != -1; - }); - }; def matches = IMAGEDATA[domme]; if (!matches) return null; matches = matches.sets[set]; if (!matches) return null; matches = matches - .images.findAll({ i -> meets(i) }); + .images.findAll(matchTags(spec)); if (matches.isEmpty()) return null; return matches[getRandom(matches.size())]; }; |