decord/source/modules/premium/powerups/GuildPowerupsStore.tsx

331 lines
9.9 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 4265
// Function ID: 4266
2026-07-29 08:29:29 +00:00
// Name: calculateAppliedBoosts
2026-08-24 06:08:38 +00:00
// Dependencies: [32, 1910, 4266, 676, 589, 709, 2]
2026-07-20 16:05:17 +00:00
2026-08-24 06:08:38 +00:00
// Module 4265 (calculateAppliedBoosts)
import initializeDefault from "initialize" /* 589 */;
import dispatcherDefault from "dispatcher" /* 709 */;
import closure_0 from "_slicedToArray" /* 32 */;
import closure_1 from "createGuildRecordFromRust" /* 1910 */;
import BoostedGuildTiers from "BoostedGuildTiers" /* 4266 */;
import ME from "ME" /* 676 */;
2026-07-23 10:11:24 +00:00
2026-07-20 16:05:17 +00:00
function calculateAppliedBoosts(guildId) {
2026-07-23 10:11:24 +00:00
guild = guild.getGuild(guildId);
2026-07-20 16:05:17 +00:00
let hasItem;
2026-07-29 08:29:29 +00:00
if (guild != null) {
2026-07-20 16:05:17 +00:00
const features = guild.features;
hasItem = features.has(obj.PREMIUM_TIER_3_OVERRIDE);
}
let num = 0;
if (true !== hasItem) {
let premiumTier;
2026-07-29 08:29:29 +00:00
if (guild != null) {
2026-07-20 16:05:17 +00:00
premiumTier = guild.premiumTier;
}
2026-07-29 08:29:29 +00:00
if (premiumTier == null) {
2026-07-20 16:05:17 +00:00
premiumTier = constants.NONE;
}
2026-07-29 08:29:29 +00:00
num = closure_4[premiumTier];
const tmp5 = closure_4;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let sum = num;
const entries = Object.entries(closure_3);
while (tmp10 !== undefined) {
let tmp12 = callback;
let tmp13 = callback(tmp11, 2);
[tmp14, tmp15] = tmp13;
let hasItem1 = tmp4;
if (tmp4) {
let tmp17 = set;
let tmp18 = tmp14;
hasItem1 = set.has(tmp14);
}
if (!hasItem1) {
let hasItem2;
if (guild != null) {
let premiumFeatures = guild.premiumFeatures;
if (premiumFeatures != null) {
let features2 = premiumFeatures.features;
let tmp20 = tmp14;
2026-07-20 16:05:17 +00:00
hasItem2 = features2.includes(tmp14);
}
2026-07-29 08:29:29 +00:00
}
if (hasItem2) {
let tmp21 = tmp15;
let isEnabled = tmp15.isEnabled;
let num2;
if (isEnabled != null) {
num2 = isEnabled(guildId);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (num2 == null) {
num2 = 1;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
hasItem2 = num2;
}
if (hasItem2) {
let tmp22 = tmp15;
let tmp23 = null == tmp15.includedInLevel;
if (!tmp23) {
let tmp24 = tmp15;
tmp23 = guild.premiumTier < tmp15.includedInLevel;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
hasItem2 = tmp23;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (hasItem2) {
let tmp25 = sum;
let tmp26 = tmp15;
sum = sum + tmp15.boostPrice;
}
}
continue;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return sum;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
({ GUILD_POWERUP_TIER_3_OVERRIDDEN_PURCHASABLE_FEATURES: obj1, PURCHASABLE_PREMIUM_FEATURES_BOOST_INFO: c3 } = BoostedGuildTiers);
({ AppliedGuildBoostsRequiredForBoostedGuildTier: c4, BoostedGuildTiers: c5, GuildFeatures: closure_6 } = ME);
let closure_7 = {};
2026-08-24 06:08:38 +00:00
const PersistedStore = initializeDefault.PersistedStore;
2026-07-29 08:29:29 +00:00
class GuildPowerupsStore extends PersistedStore {
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const prototype = GuildPowerupsStore.prototype;
prototype["initialize"] = function initialize(arg0) {
2026-08-24 06:08:38 +00:00
this.waitFor(closure_1);
2026-07-29 08:29:29 +00:00
if (null != arg0) {
2026-08-24 06:08:38 +00:00
closure_7 = arg0;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
};
prototype["getState"] = function getState() {
return closure_7;
};
prototype["getStateForGuild"] = function getStateForGuild(arg0) {
let tmp;
if (null != arg0) {
tmp = dependencyMap[arg0];
}
return tmp;
};
prototype["shouldFetchCatalogForGuild"] = function shouldFetchCatalogForGuild(arg0) {
let catalogFetchCooldown;
if (dependencyMap[arg0] != null) {
catalogFetchCooldown = tmp.catalogFetchCooldown;
}
let tmp3 = null == catalogFetchCooldown;
if (!tmp3) {
const _Date = Date;
const sum = catalogFetchCooldown + 86400000;
tmp3 = sum < Date.now();
}
return tmp3;
};
prototype["shouldFetchPowerupsForGuild"] = function shouldFetchPowerupsForGuild(guildId) {
let prop;
if (dependencyMap[guildId] != null) {
prop = tmp.unlockedPowerupsFetchCooldown;
}
let tmp3 = null == prop;
if (!tmp3) {
const _Date = Date;
const sum = prop + 3600000;
tmp3 = sum < Date.now();
}
return tmp3;
};
prototype["hasFetchedPowerupCatalog"] = function hasFetchedPowerupCatalog(arg0) {
let tmp = null != arg0;
if (tmp) {
let prop;
if (dependencyMap[arg0] != null) {
prop = tmp3.hasFetchedPowerupCatalog;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp = true === prop;
}
return tmp;
};
prototype["hasFetchedUnlockedPowerups"] = function hasFetchedUnlockedPowerups(arg0) {
let tmp = null != arg0;
if (tmp) {
let prop;
if (dependencyMap[arg0] != null) {
prop = tmp3.hasFetchedUnlockedPowerups;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp = true === prop;
}
return tmp;
};
GuildPowerupsStore.displayName = "GuildPowerupsStore";
GuildPowerupsStore.persistKey = "GuildPowerupsStore";
2026-07-23 10:11:24 +00:00
let items = [
2026-07-20 16:05:17 +00:00
(arg0) => {
let fromEntriesResult = arg0;
if (null != arg0) {
const _Object = Object;
const _Object2 = Object;
const entries = Object.entries(arg0);
const found = entries.filter((arg0) => {
[, tmp] = arg0;
2026-08-04 21:03:28 +00:00
return null != tmp && typeof tmp === "object";
2026-07-20 16:05:17 +00:00
});
fromEntriesResult = Object.fromEntries(found.map((arg0) => {
[tmp, tmp2] = arg0;
const items = [tmp, ];
const obj = {};
const merged = Object.assign(tmp2);
let allPowerups = tmp2.allPowerups;
2026-07-29 08:29:29 +00:00
if (allPowerups == null) {
2026-07-20 16:05:17 +00:00
allPowerups = {};
}
2026-07-29 08:29:29 +00:00
obj.allPowerups = allPowerups;
2026-07-20 16:05:17 +00:00
let powerupCatalog = tmp2.powerupCatalog;
2026-07-29 08:29:29 +00:00
if (powerupCatalog == null) {
2026-07-20 16:05:17 +00:00
powerupCatalog = {};
}
2026-07-29 08:29:29 +00:00
obj.powerupCatalog = powerupCatalog;
2026-07-20 16:05:17 +00:00
let unlockedPowerups = tmp2.unlockedPowerups;
2026-07-29 08:29:29 +00:00
if (unlockedPowerups == null) {
2026-07-20 16:05:17 +00:00
unlockedPowerups = {};
}
2026-07-29 08:29:29 +00:00
obj.unlockedPowerups = unlockedPowerups;
2026-07-20 16:05:17 +00:00
items[1] = obj;
return items;
}));
}
return fromEntriesResult;
}
];
2026-07-29 08:29:29 +00:00
GuildPowerupsStore.migrations = items;
2026-08-24 06:08:38 +00:00
const guildPowerupsStore = new GuildPowerupsStore(dispatcherDefault, {
2026-07-20 16:05:17 +00:00
LOGOUT: function handleReset() {
2026-08-24 06:08:38 +00:00
closure_7 = {};
2026-07-20 16:05:17 +00:00
},
GUILD_POWERUP_CATALOG_FETCH_SUCCESS: function handleGuildPowerupCatalogFetchSuccess(guildId) {
guildId = guildId.guildId;
({ allPowerups, powerupCatalog } = guildId);
2026-07-29 08:29:29 +00:00
if (null == obj[guildId]) {
obj = { allPowerups: null, powerupCatalog: null, unlockedPowerups: null, appliedBoosts: null };
obj[0] = {};
obj[1] = {};
obj[2] = {};
obj[3] = calculateAppliedBoosts(guildId);
obj[guildId] = obj;
}
obj = {};
2026-07-23 10:11:24 +00:00
const merged = Object.assign(obj);
2026-07-20 16:05:17 +00:00
obj = {};
2026-07-29 08:29:29 +00:00
const merged1 = Object.assign(obj[guildId]);
obj.allPowerups = allPowerups;
obj.powerupCatalog = powerupCatalog;
obj.catalogFetchCooldown = Date.now();
obj.hasFetchedPowerupCatalog = true;
2026-07-20 16:05:17 +00:00
obj[guildId] = obj;
},
GUILD_BOOST_ENTITLEMENTS_FETCH_SUCCESS: function handleGuildBoostEntitlementsFetchSuccess(guildId) {
guildId = guildId.guildId;
2026-07-29 08:29:29 +00:00
if (null == obj[guildId]) {
obj = { allPowerups: null, powerupCatalog: null, unlockedPowerups: null, appliedBoosts: null };
obj[0] = {};
obj[1] = {};
obj[2] = {};
obj[3] = calculateAppliedBoosts(guildId);
obj[guildId] = obj;
}
obj = {};
2026-07-23 10:11:24 +00:00
const merged = Object.assign(obj);
2026-07-20 16:05:17 +00:00
obj = {};
2026-07-29 08:29:29 +00:00
const merged1 = Object.assign(obj[guildId]);
obj.unlockedPowerups = guildId.unlockedPowerups;
obj.appliedBoosts = calculateAppliedBoosts(guildId);
obj.unlockedPowerupsFetchCooldown = Date.now();
obj.hasFetchedUnlockedPowerups = true;
2026-07-20 16:05:17 +00:00
obj[guildId] = obj;
},
GUILD_POWERUP_ENTITLEMENTS_CREATE: function handleGuildPowerupCreated(arg0) {
2026-07-29 08:29:29 +00:00
({ guildId, entitlements } = arg0);
2026-08-24 06:08:38 +00:00
c0 = true;
closure_1 = undefined;
2026-07-29 08:29:29 +00:00
if (null == obj[guildId]) {
obj = { allPowerups: null, powerupCatalog: null, unlockedPowerups: null, appliedBoosts: null };
obj[0] = {};
obj[1] = {};
obj[2] = {};
obj[3] = calculateAppliedBoosts(guildId);
obj[guildId] = obj;
}
2026-08-24 06:08:38 +00:00
closure_1 = tmp3;
2026-07-29 08:29:29 +00:00
const item = entitlements.forEach((sku_id) => {
if (c0) {
2026-08-24 06:08:38 +00:00
unlockedPowerups.unlockedPowerups[sku_id.sku_id] = sku_id;
2026-07-29 08:29:29 +00:00
} else {
delete tmp2[tmp];
}
});
obj = {};
const merged = Object.assign(obj);
obj = {};
const merged1 = Object.assign(tmp3);
obj.appliedBoosts = calculateAppliedBoosts(guildId);
obj[guildId] = obj;
2026-07-20 16:05:17 +00:00
},
GUILD_POWERUP_ENTITLEMENTS_DELETE: function handleGuildPowerupDeleted(arg0) {
2026-07-29 08:29:29 +00:00
({ guildId, entitlements } = arg0);
2026-08-24 06:08:38 +00:00
c0 = false;
closure_1 = undefined;
2026-07-29 08:29:29 +00:00
if (null == obj[guildId]) {
obj = { allPowerups: null, powerupCatalog: null, unlockedPowerups: null, appliedBoosts: null };
obj[0] = {};
obj[1] = {};
obj[2] = {};
obj[3] = calculateAppliedBoosts(guildId);
obj[guildId] = obj;
}
2026-08-24 06:08:38 +00:00
closure_1 = tmp3;
2026-07-29 08:29:29 +00:00
const item = entitlements.forEach((sku_id) => {
if (c0) {
2026-08-24 06:08:38 +00:00
unlockedPowerups.unlockedPowerups[sku_id.sku_id] = sku_id;
2026-07-29 08:29:29 +00:00
} else {
delete tmp2[tmp];
}
});
obj = {};
const merged = Object.assign(obj);
obj = {};
const merged1 = Object.assign(tmp3);
obj.appliedBoosts = calculateAppliedBoosts(guildId);
obj[guildId] = obj;
2026-07-20 16:05:17 +00:00
},
GUILD_UPDATE: function handleGuildUpdated(guild) {
const id = guild.guild.id;
2026-07-29 08:29:29 +00:00
if (null == dependencyMap[id]) {
let obj = { allPowerups: null, powerupCatalog: null, unlockedPowerups: null, appliedBoosts: null };
obj[0] = {};
obj[1] = {};
obj[2] = {};
obj[3] = calculateAppliedBoosts(id);
dependencyMap[id] = obj;
}
obj = {};
const merged = Object.assign(dependencyMap[id]);
obj.appliedBoosts = calculateAppliedBoosts(id);
dependencyMap[id] = obj;
2026-07-20 16:05:17 +00:00
},
GAME_SERVER_FETCH_INSTANCES_SUCCESS: function handleGameServerInstanceFetched(guildId) {
guildId = guildId.guildId;
2026-07-29 08:29:29 +00:00
if (null == dependencyMap[guildId]) {
let obj = { allPowerups: null, powerupCatalog: null, unlockedPowerups: null, appliedBoosts: null };
obj[0] = {};
obj[1] = {};
obj[2] = {};
obj[3] = calculateAppliedBoosts(guildId);
dependencyMap[guildId] = obj;
}
obj = {};
const merged = Object.assign(dependencyMap[guildId]);
obj.appliedBoosts = calculateAppliedBoosts(guildId);
dependencyMap[guildId] = obj;
2026-07-20 16:05:17 +00:00
}
});
2026-08-24 06:08:38 +00:00
const result = require("set").fileFinishedImporting("modules/premium/powerups/GuildPowerupsStore.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default guildPowerupsStore;