diff --git a/dist/extension.zip b/dist/extension.zip index ed80af7..81686b7 100644 Binary files a/dist/extension.zip and b/dist/extension.zip differ diff --git a/dist/extension/birb.js b/dist/extension/birb.js index a38d411..43ca98d 100644 --- a/dist/extension/birb.js +++ b/dist/extension/birb.js @@ -618,13 +618,12 @@ "#373737": PALETTE.FEATHER_SPINE, }; - /** - * @type {Record} - */ - const RARITY = { + const RARITY = Object.freeze(/** @type {const} */ ({ FAMILIAR: "familiar", UNCOMMON: "uncommon" - }; + })); + + /** @typedef {typeof RARITY[keyof typeof RARITY]} Rarity */ class BirdType { /** @@ -632,7 +631,7 @@ * @param {string} description * @param {Record} colors * @param {string[]} [tags] - * @param {string} [rarity] + * @param {Rarity} [rarity] */ constructor(name, description, colors, tags = [], rarity = RARITY.FAMILIAR) { this.name = name; @@ -665,6 +664,7 @@ /** @type {Record} */ this.colors = { ...defaultColors, ...colors, [PALETTE.THEME_HIGHLIGHT]: colors[PALETTE.THEME_HIGHLIGHT] ?? colors.hood ?? colors.face }; this.tags = tags; + /** @type {Rarity} */ this.rarity = rarity; } } @@ -2398,6 +2398,7 @@ 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 UNCOMMON_FEATHER_CHANCE = 0.1; // 10% of feathers are uncommon const HAT_CHANCE = 1 / (60 * 60 * 25); // Every 25 minutes // Feathers @@ -2849,7 +2850,8 @@ if (document.querySelector("#" + FEATHER_ID)) { return; } - const speciesToUnlock = Object.keys(SPECIES).filter((species) => !unlockedSpecies.includes(species)); + const rarity = Math.random() < UNCOMMON_FEATHER_CHANCE ? RARITY.UNCOMMON : RARITY.FAMILIAR; + const speciesToUnlock = Object.keys(SPECIES).filter((species) => !unlockedSpecies.includes(species) && SPECIES[species].rarity === rarity); if (speciesToUnlock.length === 0) { // No more species to unlock return; diff --git a/dist/obsidian/main.js b/dist/obsidian/main.js index db1442a..96224ee 100644 --- a/dist/obsidian/main.js +++ b/dist/obsidian/main.js @@ -623,13 +623,12 @@ module.exports = class PocketBird extends Plugin { "#373737": PALETTE.FEATHER_SPINE, }; - /** - * @type {Record} - */ - const RARITY = { + const RARITY = Object.freeze(/** @type {const} */ ({ FAMILIAR: "familiar", UNCOMMON: "uncommon" - }; + })); + + /** @typedef {typeof RARITY[keyof typeof RARITY]} Rarity */ class BirdType { /** @@ -637,7 +636,7 @@ module.exports = class PocketBird extends Plugin { * @param {string} description * @param {Record} colors * @param {string[]} [tags] - * @param {string} [rarity] + * @param {Rarity} [rarity] */ constructor(name, description, colors, tags = [], rarity = RARITY.FAMILIAR) { this.name = name; @@ -670,6 +669,7 @@ module.exports = class PocketBird extends Plugin { /** @type {Record} */ this.colors = { ...defaultColors, ...colors, [PALETTE.THEME_HIGHLIGHT]: colors[PALETTE.THEME_HIGHLIGHT] ?? colors.hood ?? colors.face }; this.tags = tags; + /** @type {Rarity} */ this.rarity = rarity; } } @@ -2431,6 +2431,7 @@ module.exports = class PocketBird extends Plugin { 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 UNCOMMON_FEATHER_CHANCE = 0.1; // 10% of feathers are uncommon const HAT_CHANCE = 1 / (60 * 60 * 25); // Every 25 minutes // Feathers @@ -2882,7 +2883,8 @@ module.exports = class PocketBird extends Plugin { if (document.querySelector("#" + FEATHER_ID)) { return; } - const speciesToUnlock = Object.keys(SPECIES).filter((species) => !unlockedSpecies.includes(species)); + const rarity = Math.random() < UNCOMMON_FEATHER_CHANCE ? RARITY.UNCOMMON : RARITY.FAMILIAR; + const speciesToUnlock = Object.keys(SPECIES).filter((species) => !unlockedSpecies.includes(species) && SPECIES[species].rarity === rarity); if (speciesToUnlock.length === 0) { // No more species to unlock return; diff --git a/dist/userscript/birb.user.js b/dist/userscript/birb.user.js index 561386e..38d3266 100644 --- a/dist/userscript/birb.user.js +++ b/dist/userscript/birb.user.js @@ -632,13 +632,12 @@ "#373737": PALETTE.FEATHER_SPINE, }; - /** - * @type {Record} - */ - const RARITY = { + const RARITY = Object.freeze(/** @type {const} */ ({ FAMILIAR: "familiar", UNCOMMON: "uncommon" - }; + })); + + /** @typedef {typeof RARITY[keyof typeof RARITY]} Rarity */ class BirdType { /** @@ -646,7 +645,7 @@ * @param {string} description * @param {Record} colors * @param {string[]} [tags] - * @param {string} [rarity] + * @param {Rarity} [rarity] */ constructor(name, description, colors, tags = [], rarity = RARITY.FAMILIAR) { this.name = name; @@ -679,6 +678,7 @@ /** @type {Record} */ this.colors = { ...defaultColors, ...colors, [PALETTE.THEME_HIGHLIGHT]: colors[PALETTE.THEME_HIGHLIGHT] ?? colors.hood ?? colors.face }; this.tags = tags; + /** @type {Rarity} */ this.rarity = rarity; } } @@ -2393,6 +2393,7 @@ 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 UNCOMMON_FEATHER_CHANCE = 0.1; // 10% of feathers are uncommon const HAT_CHANCE = 1 / (60 * 60 * 25); // Every 25 minutes // Feathers @@ -2844,7 +2845,8 @@ if (document.querySelector("#" + FEATHER_ID)) { return; } - const speciesToUnlock = Object.keys(SPECIES).filter((species) => !unlockedSpecies.includes(species)); + const rarity = Math.random() < UNCOMMON_FEATHER_CHANCE ? RARITY.UNCOMMON : RARITY.FAMILIAR; + const speciesToUnlock = Object.keys(SPECIES).filter((species) => !unlockedSpecies.includes(species) && SPECIES[species].rarity === rarity); if (speciesToUnlock.length === 0) { // No more species to unlock return; diff --git a/dist/web/birb.embed.js b/dist/web/birb.embed.js index a7e93d5..08358cd 100644 --- a/dist/web/birb.embed.js +++ b/dist/web/birb.embed.js @@ -618,13 +618,12 @@ "#373737": PALETTE.FEATHER_SPINE, }; - /** - * @type {Record} - */ - const RARITY = { + const RARITY = Object.freeze(/** @type {const} */ ({ FAMILIAR: "familiar", UNCOMMON: "uncommon" - }; + })); + + /** @typedef {typeof RARITY[keyof typeof RARITY]} Rarity */ class BirdType { /** @@ -632,7 +631,7 @@ * @param {string} description * @param {Record} colors * @param {string[]} [tags] - * @param {string} [rarity] + * @param {Rarity} [rarity] */ constructor(name, description, colors, tags = [], rarity = RARITY.FAMILIAR) { this.name = name; @@ -665,6 +664,7 @@ /** @type {Record} */ this.colors = { ...defaultColors, ...colors, [PALETTE.THEME_HIGHLIGHT]: colors[PALETTE.THEME_HIGHLIGHT] ?? colors.hood ?? colors.face }; this.tags = tags; + /** @type {Rarity} */ this.rarity = rarity; } } @@ -2373,6 +2373,7 @@ 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 UNCOMMON_FEATHER_CHANCE = 0.1; // 10% of feathers are uncommon const HAT_CHANCE = 1 / (60 * 60 * 25); // Every 25 minutes // Feathers @@ -2824,7 +2825,8 @@ if (document.querySelector("#" + FEATHER_ID)) { return; } - const speciesToUnlock = Object.keys(SPECIES).filter((species) => !unlockedSpecies.includes(species)); + const rarity = Math.random() < UNCOMMON_FEATHER_CHANCE ? RARITY.UNCOMMON : RARITY.FAMILIAR; + const speciesToUnlock = Object.keys(SPECIES).filter((species) => !unlockedSpecies.includes(species) && SPECIES[species].rarity === rarity); if (speciesToUnlock.length === 0) { // No more species to unlock return; diff --git a/dist/web/birb.js b/dist/web/birb.js index a7e93d5..08358cd 100644 --- a/dist/web/birb.js +++ b/dist/web/birb.js @@ -618,13 +618,12 @@ "#373737": PALETTE.FEATHER_SPINE, }; - /** - * @type {Record} - */ - const RARITY = { + const RARITY = Object.freeze(/** @type {const} */ ({ FAMILIAR: "familiar", UNCOMMON: "uncommon" - }; + })); + + /** @typedef {typeof RARITY[keyof typeof RARITY]} Rarity */ class BirdType { /** @@ -632,7 +631,7 @@ * @param {string} description * @param {Record} colors * @param {string[]} [tags] - * @param {string} [rarity] + * @param {Rarity} [rarity] */ constructor(name, description, colors, tags = [], rarity = RARITY.FAMILIAR) { this.name = name; @@ -665,6 +664,7 @@ /** @type {Record} */ this.colors = { ...defaultColors, ...colors, [PALETTE.THEME_HIGHLIGHT]: colors[PALETTE.THEME_HIGHLIGHT] ?? colors.hood ?? colors.face }; this.tags = tags; + /** @type {Rarity} */ this.rarity = rarity; } } @@ -2373,6 +2373,7 @@ 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 UNCOMMON_FEATHER_CHANCE = 0.1; // 10% of feathers are uncommon const HAT_CHANCE = 1 / (60 * 60 * 25); // Every 25 minutes // Feathers @@ -2824,7 +2825,8 @@ if (document.querySelector("#" + FEATHER_ID)) { return; } - const speciesToUnlock = Object.keys(SPECIES).filter((species) => !unlockedSpecies.includes(species)); + const rarity = Math.random() < UNCOMMON_FEATHER_CHANCE ? RARITY.UNCOMMON : RARITY.FAMILIAR; + const speciesToUnlock = Object.keys(SPECIES).filter((species) => !unlockedSpecies.includes(species) && SPECIES[species].rarity === rarity); if (speciesToUnlock.length === 0) { // No more species to unlock return; diff --git a/src/animation/sprites.js b/src/animation/sprites.js index 72e7774..2e03648 100644 --- a/src/animation/sprites.js +++ b/src/animation/sprites.js @@ -98,13 +98,12 @@ export const DEFAULT_COLOR_OVERRIDES = { [PALETTE.WING_SPOTS]: PALETTE.WING, }; -/** - * @type {Record} - */ -export const RARITY = { +export const RARITY = Object.freeze(/** @type {const} */ ({ FAMILIAR: "familiar", UNCOMMON: "uncommon" -} +})); + +/** @typedef {typeof RARITY[keyof typeof RARITY]} Rarity */ export class BirdType { /** @@ -112,7 +111,7 @@ export class BirdType { * @param {string} description * @param {Record} colors * @param {string[]} [tags] - * @param {string} [rarity] + * @param {Rarity} [rarity] */ constructor(name, description, colors, tags = [], rarity = RARITY.FAMILIAR) { this.name = name; @@ -145,6 +144,7 @@ export class BirdType { /** @type {Record} */ this.colors = { ...defaultColors, ...colors, [PALETTE.THEME_HIGHLIGHT]: colors[PALETTE.THEME_HIGHLIGHT] ?? colors.hood ?? colors.face }; this.tags = tags; + /** @type {Rarity} */ this.rarity = rarity; } } diff --git a/src/application.js b/src/application.js index 4c8736a..46755ed 100644 --- a/src/application.js +++ b/src/application.js @@ -110,6 +110,7 @@ const HOP_DELAY = 500; 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 UNCOMMON_FEATHER_CHANCE = 0.1; // 10% of feathers are uncommon const HAT_CHANCE = 1 / (60 * 60 * 25); // Every 25 minutes // Feathers @@ -564,7 +565,8 @@ function startApplication(birbPixels, featherPixels, hatsPixels) { if (document.querySelector("#" + FEATHER_ID)) { return; } - const speciesToUnlock = Object.keys(SPECIES).filter((species) => !unlockedSpecies.includes(species)); + const rarity = Math.random() < UNCOMMON_FEATHER_CHANCE ? RARITY.UNCOMMON : RARITY.FAMILIAR; + const speciesToUnlock = Object.keys(SPECIES).filter((species) => !unlockedSpecies.includes(species) && SPECIES[species].rarity === rarity); if (speciesToUnlock.length === 0) { // No more species to unlock return;