Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special Mayor Command #292

Merged
merged 2 commits into from
Dec 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions src/minecraft/commands/specialMayorCommand.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
const minecraftCommand = require("../../contracts/minecraftCommand.js");


/*
Derpy = 368 mod 24 = 8
Jerry = 376 mod 24 = 16
Scorpius = 384 mod 24 = 0
https://hypixel-skyblock.fandom.com/wiki/Mayor_Election#Special_Candidates_Election_Cycle
*/

const hourMs = 50000;
const dayMs = 24 * hourMs;
const monthLength = 31;
const yearLength = 12;

const monthMs = monthLength * dayMs;
const yearMs = yearLength * monthMs;

const yearZero = 1560275700000;

const currentSkyblockYear = timeToSkyblockYear(Date.now());

var yearsUntilSpecial = 0;
var diffSkyblockYear = currentSkyblockYear;
var specialMayor = "";


function timeToSkyblockYear(time) {
return Math.floor((time - yearZero) / yearMs) + 1;
}

function getSpecialMayor(skyblockYear) {
if (diffSkyblockYear % 24 == 8){
specialMayor = "Derpy";
} else if (diffSkyblockYear % 24 == 16){
specialMayor = "Jerry";
} else if (diffSkyblockYear % 24 == 0){
specialMayor = "Scorpius";
} else {
specialMayor = "Error!";
}
return specialMayor;
}

class SpecialMayorCommand extends minecraftCommand {
constructor(minecraft) {
super(minecraft);

this.name = "specialmayor";
this.aliases = ["specmayor"];
this.description = "How many years until next special mayor, along with speculated special mayor.";
this.options = [];
}

async onCommand() {
try {

if (currentSkyblockYear % 8 == 0){
specialMayor = getSpecialMayor(currentSkyblockYear);
this.send(`/gc Special Mayor this year! It is speculated to be ${specialMayor}.`);
} else {
while (diffSkyblockYear % 8 != 0){
yearsUntilSpecial += 1;
diffSkyblockYear += 1;
specialMayor = getSpecialMayor(diffSkyblockYear);
}
this.send(`/gc Not Special Mayor, ${yearsUntilSpecial} years until the next one! It is speculated to be ${specialMayor}.`);
}

} catch (error) {
console.log(error)
this.send(`/gc [ERROR] ${error}`);
}
}
}

module.exports = SpecialMayorCommand;

Loading