summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2019-06-20 19:33:57 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2019-06-20 19:33:57 +0100
commit16c98839c7250d996611f7a233cf034f42386b9d (patch)
tree34db5771d1da7576ab2eed128c607f9b2d7c61fe /scripts
parentExtract sleeping into a module (diff)
downloadtoy-16c98839c7250d996611f7a233cf034f42386b9d.zip
Extract imagery into a module
Diffstat (limited to 'scripts')
-rw-r--r--scripts/toy.groovy93
-rw-r--r--scripts/toy/imagery.groovy99
2 files changed, 100 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
diff --git a/scripts/toy/imagery.groovy b/scripts/toy/imagery.groovy
new file mode 100644
index 0000000..a0f1ddf
--- /dev/null
+++ b/scripts/toy/imagery.groovy
@@ -0,0 +1,99 @@
+{ toy ->
+ final IMAGEDATA = {
+ return new File("${toy.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() }
+ ];
+ }
+ ]
+ ]}
+ ]
+ ]
+ };
+ }();
+
+ 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) });
+ if (matches.isEmpty()) return null;
+ return matches[getRandom(matches.size())];
+ };
+
+ toy.metaClass.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;
+ }
+ };
+
+ toy.metaClass.showLounge {
+ setImage("toy/$OWNER/lounge.jpg");
+ };
+
+ toy.metaClass.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())];
+ };
+
+ toy.metaClass.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);
+ };
+}