From ae2c20f8e8ea87ef45ed5dd2dfff53be248a4032 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 18 Dec 2018 19:49:41 +0000 Subject: Adjust flow to improve test run-ability (again) --- scripts/toy.groovy | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'scripts/toy.groovy') diff --git a/scripts/toy.groovy b/scripts/toy.groovy index a33959c..7b13571 100644 --- a/scripts/toy.groovy +++ b/scripts/toy.groovy @@ -100,8 +100,9 @@ def showLounge = { }; def selectImageSet = { domme, specs -> def matches = IMAGEDATA - .find({ d -> d.domme == domme }) - .sets.findAll({ s -> specs.every({ spec -> selectImage(domme, s.set, spec)})}); + .find({ d -> d.domme == domme }); + if (!matches) return null; + matches = matches.sets.findAll({ s -> specs.every({ spec -> selectImage(domme, s.set, spec)})}); return matches[getRandom(matches.size())]; }; def dress = { specs -> @@ -109,10 +110,12 @@ def dress = { specs -> def outfitTime = loadInteger("toy.owner.outfitTime"); if (outfitTime > getTime() - 7200) { // Recent, check def prev = IMAGEDATA - .find({ d -> d.domme == OWNER }) - .sets.find({ s -> s.set == outfit }); - if (prev && specs.every({ spec -> selectImage(OWNER, prev.set, spec)})) { - return outfit; + .find({ d -> d.domme == OWNER }); + if (prev) { + prev = prev.sets.find({ s -> s.set == outfit }); + if (prev && specs.every({ spec -> selectImage(OWNER, prev.set, spec)})) { + return outfit; + } } } outfit = selectImageSet(OWNER, specs); -- cgit v1.2.3