From 4902903b3a23179533e90a26c06e2daa61e66803 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 19 Jun 2019 21:04:34 +0100 Subject: Extract social into a module --- scripts/toy.groovy | 100 ++++++++--------------------------------------------- 1 file changed, 15 insertions(+), 85 deletions(-) (limited to 'scripts/toy.groovy') diff --git a/scripts/toy.groovy b/scripts/toy.groovy index 1dfadca..d7747a7 100644 --- a/scripts/toy.groovy +++ b/scripts/toy.groovy @@ -34,8 +34,6 @@ return new Object() { final RELEASEFROM = "releaseFrom"; final LUNCH = "lunch", SHOPPING = "shopping", PARTY = "party", SLEEPING = "sleeping"; final BEDTIME = "bedtime", WAKEUP = "wakeup", BEDTIMECHECK = "bedtimeCheck"; - final BEGINPLAN = "beginPlan", ENDPLAN = "endPlan"; - final FRIENDS = [ "Tori", "Sophie", "Krystal" ]; // toy.position final KNEELING = "kneeling", ALLFOURS = "allfours", STANDING = "standing"; def OWNER = null; @@ -1792,85 +1790,19 @@ return new Object() { }; // Setup - // Plans - cannot overlap - def setupPlan = { plan, float startmin, float startmax, float endmin, float endmax -> - def timeWindow = { float min, float max -> (int)((min * HOUR) - localTimeOffset() + getRandom((int)((max - min) * HOUR))) }; - final friendName = FRIENDS[getRandom(FRIENDS.size())]; - def day = getDay() + ((getRandom(3) + 1) * DAY); - addEventIfMissing(plan, day + timeWindow(startmin, startmax), BEGINPLAN, - [friendName: friendName, returnTime: day + timeWindow(endmin, endmax)]); - } - def setupPlans = { - save("toy.plan", null); - setupPlan(LUNCH, 11.5, 12.5, 13.0, 14.0) - setupPlan(SHOPPING, 14.5, 15.5, 16.0, 18.0) - setupPlan(PARTY, 19, 20, 22.0, 25.0) - }; def setupEvents = { playSchedule(); sleepSchedule(); - setupPlans(); }; def setDefault = { prop, val -> if (loadString(prop) == null) { save(prop, val); } }; - def leaveNote = { msg, instr -> - save("toy.note", msg); - save("toy.noteInstr", instr); - }; - def readNote = { - leaveNote(null, null); - }; - def plannedCheck = { plan -> - return (getTime() > loadInteger("toy.plan.${plan}.${START}") && getTime() < loadInteger("toy.plan.${plan}.${END}")); - } - def beginPlan = { rt, plan, args -> - addEvent(plan, args.returnTime, ENDPLAN, args.friendName); - dress([[DRESSED,nTEASE], [DRESSED,TEASE]]); - if (rt && sessionSummon([DRESSED,nTEASE])) { - present([DRESSED,nTEASE], [ - [ "I'm going out now, toy.", "$plan time!" ], - [ "Will you be good while I'm gone?", "You will behave as I expect?" ]]); - wait(10); - postChastity(); - def toys = TOYTOYS.findAll { t -> stateIs(t) }; - Collections.shuffle(toys); - toys.each { removeToy(it, [DRESSED,nTEASE]) }; - removeEvent(REDRESS); - set(NAKED, false); - present([DRESSED,TEASE], [ - [ "Back later!", "See you soon, toy" ]]); - wait(5); - } - else if (has(CHASTITY) && !stateIs(CHASTE)) { - leaveNote("I want you in chastity until I return!", CHASTE); - } - DOMME = loadDomme(OWNER); - setAway(plan); - removeEvent(PLAY); - showLounge(); - }; - def endPlan = { rt, plan -> - save("toy.owner.outfitTime", getTime()); - setAway(null); - if (rt && sessionSummon([DRESSED])) { - present([DRESSED], [["Hello, toy!"], ["I'm back home now."]]); - wait(10); - showLounge(); - } - readNote(); - playSchedule(); - setupPlans(); - }; - // Initial - basic checks and defaults def namedEvents = [ bedtime: { name, arg, schedTime, rt -> bedtime(rt, schedTime) }, bedtimeCheck: { name, arg, schedTime, rt -> bedtimeCheck(rt) }, wakeup: { name, arg, schedTime, rt -> wakeup(rt) }, - beginPlan: { name, arg, schedTime, rt -> beginPlan(rt, name, arg) }, - endPlan: { name, arg, schedTime, rt -> endPlan(rt, name) }, play: { name, arg, schedTime, rt -> playEvent(rt, arg) }, releaseFrom: { name, arg, schedTime, rt -> releaseFrom(rt, arg, name) }, redress: { name, arg, schedTime, rt -> redress(rt) }, @@ -1952,18 +1884,19 @@ return new Object() { def showFaq = { useUrl("http://toy.randomdan.homeip.net/"); }; - def setupShowCalendar = { - final events = loadEvents(); - show( - [LUNCH, SHOPPING, PARTY].collect { - final event = events[it]; - if (!event) return ""; - def s = event.time; - def f = event.arg.friendName; - def timeStr = localTimeOf(s).format(soonFormatter); - return "$it with $f on $timeStr.\n".capitalize(); - }.join()); - showButton("OK"); + + final addNamedEvent = { String name, func -> + namedEvents[name] = func; + } + def requestables = [ + faq: [ lbl: "FAQ (webpage)", act: showFaq ], + confess: [ lbl: "Confess", act: confess ], + ]; + final addRequestable = { String name, String label, func -> + requestables[name] = [lbl: label, act: func]; + }; + final removeRequestable = { String name -> + requestables.remove(name); }; String main() @@ -2030,11 +1963,7 @@ return new Object() { final waitTime = Math.min(cycleTime, e.event.time - getTime()); final clickTime = showButton("Please, ${dommeTitle()}?", waitTime); if (clickTime < waitTime) { - def opts = [ - [ lbl: "FAQ (webpage)", act: showFaq ], - [ lbl: "Calendar", act: setupShowCalendar ], - [ lbl: "Confess", act: confess ], - ]; + def opts = requestables.values().toList(); if (stateIs("DEBUG")) { opts.push([ lbl: "Status", act: setupShowState ]); opts.push([ lbl: "Play", act: playEvent, arg: true ]); @@ -2067,6 +1996,7 @@ return new Object() { /* * Resources * scripts/toy.groovy + * scripts/toy/social.groovy * images/toy/ancilla/corset/1.jpg * images/toy/ancilla/corset/10.jpg * images/toy/ancilla/corset/11.jpg -- cgit v1.2.3