diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-07-09 17:32:38 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-07-09 17:32:38 +0100 |
commit | b35e96ba4a02274907d7b60d043aa069b94335b8 (patch) | |
tree | b00b312918ec3f9c95f708a19185be93405bb49d /scripts/toy.groovy | |
parent | Basic trigger point event system (diff) | |
download | toy-b35e96ba4a02274907d7b60d043aa069b94335b8.zip |
Move availability into a module
Diffstat (limited to 'scripts/toy.groovy')
-rw-r--r-- | scripts/toy.groovy | 27 |
1 files changed, 5 insertions, 22 deletions
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> T getProp(String i, java.util.function.Function<String, T> 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 |