summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2019-03-16 12:04:02 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2019-03-16 12:04:02 +0000
commitd87aa9c1b183b8de7f0f20e762a2ba7720f6fd11 (patch)
tree17f4a2705e13883dc161f5b45ca7d6be35d10bab /scripts
parentSimplify image data 1 (diff)
downloadtoy-d87aa9c1b183b8de7f0f20e762a2ba7720f6fd11.zip
Simplify image data 2
Diffstat (limited to 'scripts')
-rw-r--r--scripts/toy.groovy55
1 files changed, 27 insertions, 28 deletions
diff --git a/scripts/toy.groovy b/scripts/toy.groovy
index 1f0547c..fdcc10f 100644
--- a/scripts/toy.groovy
+++ b/scripts/toy.groovy
@@ -48,30 +48,30 @@ final IMAGEDATA = {
return new File("$DATAFOLDER/images/toy")
.listFiles()
.findAll { d -> d.isDirectory(); }
- .collectEntries { d ->
- [
- d.getName(), [
- sets: d.listFiles()
- .findAll { s -> s.isDirectory(); }
- .collect { s -> [ sub: s, f: new File(s.getPath() + "/tags")] }
- .findAll { s -> s.f.canRead() }
- .collect { s ->
- [
- set: s.sub.getName(),
- images: s.f
- .readLines()
- .collect { l ->
- def fields = l.split(":");
- return [
- image: fields[0],
- tags: fields[1]
- .split(",")
- .findAll { t -> !t.isEmpty() }
- ];
- }
- ]
- }
- ]
+ .collectEntries { d -> [
+ d.getName(), [
+ domme: d.getName(),
+ sets: d.listFiles()
+ .findAll { s -> s.isDirectory(); }
+ .collect { s -> [ sub: s, f: new File(s.getPath() + "/tags")] }
+ .findAll { s -> s.f.canRead() }
+ .collectEntries { s -> [
+ s.sub.getName(), [
+ set: s.sub.getName(),
+ images: s.f
+ .readLines()
+ .collect { l ->
+ def fields = l.split(":");
+ return [
+ image: fields[0],
+ tags: fields[1]
+ .split(",")
+ .findAll { t -> !t.isEmpty() }
+ ];
+ }
+ ]
+ ]}
+ ]
]
};
}();
@@ -83,8 +83,7 @@ def selectImage = { domme, set, spec ->
};
def matches = IMAGEDATA[domme];
if (!matches) return null;
- matches = matches
- .sets.find({ s -> s.set == set });
+ matches = matches.sets[set];
if (!matches) return null;
matches = matches
.images.findAll({ i -> meets(i) });
@@ -109,7 +108,7 @@ def showLounge = {
def selectImageSet = { domme, specs ->
def matches = IMAGEDATA[domme];
if (!matches) return null;
- matches = matches.sets.findAll({ s -> specs.every({ spec -> selectImage(domme, s.set, spec)})});
+ matches = matches.sets.values().findAll({ s -> specs.every({ spec -> selectImage(domme, s.set, spec)})});
return matches[getRandom(matches.size())];
};
def dress = { specs ->
@@ -118,7 +117,7 @@ def dress = { specs ->
if (outfitTime > getTime() - 7200) { // Recent, check
def prev = IMAGEDATA[OWNER];
if (prev) {
- prev = prev.sets.find({ s -> s.set == outfit });
+ prev = prev.sets[outfit];
if (prev && specs.every({ spec -> selectImage(OWNER, prev.set, spec)})) {
return outfit;
}