diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-06-20 19:33:57 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-06-20 19:33:57 +0100 |
commit | 16c98839c7250d996611f7a233cf034f42386b9d (patch) | |
tree | 34db5771d1da7576ab2eed128c607f9b2d7c61fe /scripts/toy.groovy | |
parent | Extract sleeping into a module (diff) | |
download | toy-16c98839c7250d996611f7a233cf034f42386b9d.zip |
Extract imagery into a module
Diffstat (limited to 'scripts/toy.groovy')
-rw-r--r-- | scripts/toy.groovy | 93 |
1 files changed, 1 insertions, 92 deletions
diff --git a/scripts/toy.groovy b/scripts/toy.groovy index e037277..529f5e0 100644 --- a/scripts/toy.groovy +++ b/scripts/toy.groovy @@ -44,37 +44,6 @@ return new Object() { // Imagery final DRESSED = "dressed", TITS = "tits", PUSSY = "pussy", LINGERIE = "lingerie", TEASE = "tease", SIT = "sit", BOOTS = "boots", KNEEL = "kneel", STOOD = "stood", MEAN = "mean", CROP = "crop", ASS = "ass", SQUAT = "squat", SSSH = "sssh"; final nDRESSED = "!$DRESSED", nTITS = "!$TITS", nTEASE = "!$TEASE"; - final IMAGEDATA = { - return new File("$DATAFOLDER/images/toy") - .listFiles() - .findAll { d -> d.isDirectory(); } - .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() } - ]; - } - ] - ]} - ] - ] - }; - }(); def loadDomme = { domme, set = null -> final readDomme = { path -> if (!path) return [:]; @@ -96,67 +65,6 @@ return new Object() { Eval.me(s.text)(toy); }); }; - def selectImage = { domme, set, spec -> - def 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) }); - if (matches.isEmpty()) return null; - return matches[getRandom(matches.size())]; - }; - def showImage = { spec -> - def outfit = loadString("toy.owner.outfit"); - def image = selectImage(OWNER, outfit, spec); - if (image) { - setImage("toy/$OWNER/$outfit/${image.image}.jpg"); - return image.tags; - } - else { - setImage(null); - return null; - } - }; - def showLounge = { - setImage("toy/$OWNER/lounge.jpg"); - }; - def selectImageSet = { domme, specs -> - def matches = IMAGEDATA[domme]; - if (!matches) return null; - matches = matches.sets.values().findAll({ s -> specs.every({ spec -> selectImage(domme, s.set, spec)})}); - return matches[getRandom(matches.size())]; - }; - def dress = { specs -> - def outfit = loadString("toy.owner.outfit"); - def outfitTime = loadInteger("toy.owner.outfitTime"); - if (outfitTime > getTime() - 7200) { // Recent, check - def prev = IMAGEDATA[OWNER]; - if (prev) { - prev = prev.sets[outfit]; - if (prev && specs.every({ spec -> selectImage(OWNER, prev.set, spec)})) { - DOMME = loadDomme(OWNER, outfit); - return outfit; - } - } - } - outfit = selectImageSet(OWNER, specs); - if (!outfit) { - showPopup("No outfit for $OWNER : $specs"); - save("toy.owner.outfit", null); - save("toy.owner.outfitTime", null); - DOMME = loadDomme(OWNER, outfit); - return; - } - save("toy.owner.outfit", outfit.set); - save("toy.owner.outfitTime", getTime()); - DOMME = loadDomme(OWNER, outfit.set); - }; // Utils int localTimeOffset() { @@ -1885,6 +1793,7 @@ return new Object() { /* * Resources * scripts/toy.groovy + * scripts/toy/imagery.groovy * scripts/toy/intro.groovy * scripts/toy/sleep.groovy * scripts/toy/social.groovy |