67 lines
2.6 KiB
TypeScript
67 lines
2.6 KiB
TypeScript
// Metro module 11596 (f11597).
|
|
import _slicedToArray from "../../../../_bundle/_slicedToArray";
|
|
import { useState, useMemo } from "react";
|
|
import GuildStore from "../../../../stores/GuildStore";
|
|
import GuildPowerupsStore from "../GuildPowerupsStore";
|
|
import { GUILD_POWERUP_TIER_3_OVERRIDDEN_SKUS } from "../constants/GuildPowerupsConstants";
|
|
import { GuildFeatures } from "../../../../Constants";
|
|
import { GUILD_POWERUP_LEVEL_1_SKU_ID, GUILD_POWERUP_LEVEL_2_SKU_ID, GUILD_POWERUP_LEVEL_3_SKU_ID, GUILD_POWERUP_TAG_SKU_ID, GUILD_POWERUP_ROLE_COLOR_SKU_ID, GUILD_TAGS_BADGE_PACK_FLEX_POWERUP_SKU_ID, GUILD_TAGS_BADGE_PACK_PETS_POWERUP_SKU_ID } from "../../../../_bundle/Module4080";
|
|
import { useStateFromStores } from "../../../../_bundle/Module589";
|
|
import useGuildPowerupsBoostCount from "./useGuildPowerupsBoostCount";
|
|
let c7912_9 = [{
|
|
skuId: GUILD_POWERUP_LEVEL_1_SKU_ID,
|
|
threshold: 1
|
|
}, {
|
|
skuId: GUILD_POWERUP_LEVEL_2_SKU_ID,
|
|
threshold: 2
|
|
}, {
|
|
skuId: GUILD_POWERUP_LEVEL_3_SKU_ID,
|
|
threshold: 2
|
|
}, {
|
|
skuId: GUILD_POWERUP_TAG_SKU_ID,
|
|
threshold: 1
|
|
}, {
|
|
skuId: GUILD_POWERUP_ROLE_COLOR_SKU_ID,
|
|
threshold: 1
|
|
}, {
|
|
skuId: GUILD_TAGS_BADGE_PACK_FLEX_POWERUP_SKU_ID,
|
|
threshold: 1
|
|
}, {
|
|
skuId: GUILD_TAGS_BADGE_PACK_PETS_POWERUP_SKU_ID,
|
|
threshold: 1
|
|
}];
|
|
export default function useBoostToUnlockFeaturedPowerup(a0) {
|
|
let available, stateFromStores2, state;
|
|
const stateFromStores = useStateFromStores([GuildPowerupsStore], () => GuildPowerupsStore.getStateForGuild(a0));
|
|
available = useGuildPowerupsBoostCount(a0).available;
|
|
stateFromStores2 = useStateFromStores([GuildStore], () => {
|
|
const guild = GuildStore.getGuild(a0);
|
|
return (guild == null ? void 0 : guild.features.has(GuildFeatures.PREMIUM_TIER_3_OVERRIDE)) === true;
|
|
});
|
|
state = _slicedToArray(useState(() => Math.random()), 1)[0];
|
|
return useMemo(() => {
|
|
if (stateFromStores != null) {
|
|
const { allPowerups, unlockedPowerups } = stateFromStores;
|
|
const r29 = [];
|
|
for (const item of c7912_9) {
|
|
const { skuId, threshold } = item;
|
|
const r36 = allPowerups[skuId];
|
|
if (r36 != null) {
|
|
if (stateFromStores2 && GUILD_POWERUP_TIER_3_OVERRIDDEN_SKUS.has(skuId)) {
|
|
continue;
|
|
}
|
|
if (unlockedPowerups[skuId] == null && r36.dependencies.every((dependency) => unlockedPowerups[dependency] != null)) {
|
|
const r52 = r36.cost - available;
|
|
if (r52 > 0 && r52 <= threshold) {
|
|
r29.push(r36);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (r29.length > 0) {
|
|
return r29[Math.floor(state * r29.length)];
|
|
}
|
|
}
|
|
}, [stateFromStores, available, stateFromStores2, state]);
|
|
};
|