Skip to content

Instantly share code, notes, and snippets.

@chemputer
Last active May 29, 2021 23:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chemputer/d49b7e93451a041f6da47d16894893cb to your computer and use it in GitHub Desktop.
Save chemputer/d49b7e93451a041f6da47d16894893cb to your computer and use it in GitHub Desktop.
World of Warships Pirate Schedule Determine Tiers Script

Instructions

You can download/copy the Google Sheet from here if you want/need all the data. Otherwise, you can just download the PirateSchedule - Tiers.csv and import that, make sure the sheet (not the spreadsheet!) is called Tiers, or else change the name in the code.

Getting the SpreadsheetID

You'll need the spreadsheet ID, which is this part of the url of your Google Sheet. Here's an example from the copy Spreadsheet's URL and the resulting ID: https://docs.google.com/spreadsheets/d/1eaANrFtkPlnY6h9HBsZJwdU6-fGTVlTTNj4ezDhDHm0/edit ID: 1eaANrFtkPlnY6h9HBsZJwdU6-fGTVlTTNj4ezDhDHm0 Pretty simple!

Configuring the script

To add the script, just go to tools -> Script Editor -> Add Google Sheets API as a service, and then paste the code into Code.js, and finally, go to triggers, and set it to update at the frequency desired.

Team Tiers
Alpha VIII, IX, X
Bravo VIII, IX, X
/**
"Simple" Google App Script (basically JS) that updates two cells every minute (or whatever you set it to) to determine the correct tier
according to the schedule for Alpha and Bravo teams.
*/
//enable debugging console output
var debug = false
// function to make life easier
function cmp(date, min, max) {
var d = new Date();
var n = d.getUTCDate();
timezone = "GMT-" + new Date().getTimezoneOffset()/60
var ct = Utilities.formatDate(new Date(), timezone, "HHmm"); // "yyyy-MM-dd'T'HH:mm:ss'Z'"
//var ct = d.toLocaleTimeString()
if (debug == true){
console.log(n)
console.log(ct)
}
if (ct >= min && ct <= max && date == n) {
if(debug == true) {console.log(true)}
return true
}
else {
if(debug == true) {console.log(false)}
return false
}
}
// update the two cells that alpha and bravo tiers are stored in
function updateAB(a,b){
var spreadsheetId = 'redacted'; // redacted - get your own spreadsheetID!
var ss = SpreadsheetApp.openById(spreadsheetId);
var alpha = SpreadsheetApp.getActiveSpreadsheet().getRange("Tiers!B2");
alpha.setValue(a);
console.log("Alpha: " + a)
var bravo = SpreadsheetApp.getActiveSpreadsheet().getRange("Tiers!B3");
bravo.setValue(b);
console.log("Bravo: " + b)
}
function myFunction() {
/**Schedule
Alpha Beta
Day(EDT) Time(EDT) Tiers Day(EDT) Time(EDT) Tiers
28 1400 VIII, IX, X 28 1400 VIII, IX, X
28 1800 VI 28 1800 VIII
28 2200 VIII, IX, X 28 2200 VIII, IX, X
29 100 V 29 100 VII
29 400 VIII, IX, X 29 400 VIII, IX, X
29 1000 VIII 29 1000 VI
29 1400 VIII, IX, X 29 1400 VIII, IX, X
29 1800 VII 29 1800 V
29 2200 VIII, IX, X 29 2200 VIII, IX, X
30 100 VIII 30 100 VI
30 400 VIII, IX, X 30 400 VIII, IX, X
30 1000 VI 30 1000 VIII
30 1400 VIII, IX, X 30 1400 VIII, IX, X
30 1800 ALL TIERS 30 1800 ALL TIERS
30 2200 ALL TIERS 30 2200 ALL TIERS
31 100 ALL TIERS 31 100 ALL TIERS
31 400 STOP 31 400 STOP
*/
//should've used a switch statement, but oh well.
if (cmp(28,1400,1800)){
updateAB("VI", "VII")
}else
if (cmp(28,1800,2200)){
updateAB("VIII, IX, X", "VIII, IX, X")
}else
if (cmp(28,2200,2359) || cmp(29,0,100)){
updateAB("VIII, IX, X", "VIII, IX, X")
}else
if (cmp(29,100,400)){
updateAB("V", "VIII")
}else
if (cmp(29,400,1000)){
updateAB("VIII, IX, X", "VIII, IX, X")
}else
if (cmp(29,1000,1400)){
updateAB("VIII", "VI")
}else
if (cmp(29,1400,1800)){
updateAB("VIII, IX, X", "VIII, IX, X")
}else
if (cmp(29,1800,2200)){
updateAB("VII", "V")
}else
if (cmp(29,2200,2359) || cmp(30,0,100)){
updateAB("VIII, IX, X", "VIII, IX, X")
}else
if (cmp(30,100,400)){
updateAB("VI", "VIII")
}else
if (cmp(30,400,1000)){
updateAB("VIII, IX, X", "VIII, IX, X")
}else
if (cmp(30,1000,1400)){
updateAB("VI", "VIII")
}else
if (cmp(30,1400,1800)){
updateAB("VIII, IX, X", "VIII, IX, X")
}else
if (cmp(30,1800,2200)){
updateAB("ALL TIERS", "ALL TIERS")
}else
if (cmp(30,2200,2359) || cmp(31,0,100)){
updateAB("ALL TIERS", "ALL TIERS")
}else
if (cmp(31,400,1000)){
updateAB("STOP", "STOP")
}else{
updateAB("STOP","STOP")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment