mirror of
https://github.com/AsgardEternal/squad-js-map-vote.git
synced 2025-01-23 18:23:52 -06:00
utcTime option to timezone option
This commit is contained in:
parent
1bcb5e5bdf
commit
66c5245e37
@ -131,7 +131,7 @@ Array of timeframes that allows to override options based on local time. See exa
|
||||
name: "friendly name", // a friendly name visible in the logs
|
||||
start: "12:00", // timeframe start time <hour>:<minutes>
|
||||
end: "18:00", // timeframe end time <hour>:<minutes>
|
||||
utcTime: false, // true: use UTC time; false: use LOCAL time
|
||||
timezone: 0, // Timezone relative to UTC time. 0 for UTC, 2 for CEST (UTC+2), -1 (UTC-1)
|
||||
overrides: { // options to override
|
||||
automaticVoteStart: false,
|
||||
layerLevelBlacklist: [ "Anvil", "Chora" ]
|
||||
@ -162,7 +162,7 @@ Array of timeframes that allows to override options based on local time. See exa
|
||||
"name": "follow layer rotation list",
|
||||
"start": "12:00",
|
||||
"end": "18:00",
|
||||
"utcTime": true,
|
||||
"timezone": +2,
|
||||
"overrides": {
|
||||
"automaticVoteStart": false
|
||||
}
|
||||
@ -170,7 +170,7 @@ Array of timeframes that allows to override options based on local time. See exa
|
||||
{
|
||||
"start": "22:00",
|
||||
"end": "02:00",
|
||||
"utcTime": false,
|
||||
"timezone": -1,
|
||||
"overrides": {
|
||||
"voteBroadcastMessage": "Late night games? Vote your favourite map!"
|
||||
}
|
||||
|
13
mapvote.js
13
mapvote.js
@ -107,6 +107,8 @@ export default class MapVote extends DiscordBasePlugin {
|
||||
constructor(server, options, connectors) {
|
||||
super(server, options, connectors);
|
||||
|
||||
this.options.timeFrames.forEach((e, key, arr) => { arr[ key ].id = key + 1 });
|
||||
|
||||
this.voteRules = {}; //data object holding vote configs
|
||||
this.nominations = []; //layer strings for the current vote choices
|
||||
this.trackedVotes = {}; //player votes, keyed by steam id
|
||||
@ -175,7 +177,9 @@ export default class MapVote extends DiscordBasePlugin {
|
||||
this.updateNextMap();
|
||||
}
|
||||
async timeframeOptionOverrider() {
|
||||
const activeTimeframes = this.or_options.timeFrames.filter(tfFilter);
|
||||
|
||||
const orOpt = { ...this.or_options };
|
||||
const activeTimeframes = orOpt.timeFrames.filter(tfFilter);
|
||||
|
||||
let logTimeframe = "Active Time Frames: ";
|
||||
let activeTfIds = [];
|
||||
@ -190,16 +194,17 @@ export default class MapVote extends DiscordBasePlugin {
|
||||
this.verbose(1, logTimeframe + activeTfIds.join(', '));
|
||||
|
||||
function tfFilter(tf, key, arr) {
|
||||
const timeNow = tf.utcTime ? new Date(0, 0, 0, new Date().getUTCHours(), new Date().getUTCMinutes()) : new Date(0, 0, 0, new Date().getHours(), new Date().getMinutes());
|
||||
const utcDelay = tf.timezone ? parseFloat(tf.timezone) : 0;
|
||||
const timeNow = new Date(0, 0, 0, new Date().getUTCHours() + utcDelay, new Date().getUTCMinutes());
|
||||
this.verbose(1, `Current time (UTC+${utcDelay}) ${timeNow.getHours()}:${timeNow.getMinutes()}`)
|
||||
|
||||
arr[ key ].id = key + 1;
|
||||
const tfStartSplit = [ parseInt(tf.start.split(':')[ 0 ]), parseInt(tf.start.split(':')[ 1 ]) ];
|
||||
const tfEndSplit = [ parseInt(tf.end.split(':')[ 0 ]), parseInt(tf.end.split(':')[ 1 ]) ];
|
||||
|
||||
const tfStart = new Date(0, 0, 0, ...tfStartSplit)
|
||||
const tfStart2 = new Date(0, 0, 0, 0, 0)
|
||||
const tfEnd = new Date(0, 0, 0, ...tfEndSplit)
|
||||
return (tfStart <= timeNow && timeNow < tfEnd) || (tfStart > tfEnd && tfStart2 <= timeNow && timeNow < tfEnd)
|
||||
return (tfStart <= timeNow && timeNow < tfEnd) || (tfStart > tfEnd && ((tfStart <= timeNow || tfStart2 <= timeNow) && timeNow < tfEnd))
|
||||
}
|
||||
}
|
||||
async checkUpdates(callback) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user