isaacscript-common
Version:
Helper functions and features for IsaacScript mods.
132 lines (131 loc) • 6.96 kB
JavaScript
;
/**
* Constants relating to collections for various vanilla objects.
*
* @module
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.VANILLA_PILL_EFFECTS_SET = exports.VANILLA_PILL_EFFECTS = exports.VANILLA_PILL_EFFECT_RANGE = exports.VANILLA_CARD_TYPES_SET = exports.VANILLA_CARD_TYPES = exports.VANILLA_CARD_TYPE_RANGE = exports.VANILLA_TRINKET_TYPES_SET = exports.VANILLA_TRINKET_TYPES = exports.VANILLA_TRINKET_TYPE_RANGE = exports.VANILLA_COLLECTIBLE_TYPES_SET = exports.VANILLA_COLLECTIBLE_TYPES = exports.VANILLA_COLLECTIBLE_TYPE_RANGE = void 0;
const types_1 = require("../functions/types");
const utils_1 = require("../functions/utils");
const ReadonlySet_1 = require("../types/ReadonlySet");
const cachedClasses_1 = require("./cachedClasses");
const constantsFirstLast_1 = require("./constantsFirstLast");
// ------------
// Collectibles
// ------------
/**
* An array that represents the range from the first vanilla collectible type to the last vanilla
* collectible type. This will include integers that do not represent any valid collectible types.
*
* This function is only useful when building collectible type objects. For most purposes, you
* should use the `VANILLA_COLLECTIBLE_TYPES` or `VANILLA_COLLECTIBLE_TYPES_SET` constants instead.
*/
exports.VANILLA_COLLECTIBLE_TYPE_RANGE = (0, utils_1.iRange)(constantsFirstLast_1.FIRST_COLLECTIBLE_TYPE, constantsFirstLast_1.LAST_VANILLA_COLLECTIBLE_TYPE);
/**
* An array that contains every valid vanilla collectible type, as verified by the
* `ItemConfig.GetCollectible` method. Vanilla collectible types are not contiguous, so every valid
* must be verified. (There are several gaps, e.g. 666.)
*
* If you need to do O(1) lookups, use the `VANILLA_COLLECTIBLE_TYPES_SET` constant instead.
*/
// eslint-disable-next-line complete/strict-enums
exports.VANILLA_COLLECTIBLE_TYPES = exports.VANILLA_COLLECTIBLE_TYPE_RANGE.filter((potentialCollectibleType) => {
const collectibleType = (0, types_1.asCollectibleType)(potentialCollectibleType);
const itemConfigItem = cachedClasses_1.itemConfig.GetCollectible(collectibleType);
return itemConfigItem !== undefined;
});
/**
* A set that contains every valid vanilla collectible type, as verified by the
* `ItemConfig.GetCollectible` method. Vanilla collectible types are not contiguous, so every valid
* must be verified. (There are several gaps, e.g. 666.)
*/
exports.VANILLA_COLLECTIBLE_TYPES_SET = new ReadonlySet_1.ReadonlySet(exports.VANILLA_COLLECTIBLE_TYPES);
// --------
// Trinkets
// --------
/**
* An array that represents the range from the first vanilla trinket type to the last vanilla
* trinket type. This will include integers that do not represent any valid trinket types.
*
* This function is only useful when building trinket type objects. For most purposes, you should
* use the `VANILLA_TRINKET_TYPES` or `VANILLA_TRINKET_TYPES_SET` constants instead.
*/
exports.VANILLA_TRINKET_TYPE_RANGE = (0, utils_1.iRange)(constantsFirstLast_1.FIRST_TRINKET_TYPE, constantsFirstLast_1.LAST_VANILLA_TRINKET_TYPE);
/**
* An array that contains every valid vanilla trinket type, as verified by the
* `ItemConfig.GetTrinket` method. Vanilla trinket types are not contiguous, so every valid must be
* verified. (The only gap is 47 for `POLAROID_OBSOLETE`.)
*
* If you need to do O(1) lookups, use the `VANILLA_TRINKET_TYPES_SET` constant instead.
*/
// eslint-disable-next-line complete/strict-enums
exports.VANILLA_TRINKET_TYPES = exports.VANILLA_TRINKET_TYPE_RANGE.filter((potentialTrinketType) => {
const trinketType = (0, types_1.asTrinketType)(potentialTrinketType);
const itemConfigTrinket = cachedClasses_1.itemConfig.GetTrinket(trinketType);
return itemConfigTrinket !== undefined;
});
/**
* A set that contains every valid vanilla trinket type, as verified by the `ItemConfig.GetTrinket`
* method. Vanilla trinket types are not contiguous, so every valid must be verified. (The only gap
* is 47 for `POLAROID_OBSOLETE`.)
*/
exports.VANILLA_TRINKET_TYPES_SET = new ReadonlySet_1.ReadonlySet(exports.VANILLA_TRINKET_TYPES);
// ----------
// Card Types
// ----------
/**
* An array that represents the range from the first vanilla card type to the last vanilla card
* type.
*
* This function is only useful when building card type objects. For most purposes, you should use
* the `VANILLA_CARD_TYPES` or `VANILLA_CARD_TYPES_SET` constants instead.
*/
exports.VANILLA_CARD_TYPE_RANGE = (0, utils_1.iRange)(constantsFirstLast_1.FIRST_CARD_TYPE, constantsFirstLast_1.LAST_VANILLA_CARD_TYPE);
/**
* An array that contains every valid vanilla card type, as verified by the `ItemConfig.GetCard`
* method. Vanilla card types are contiguous, but we validate every entry to double check.
*
* If you need to do O(1) lookups, use the `VANILLA_CARD_TYPES_SET` constant instead.
*/
// eslint-disable-next-line complete/strict-enums
exports.VANILLA_CARD_TYPES = exports.VANILLA_CARD_TYPE_RANGE.filter((potentialCardType) => {
const cardType = (0, types_1.asCardType)(potentialCardType);
const itemConfigCard = cachedClasses_1.itemConfig.GetCard(cardType);
return itemConfigCard !== undefined;
});
/**
* A set that contains every valid vanilla card type, as verified by the `ItemConfig.GetCard`
* method. Vanilla card types are contiguous, but we validate every entry to double check.
*/
exports.VANILLA_CARD_TYPES_SET = new ReadonlySet_1.ReadonlySet(exports.VANILLA_CARD_TYPES);
// ------------
// Pill Effects
// ------------
/**
* An array that represents the range from the first vanilla pill effect to the last vanilla pill
* effect.
*
* This function is only useful when building pill effect objects. For most purposes, you should use
* the `VANILLA_PILL_EFFECTS` or `VANILLA_PILL_EFFECTS_SET` constants instead.
*/
exports.VANILLA_PILL_EFFECT_RANGE = (0, utils_1.iRange)(constantsFirstLast_1.FIRST_PILL_EFFECT, constantsFirstLast_1.LAST_VANILLA_PILL_EFFECT);
/**
* An array that contains every valid vanilla pill effect, as verified by the
* `ItemConfig.GetPillEffect` method. Vanilla pill effects are contiguous, but we validate every
* entry to double check.
*
* If you need to do O(1) lookups, use the `VANILLA_PILL_EFFECT_SET` constant instead.
*/
// eslint-disable-next-line complete/strict-enums
exports.VANILLA_PILL_EFFECTS = exports.VANILLA_PILL_EFFECT_RANGE.filter((potentialPillEffect) => {
const pillEffect = (0, types_1.asPillEffect)(potentialPillEffect);
const itemConfigPillEffect = cachedClasses_1.itemConfig.GetPillEffect(pillEffect);
return itemConfigPillEffect !== undefined;
});
/**
* A set that contains every valid vanilla pill effect, as verified by the
* `ItemConfig.GetPillEffect` method. Vanilla pill effects are contiguous, but we validate every
* entry to double check.
*/
exports.VANILLA_PILL_EFFECTS_SET = new ReadonlySet_1.ReadonlySet(exports.VANILLA_PILL_EFFECTS);