From 1fa60618a0731c987107636721e6c9dea6ae12e0 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 30 Jun 2019 12:09:21 +0100 Subject: Refactor basically everything about toys --- scripts/toy.groovy | 3 +- scripts/toy/bondage.groovy | 6 +- scripts/toy/humiliation.groovy | 33 +++++++++++ scripts/toy/pain.groovy | 4 +- scripts/toy/play.groovy | 124 ++--------------------------------------- scripts/toy/sleep.groovy | 10 +--- scripts/toy/social.groovy | 5 +- scripts/toy/toys.groovy | 98 ++++++++++++++++++++++++++++++++ 8 files changed, 151 insertions(+), 132 deletions(-) create mode 100644 scripts/toy/toys.groovy diff --git a/scripts/toy.groovy b/scripts/toy.groovy index 999264d..085ec90 100644 --- a/scripts/toy.groovy +++ b/scripts/toy.groovy @@ -64,7 +64,7 @@ return new Object() { .listFiles() .collect { s -> Eval.me(s.text)(toy); - } + } .findAll { p -> p }; }; @@ -424,6 +424,7 @@ return new Object() { * scripts/toy/sleep.groovy * scripts/toy/social.groovy * scripts/toy/tease.groovy + * scripts/toy/toys.groovy * images/toy/ancilla/corset/1.jpg * images/toy/ancilla/corset/10.jpg * images/toy/ancilla/corset/11.jpg diff --git a/scripts/toy/bondage.groovy b/scripts/toy/bondage.groovy index ad4678c..df3b5ae 100644 --- a/scripts/toy/bondage.groovy +++ b/scripts/toy/bondage.groovy @@ -95,5 +95,9 @@ toy.addActivity("preGag", { toy.preGag() }); toy.addActivity("preCollar", { toy.preCollar() }); toy.addActivity("playBondage", { toy.playBondage() }); - return null; + return { + toy.addToy(toy.COLLAR, toy.COLLARED, "collar", "May I remove my collar?"); + toy.addToy(toy.HANDCUFFS, toy.CUFFED, "handcuffs", "May I be uncuffed?"); + toy.addToy(toy.BALLGAG, toy.GAGGED, "gag", "May I be ungagged?"); + } } diff --git a/scripts/toy/humiliation.groovy b/scripts/toy/humiliation.groovy index a039cdb..af01315 100644 --- a/scripts/toy/humiliation.groovy +++ b/scripts/toy/humiliation.groovy @@ -162,6 +162,39 @@ pause(10); }; + toy.metaClass.redress { rt -> + if (!rt || !sessionSummon([DRESSED])) { + addEvent(REDRESS, getTime() + 300, "redress"); + return; + } + present([DRESSED], [ + ["OK, toy,"], + ["you can put some clothes back on now.", "get yourself covered up."]]); + pause(getRandom(10) + 15); + showButtonG("Thank you, ${dommeTitle()}", "ok"); + set(NAKED, false); + showLounge(); + }; + + toy.metaClass.requestClothes { + adjustPunish(5); + present([DRESSED], [ + ["Really?", "Disappointing."], + ["You want to clothes back on?", "You wish to cover up?"]]); + if (getBoolean(null)) { + present([DRESSED], [["Hmm, very well.", "If you must."]]); + adjustPunish(50); + set(NAKED, false); + removeEvent(REDRESS); + } + else { + present([DRESSED], [["Good boy."]]); + } + showButtonG("Thank you, ${dommeTitle()}", "ok"); + showLounge(); + }; + + toy.addNamedEvent(toy.REDRESS, { name, arg, schedTime, rt -> toy.redress(rt) }); toy.addActivity("preStrip", { toy.preStrip() }); toy.addActivity("playKneel", { toy.playKneel() }); toy.addActivity("playSuck", { toy.playSuck() }); diff --git a/scripts/toy/pain.groovy b/scripts/toy/pain.groovy index bc58ab5..1e4b81c 100644 --- a/scripts/toy/pain.groovy +++ b/scripts/toy/pain.groovy @@ -133,5 +133,7 @@ toy.addActivity('playClamps', { toy.playClamps() }); toy.addActivity('intSqueeze', { toy.intSqueeze() }); toy.addActivity('intClamps', { toy.intClamps() }); - return null; + return { + toy.addToy(toy.CLAMPS, toy.CLAMPED, "nipple clamps", "May I remove the nipple clamps?"); + } } diff --git a/scripts/toy/play.groovy b/scripts/toy/play.groovy index b892a04..53bf0f8 100644 --- a/scripts/toy/play.groovy +++ b/scripts/toy/play.groovy @@ -1,31 +1,4 @@ { toy -> - toy.metaClass.stateToyName { state -> - switch (state) { - case CUFFED: - return "cuffs"; - case COLLARED: - return "collar"; - case CLAMPED: - return "nipple clamps"; - case GAGGED: - return "gag"; - } - return null; - }; - - toy.metaClass.removeToy { state, imageSpec -> - if (!stateIs(state)) return; - def toyName = stateToyName(state); - present(imageSpec, [ - ["OK,"], - ["you may remove your $toyName.", "the $toyName can come off.", "take the $toyName off."]]); - showButtonG("Thank you, ${dommeTitle()}", "ok"); - pause(5); - set(state, false); - removeEvent("$RELEASEFROM-$state"); - showButtonGT("Removed, ${dommeTitle()}", "removed", 20, 1); - }; - toy.metaClass.sessionPlay { if (stateIs(CHASTE)) sessionToys[CHASTITY] = getTime(); def playScope = [ @@ -143,26 +116,13 @@ postChastity(); } pause(getRandom(10) + 5); - def toys = TOYTOYS.findAll { t -> stateIs(t) }; - Collections.shuffle(toys); - if (toys) { - if (!goodToy) { - present([DRESSED], [ - ["I should leave you like that.", "I suppose you still want letting free?"], - ["Maybe.", "Let me ponder on it."]]); - pause(getRandom(20) + 20); - } - toys.each { toyState -> - if (getRandom(100) > ((goodToy && (getPunish() < 100)) ? 10 : 80)) { - removeToy(toyState, [DRESSED]); - } - else { - addEvent("$RELEASEFROM-$toyState", getTime() + 100 + getRandom(10 * (getPunish() + 1)), - RELEASEFROM, toyState); - adjustPunish(-5); - } - }; + if (!goodToy && anyToys()) { + present([DRESSED], [ + ["I should leave you like that.", "I suppose you still want letting free?"], + ["Maybe.", "Let me ponder on it."]]); + pause(getRandom(20) + 20); } + removeAllToys([DRESSED], getPunish()); if (stateIs(NAKED)) { if (goodToy && getRandom(1)) { present([DRESSED], [ @@ -246,79 +206,7 @@ showLounge(); } - toy.metaClass.redress { rt -> - if (!rt || !sessionSummon([DRESSED])) { - addEvent(REDRESS, getTime() + 300, "redress"); - return; - } - present([DRESSED], [ - ["OK, toy,"], - ["you can put some clothes back on now.", "get yourself covered up."]]); - pause(getRandom(10) + 15); - showButtonG("Thank you, ${dommeTitle()}", "ok"); - set(NAKED, false); - showLounge(); - }; - - toy.metaClass.releaseFrom { rt, arg, name -> - if (!rt || !sessionSummon([DRESSED])) { - addEvent(name, getTime() + 300, RELEASEFROM, arg); - return; - } - removeToy(arg, [DRESSED]); - showLounge(); - }; - - toy.metaClass.requestClothes { - adjustPunish(5); - present([DRESSED], [ - ["Really?", "Disappointing."], - ["You want to clothes back on?", "You wish to cover up?"]]); - if (getBoolean(null)) { - present([DRESSED], [["Hmm, very well.", "If you must."]]); - adjustPunish(50); - set(NAKED, false); - removeEvent(REDRESS); - } - else { - present([DRESSED], [["Good boy."]]); - } - showButtonG("Thank you, ${dommeTitle()}", "ok"); - showLounge(); - }; - - toy.metaClass.requestRelease { toyState -> - adjustPunish(5); - present([DRESSED], [ - ["Really?", "Disappointing."], - ["You wish to be un-$toyState?"]]); - if (getBoolean(null)) { - adjustPunish(10); - if (getRandom(100) > getPunish()) { - present([DRESSED], [["No.", "You may not."], - ["Not yet.", "Not until later."]]); - } - else { - present([DRESSED], [["Hmm, very well.", "If you must."]]); - set(toyState, false); - removeEvent("$RELEASEFROM-$toyState"); - } - } - else { - present([DRESSED], [["Good boy."]]); - } - showButtonG("Thank you, ${dommeTitle()}", "ok"); - showLounge(); - }; - toy.addNamedEvent(toy.PLAY, { name, arg, schedTime, rt -> toy.playEvent(rt, arg) }); - toy.addNamedEvent(toy.RELEASEFROM, { name, arg, schedTime, rt -> toy.releaseFrom(rt, arg, name) }); - toy.addNamedEvent(toy.REDRESS, { name, arg, schedTime, rt -> toy.redress(rt) }); - toy.TOYTOYS.each { toyState -> - toy.addRequestable("un$toyState".toString(), "May I be un-$toyState".toString(), - { toy.requestRelease(toyState) }, - { toy.stateIs(toyState) }) - }; toy.playSchedule(); return null; } diff --git a/scripts/toy/sleep.groovy b/scripts/toy/sleep.groovy index 3d9b531..da17157 100644 --- a/scripts/toy/sleep.groovy +++ b/scripts/toy/sleep.groovy @@ -11,9 +11,7 @@ dress([[LINGERIE,nTITS]]); if (rt && sessionSummon([LINGERIE,nTITS])) { preStrip([LINGERIE,nTITS]); - def toys = TOYTOYS.findAll { t -> stateIs(t) }; - Collections.shuffle(toys); - toys.each { removeToy(it, [LINGERIE,nTITS]) }; + removeAllToys([LINGERIE,nTITS]); present([LINGERIE,nTITS], [ ["Very good, toy.", "OK."], ["Bedtime for you!", "Off to bed with you!", "Bed! Now!"]]); @@ -24,11 +22,7 @@ // Assume toy will return dressed tomorrow removeEvent(REDRESS); set(NAKED, false); - // Assume toy will release himself - TOYTOYS.findAll { t -> stateIs(t) }.each { - removeEvent("$RELEASEFROM-$it"); - set(it, false); - }; + backgroundRemoveAllToys(); setAway(SLEEPING); def t = schedTime + (6 * (int)HOUR) + getRandom(2 * (int)HOUR); addEvent(SLEEPING, t, WAKEUP); diff --git a/scripts/toy/social.groovy b/scripts/toy/social.groovy index 9844940..384b0a2 100644 --- a/scripts/toy/social.groovy +++ b/scripts/toy/social.groovy @@ -36,9 +36,7 @@ [ "Will you be good while I'm gone?", "You will behave as I expect?" ]]); pause(10); postChastity(); - def toys = TOYTOYS.findAll { t -> stateIs(t) }; - Collections.shuffle(toys); - toys.each { removeToy(it, [DRESSED,nTEASE]) }; + removeAllToys([DRESSED,nTEASE]); removeEvent(REDRESS); set(NAKED, false); present([DRESSED,TEASE], [ @@ -48,6 +46,7 @@ else if (has(CHASTITY) && !stateIs(CHASTE)) { leaveNote("I want you in chastity until I return!", CHASTE); } + backgroundRemoveAllToys(); loadDomme(OWNER); setAway(plan); removeEvent(PLAY); diff --git a/scripts/toy/toys.groovy b/scripts/toy/toys.groovy new file mode 100644 index 0000000..034c7fc --- /dev/null +++ b/scripts/toy/toys.groovy @@ -0,0 +1,98 @@ +{ toy -> + final toys = [:]; + + toy.metaClass.addToy { String ssName, String toyState, String name, String removeReq, removeReqFunc = null, removeFunc = null, tags = [] -> + if (!has(ssName)) { + return; + } + toys[toyState] = [ + name: name, + remFunc: removeFunc + ]; + toy.addRequestable("un$toyState".toString(), removeReq, + removeReqFunc ?: { toy.requestRelease(stateName) }, + { toy.stateIs(toyState) }) + }; + + toy.metaClass.removeToy { state, imageSpec -> + if (!stateIs(state)) return; + final customRem = toys[state].remFunc; + if (customRem) { + customRem(imageSpec); + } + else { + final toyName = toys[state].name; + present(imageSpec, [ + ["OK,"], + ["you may remove your $toyName.", "the $toyName can come off.", "take the $toyName off."]]); + showButtonG("Thank you, ${dommeTitle()}", "ok"); + pause(5); + showButtonGT("Removed, ${dommeTitle()}", "removed", 20, 1); + } + set(state, false); + removeEvent("$RELEASEFROM-$state"); + }; + + toy.metaClass.releaseFrom { rt, arg, name -> + if (!rt || !sessionSummon([DRESSED])) { + addEvent(name, getTime() + 300, RELEASEFROM, arg); + return; + } + removeToy(arg, [DRESSED]); + showLounge(); + }; + + toy.metaClass.requestRelease { toyState -> + adjustPunish(5); + present([DRESSED], [ + ["Really?", "Disappointing."], + ["You wish to be un-$toyState?"]]); + if (getBoolean(null)) { + adjustPunish(10); + if (getRandom(100) > getPunish()) { + present([DRESSED], [["No.", "You may not."], + ["Not yet.", "Not until later."]]); + } + else { + present([DRESSED], [["Hmm, very well.", "If you must."]]); + set(toyState, false); + removeEvent("$RELEASEFROM-$toyState"); + } + } + else { + present([DRESSED], [["Good boy."]]); + } + showButtonG("Thank you, ${dommeTitle()}", "ok"); + showLounge(); + }; + + toy.metaClass.anyToys { + return toys.any { s, t -> stateIs(s) }; + } + + toy.metaClass.backgroundRemoveAllToys { + // Assume toy will release himself + toys.findAll { s, t -> stateIs(s) }.each { + removeEvent("$RELEASEFROM-$it"); + set(it, false); + }; + } + + toy.metaClass.removeAllToys { imageSpec, probKeep = 0 -> + def toRemove = toys.keySet().findAll { s -> stateIs(s) }.toList(); + Collections.shuffle(toRemove); + toRemove.each { toyState -> + if (getRandom(100) >= probKeep) { + removeToy(toyState, [DRESSED]); + } + else { + addEvent("$RELEASEFROM-$toyState", getTime() + 100 + getRandom(10 * (getPunish() + 1)), + RELEASEFROM, toyState); + adjustPunish(-5); + } + } + } + + toy.addNamedEvent(toy.RELEASEFROM, { name, arg, schedTime, rt -> toy.releaseFrom(rt, arg, name) }); + return null; +} -- cgit v1.2.3