Scripts/phkb_moray_conditions.js |
"use strict";
this.name = "phkb_moray_conditions_script";
this.author = "phkb";
this.copyright = "2021 phkb";
this.license = "CC BY-NC-SA 4.0";
this.allowOfferShip = function(shipKey) {
// only offer certain styles/colours on a regular basis
var keys = {
0: [1,2,3,4,5,6,7,8,9],
1: [10,11,12,13,14,15,16,17,18],
2: [19,20,21,22,23,24,25,26,27]
}
var week = parseInt(clock.daysComponent / 7) % 4; // will be 0-3
var period = parseInt(clock.daysComponent / 30) % 3; // will be 0-2
var keylist = keys[period];
var avail = [];
switch (week) {
case 0:
avail.push(keylist[1]);
avail.push(keylist[2]);
break;
case 1:
avail.push(keylist[3]);
avail.push(keylist[4]);
break;
case 2:
avail.push(keylist[5]);
avail.push(keylist[6]);
avail.push(keylist[7]);
break;
case 3:
avail.push(keylist[8]);
avail.push(keylist[0]);
break;
}
for (var i = 0; i < avail.length; i++) {
if ((shipKey + "E").indexOf("_" + avail[i] + "E") >= 0) return true;
}
return false;
} |
Scripts/phkb_moraymed_conditions.js |
"use strict";
this.name = "phkb_moraymed_conditions_script";
this.author = "phkb";
this.copyright = "2021 phkb";
this.license = "CC BY-NC-SA 4.0";
this.allowOfferShip = function(shipKey) {
// only offer certain styles/colours on a regular basis
var keys = {
0: [1,3,5,7,9,11,13],
1: [2,4,6,8,10,12,14],
}
var week = parseInt(clock.daysComponent / 7) % 4; // will be 0-3
var period = parseInt(clock.daysComponent / 30) % 2; // will be 0-1
var keylist = keys[period];
var avail = [];
switch (week) {
case 0:
avail.push(keylist[2]);
avail.push(keylist[6]);
break;
case 1:
avail.push(keylist[5]);
avail.push(keylist[1]);
break;
case 2:
avail.push(keylist[4]);
avail.push(keylist[0]);
break;
case 3:
avail.push(keylist[3]);
break;
}
for (var i = 0; i < avail.length; i++) {
if ((shipKey + "E").indexOf("_" + avail[i] + "E") >= 0) return true;
}
return false;
} |