mirror of
https://github.com/NohamR/Pocket-Bird.git
synced 2026-05-25 04:07:23 +00:00
Use chance to determine hat unlocks and add heart to menu title
This commit is contained in:
30
dist/userscript/birb.user.js
vendored
30
dist/userscript/birb.user.js
vendored
@@ -2053,7 +2053,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;
|
||||
@@ -2062,10 +2061,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;
|
||||
@@ -2316,7 +2320,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", () => {
|
||||
@@ -2345,9 +2350,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);
|
||||
|
||||
@@ -2355,8 +2361,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() {
|
||||
@@ -2390,7 +2404,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();
|
||||
@@ -3053,6 +3067,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
function isPetBoostActive() {
|
||||
return Date.now() - lastPetTimestamp < PET_BOOST_DURATION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {number} x
|
||||
* @param {number} y
|
||||
|
||||
Reference in New Issue
Block a user