From b35e96ba4a02274907d7b60d043aa069b94335b8 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 9 Jul 2019 17:32:38 +0100 Subject: Move availability into a module --- scripts/toy.groovy | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) (limited to 'scripts/toy.groovy') diff --git a/scripts/toy.groovy b/scripts/toy.groovy index 1fb02ae..286ffad 100644 --- a/scripts/toy.groovy +++ b/scripts/toy.groovy @@ -94,6 +94,9 @@ return new Object() { int getDay() { return ((int)(getTime() / DAY) * DAY); } + int getDayNum() { + return Math.floorDiv(getTime() - localTimeOffset() - (4 * (int)HOUR), DAY) + } public T getProp(String i, java.util.function.Function f, T d = null) { final T v = f.apply("toy.$i".toString()); @@ -358,27 +361,8 @@ return new Object() { OWNER = loadString("toy.owner"); loadDomme(OWNER); def moduleSetup = loadModules(this); - def getDayNum = { Math.floorDiv(getTime() - localTimeOffset() - 14400, 86400) }; - def getAvail = { dayNum -> loadInteger("toy.availability.$dayNum") ?: 0 }; - def addAvail = { amount -> - def dayNum = getDayNum(); - save("toy.availability.$dayNum", (int)(getAvail(dayNum) + amount)); - }; - def tidyAvail = { - def p = load("toy.availability"); - if (!p) return; - def p2 = [:]; - final firstDay = getDayNum() - 20; - p.eachWithIndex{ avail, day -> - if (day >= firstDay && avail > 0) { - p2["$day"] = avail; - } - } - save("toy.availability", p2); - }; setDefault("toy.punishment", 0); execEvents(false); - tidyAvail(); moduleSetup.each { p -> p() }; final cycleTime = 60; @@ -428,12 +412,10 @@ return new Object() { else if (stateIs("DEBUG")) return "toy"; } - addAvail(clickTime); executeTrigger("toyLoungeTime", clickTime); } - def eStart = getTime(); + final eStart = getTime(); execEvents(true); - addAvail(getTime() - eStart); executeTrigger("toyEventTime", getTime() - eStart); } } @@ -443,6 +425,7 @@ return new Object() { /* * Resources * scripts/toy.groovy + * scripts/toy/availability.groovy * scripts/toy/bondage.groovy * scripts/toy/cbt.groovy * scripts/toy/chastity.groovy -- cgit v1.2.3