Use chance to determine hat unlocks and add heart to menu title

This commit is contained in:
Idrees Hassan
2026-01-21 23:23:00 -05:00
parent 7b1df9bc4f
commit 5e04727a1b
7 changed files with 144 additions and 36 deletions

30
dist/web/birb.js vendored
View File

@@ -2033,7 +2033,6 @@
// Timing constants (in milliseconds)
const UPDATE_INTERVAL = 1000 / 60; // 60 FPS
const AFK_TIME = isDebug() ? 0 : 1000 * 5;
const PET_BOOST_DURATION = 1000 * 60 * 5;
const PET_MENU_COOLDOWN = 1000;
const URL_CHECK_INTERVAL = 150;
const HOP_DELAY = 500;
@@ -2042,10 +2041,15 @@
const HOP_CHANCE = 1 / (60 * 2.5); // Every 2.5 seconds
const FOCUS_SWITCH_CHANCE = 1 / (60 * 20); // Every 20 seconds
const FEATHER_CHANCE = 1 / (60 * 60 * 60 * 2); // Every 2 hours
const HAT_CHANCE = 1 / 50; // Every 50 webpages
// Feathers
const FEATHER_FALL_SPEED = 1;
// Petting boosts
const PET_BOOST_DURATION = 1000 * 60 * 5; // 5 minutes
const PET_FEATHER_BOOST = 2;
const PET_HAT_BOOST = 1.5;
// Focus element constraints
const MIN_FOCUS_ELEMENT_WIDTH = 100;
@@ -2296,7 +2300,8 @@
// Currently being pet, don't open menu
return;
}
insertMenu(menuItems, `${birdBirb().toLowerCase()}OS`, updateMenuLocation);
insertMenu(menuItems, `${isPetBoostActive() ? "" : ""}${birdBirb().toLowerCase()}OS${isPetBoostActive() ? " ❤" : ""}`, updateMenuLocation);
});
birbElement.addEventListener("mouseover", () => {
@@ -2325,9 +2330,10 @@
setInterval(() => {
const currentPath = getContext().getPath().split("?")[0];
if (currentPath !== lastPath) {
log("Path changed, updating sticky notes: " + currentPath);
log("Path changed from '" + lastPath + "' to '" + currentPath + "'");
lastPath = currentPath;
drawStickyNotes(stickyNotes, save, deleteStickyNote);
determineHatUnlock();
}
}, URL_CHECK_INTERVAL);
@@ -2335,8 +2341,16 @@
focusOnElement(true);
// TODO: This is for testing
insertHat();
determineHatUnlock();
}
function determineHatUnlock() {
if (Math.random() < (HAT_CHANCE * (isPetBoostActive() ? PET_HAT_BOOST : 1))) {
insertHat();
} else if (location.hostname === "127.0.0.1") {
log("Inserting hat for debug purposes");
insertHat();
}
}
function update() {
@@ -2370,7 +2384,7 @@
}
// Double the chance of a feather if recently pet
const petMod = Date.now() - lastPetTimestamp < PET_BOOST_DURATION ? PET_FEATHER_BOOST : 1;
const petMod = isPetBoostActive() ? PET_FEATHER_BOOST : 1;
if (birb.isVisible() && Math.random() < FEATHER_CHANCE * petMod) {
lastPetTimestamp = 0;
activateFeather();
@@ -3033,6 +3047,10 @@
}
}
function isPetBoostActive() {
return Date.now() - lastPetTimestamp < PET_BOOST_DURATION;
}
/**
* @param {number} x
* @param {number} y