Here it is in its entirety:
"use strict";
function main() {
//Schedule Nightly
var scriptProxy = bridge.getScriptServiceProxy();
var scriptName = "tournaments/SeedDailyLeaderboard";
var scriptData = {};
var midnightPSTinUTC = 1759561200000; // Calculate for your target date
scriptProxy.scheduleRunScriptUTC(scriptName, scriptData, midnightPSTinUTC);
//end schedule
const profileIds = [
"b7d353e8-3bef-4e01-9d42-a92e31d076c1",
"4bfd2215-45bb-4ad0-96f9-97fa487926a7",
"841abac7-86a5-4f31-8e33-0da986e42216",
"75d97f20-fd76-46a9-aae1-70398bdc590e",
"655d7882-5bee-44b0-aeb9-3a9cf404858e",
"ef5061f7-2086-465e-bfb2-8df8bdc30b0d",
"817560b6-6a87-454d-aef9-c7c3f7eb7963",
"56570e93-8912-4d24-8289-9046faa6fdb2",
"4180d878-256f-4ea1-a26b-65ff757d962b",
"84d5509c-14c7-4e1f-8fd0-6a3ba432af17",
"2bc2dd6b-3e0f-45d0-bea6-13bfc01bbbc4",
"b6ad5fa9-ccf5-43be-ab6b-b44eeec02d90",
"792712e6-efc0-4310-9f12-7abbcdab1bb1"
];
function generateRandomScore() {
const min = 300;
const max = 1250;
const randomNum = Math.floor(Math.random() * (max - min + 1)) + min;
return randomNum * 100;
}
let results = {
success: [],
errors: []
};
// Process one profile at a time
let currentIndex = 0;
function processNextProfile() {
if (currentIndex >= profileIds.length) {
return results;
}
const profileId = profileIds[currentIndex];
const score = generateRandomScore(); // Generate new score for each profile
try {
const otherSession = bridge.getSessionForProfile(profileId);
//const lbProxy = bridge.getLeaderboardServiceProxy(otherSession);
const tournamentProxy = bridge.getTournamentServiceProxy(otherSession);
var postResult = tournamentProxy.joinTournament("DailyHighScore", "DailyHighScore", score);
// lbProxy.postScoreToLeaderboard(
// "WeeklyHighScore",
// score,
// {}
// );
// Wait for the first operation to complete before starting the next
//bridge.callAPI("Leaderboard", "POST_SCORE", {
// leaderboardId: "WeeklyHighScore",
// score: score,
// data: {}
//});
results.success.push({
profileId: profileId,
score: score
});
} catch (error) {
results.errors.push({
profileId: profileId,
error: error.message || "Unknown error"
});
}
currentIndex++;
return processNextProfile();
}
return processNextProfile();
}
main();